Add overwrite warning to systemd install

This commit is contained in:
Christian Bundy 2020-01-03 15:27:20 -08:00
parent 8d56405251
commit 280bf8df70
1 changed files with 11 additions and 6 deletions

View File

@ -3,16 +3,21 @@
SCRIPT_DIR=`dirname "$0"`
test "$XDG_CONFIG_HOME" || XDG_CONFIG_HOME=$HOME/.config
test "$SYSTEMD_USER_HOME" || SYSTEMD_USER_HOME="$XDG_CONFIG_HOME"/systemd/user
mkdir -p "$SYSTEMD_USER_HOME"
test -f "$SYSTEMD_USER_HOME"/oasis.service || cp "$SCRIPT_DIR"/oasis.service "$SYSTEMD_USER_HOME"/
systemctl --user daemon-reload
TARGET_PATH="$SYSTEMD_USER_HOME"/oasis.service
printf "oasis service has been installed to %s\n\n" "$SYSTEMD_USER_HOME"
if [ -f "$TARGET_PATH" ]; then
printf "Cowardly refusing to overwrite file: %s\n\n" "$TARGET_PATH"
else
mkdir -p "$SYSTEMD_USER_HOME"
cp "$SCRIPT_DIR"/oasis.service "$TARGET_PATH"
systemctl --user daemon-reload
printf "Service configuration has been installed to: %s\n\n" "$TARGET_PATH"
fi
printf "to enable for the current user, run\n\n"
printf "To start Oasis automatically in the future, run:\n\n"
printf " systemctl --user enable oasis\n\n"
printf "to start right now, run\n\n"
printf "To start and open Oasis right now, run:\n\n"
printf " systemctl --user start oasis\n"
printf " xdg-open http://localhost:4515\n"