diff options
author | Jérôme Launay | 2023-09-22 13:50:09 +0200 |
---|---|---|
committer | Jérôme Launay | 2023-09-22 13:50:09 +0200 |
commit | 7e0ca39380b017a5818fc36836a8478ccabba2cc (patch) | |
tree | 23ea2459aebfa0251de8294a0a89253032ebb3b3 /g910-gkeys-git.install | |
parent | 142100f61231b10927fd9caffa37e4ce9afcbbc4 (diff) | |
download | aur-7e0ca39380b017a5818fc36836a8478ccabba2cc.tar.gz |
Switch to a user service
Diffstat (limited to 'g910-gkeys-git.install')
-rwxr-xr-x | g910-gkeys-git.install | 69 |
1 files changed, 52 insertions, 17 deletions
diff --git a/g910-gkeys-git.install b/g910-gkeys-git.install index 5ab48879a22d..c3ba2de57748 100755 --- a/g910-gkeys-git.install +++ b/g910-gkeys-git.install @@ -1,16 +1,28 @@ post_install() { + # make config dir + if [[ ! -d "$HOME"/.config/g910-gkeys ]]; then + mkdir "$HOME"/.config/g910-gkeys + fi + + # check for existing config file + if [[ ! -f "$HOME"/.config/g910-gkeys/config.json ]]; then + # if not copy default config to config dir + cp ./etc/config.json "$HOME"/.config/g910-gkeys/config.json + fi + + # reload daemon + systemctl --user daemon-reload + + # enable and start service if necessary + systemctl --user enable --now g910-gkeys.service + echo "" echo "#########################################################" echo "" - echo "You can now enable the service by:" - echo "" - echo " # systemctl enable g910-gkeys.service" - echo "" - echo "And run it with:" - echo "" - echo " # systemctl start g910-gkeys.service" - echo "" - echo "Log file is stored in /var/log/g910-gkeys.log" + echo "Service ${_appname} was enabled and started by default:" + echo "" + echo "Config is in ${HOME}/.config/g910-gkeys/config.json" + echo "Log file is stored in ${HOME}/g910-gkeys.log" echo "" echo "#########################################################" echo "" @@ -18,19 +30,42 @@ post_install() { post_upgrade() { + # make config dir + if [[ ! -d "$HOME"/.config/g910-gkeys ]]; then + mkdir "$HOME"/.config/g910-gkeys + fi + + # check for existing config file + if [[ ! -f "$HOME"/.config/g910-gkeys/config.json ]]; then + if [[ -f /etc/g910-gkeys/config.json ]]; then + # if old config exist move it to new location (will need root privileges) + sudo mv /etc/g910-gkeys/config.json "$HOME"/.config/g910-gkeys/config.json + sudo chown "$USER":"$USER" "$HOME"/.config/g910-gkeys/config.json + else + # if not copy default config to config dir + cp ./etc/config.json "$HOME"/.config/g910-gkeys/config.json + fi + fi + + # reload daemon + systemctl --user daemon-reload + + # enable and start service if necessary + systemctl --user enable --now g910-gkeys.service + echo "" echo "#########################################################" echo "" - echo "You can now enable the service by:" - echo "" - echo " # systemctl enable g910-gkeys.service" + echo "Service ${_appname} was enabled and started by default:" echo "" - echo "And run it with:" - echo "" - echo " # systemctl start g910-gkeys.service" - echo "" - echo "Log file is stored in /var/log/g910-gkeys.log" + echo "Config is in ${HOME}/.config/g910-gkeys/config.json" + echo "Log file is stored in ${HOME}/g910-gkeys.log" echo "" echo "#########################################################" echo "" } + +pre_remove() { + # shutdown and disable service + systemctl --user disable --now g910-gkeys +} |