You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
722 B
Bash
36 lines
722 B
Bash
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
usage $0: [-c]
|
|
|
|
Options:
|
|
-c, --clean removes the service and binary
|
|
EOF
|
|
}
|
|
|
|
service="$HOME/.config/systemd/user/timesheet.service"
|
|
bin="$HOME/.local/bin/timetracker"
|
|
|
|
if [ -n "$1" ] ; then
|
|
# arguement given
|
|
if [[ $1 =~ ^-(c|-clean)$ ]] ; then
|
|
# clean
|
|
[ -f "$service" ] && systemctl --user disable "timesheet.service" && rm -f "$service"
|
|
[ -f "$bin" ] && rm -vf "$bin"
|
|
exit 0
|
|
else
|
|
echo "option $1 not recognized" >&2
|
|
usage
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
install -vm 755 "timetracker" "$bin"
|
|
cp "timesheet.service" "$service"
|
|
systemctl --user enable "timesheet.service"
|
|
|
|
echo "Timetracker installed successfully"
|