summarylogtreecommitdiffstats
path: root/g910-gkeys-git.install
diff options
context:
space:
mode:
authorJérôme Launay2023-09-22 13:50:09 +0200
committerJérôme Launay2023-09-22 13:50:09 +0200
commit7e0ca39380b017a5818fc36836a8478ccabba2cc (patch)
tree23ea2459aebfa0251de8294a0a89253032ebb3b3 /g910-gkeys-git.install
parent142100f61231b10927fd9caffa37e4ce9afcbbc4 (diff)
downloadaur-7e0ca39380b017a5818fc36836a8478ccabba2cc.tar.gz
Switch to a user service
Diffstat (limited to 'g910-gkeys-git.install')
-rwxr-xr-xg910-gkeys-git.install69
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
+}