gitea/scripts/systemd/persist

29 lines
621 B
Bash
Executable File

#!/bin/bash
declare OPTARG
declare OPTION
declare OPTIND=0
state=enable
while getopts 'd' OPTION; do
case "$OPTION" in
d) state=disable;;
esac
done
shift $(( $OPTIND - 1 ))
Instance=$1
ServiceName=gitea
Instance=$1
[[ ! $1 ]] && echo warning no instance supplied using default && Instance=default
Service=$ServiceName@$Instance
if systemctl is-active --quiet $Service; then
sudo systemctl $state $Service
systemctl is-enabled --quiet $Service && \
echo $Service boot persistance is enabled || \
echo $Service boot persistance is disabled
else
echo "can't persist $Instance as it must be running first"
fi