Use user service

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2024-02-26 17:41:04 +00:00
parent 72c5364537
commit 43b3db5c0c
3 changed files with 9 additions and 6 deletions

View file

@ -10,4 +10,4 @@ Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target
WantedBy=default.target

View file

@ -89,11 +89,12 @@ sudo cp $CONFIG_DIR_PROV/* ${GARM_CONFIG_DIR}/test-provider
sudo mv $BINARIES_DIR/* /usr/local/bin/
mkdir -p $HOME/.local/share/systemd/user/
cat $CONFIG_DIR/garm.service| envsubst | tee $HOME/.local/share/systemd/user/${GARM_SERVICE_NAME}.service > /dev/null
cat $CONFIG_DIR/garm.service| envsubst | sudo tee /lib/systemd/system/${GARM_SERVICE_NAME}@.service > /dev/null
sudo chown -R $RUN_USER:$RUN_USER ${GARM_CONFIG_DIR}
systemctl --user daemon-reload
systemctl --user restart ${GARM_SERVICE_NAME}
sudo systemctl daemon-reload
sudo systemctl enable ${GARM_SERVICE_NAME}@${RUN_USER}
sudo systemctl restart ${GARM_SERVICE_NAME}@${RUN_USER}
wait_open_port 127.0.0.1 ${GARM_PORT}
echo "GARM is up and running"

View file

@ -15,8 +15,10 @@ if [ -z $GARM_SERVICE_NAME ]; then
fi
if [ -f "$HOME/.local/share/systemd/user/${GARM_SERVICE_NAME}.service" ];then
systemctl --user stop $GARM_SERVICE_NAME.service
rm $HOME/.local/share/systemd/user/${GARM_SERVICE_NAME}.service
sudo systemctl stop $GARM_SERVICE_NAME@${RUN_USER}
sudo systemctl disable $GARM_SERVICE_NAME@${RUN_USER}
sudo rm /lib/systemd/system/${GARM_SERVICE_NAME}@.service
sudo systemctl daemon-reload
fi
if [ -d "$GARM_CONFIG_DIR" ] && [ -f "$GARM_CONFIG_DIR/config.toml" ] && [ -f "$GARM_CONFIG_DIR/garm-provider-lxd.toml" ];then