2020-12-13 13:24:31 -08:00
|
|
|
#!/bin/bash
|
2020-12-13 17:16:53 -08:00
|
|
|
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
|
2020-12-13 13:24:31 -08:00
|
|
|
ServiceName=gitea
|
|
|
|
Instance=$1
|
|
|
|
[[ ! $1 ]] && echo warning no instance supplied using default && Instance=default
|
|
|
|
Service=$ServiceName@$Instance
|
2020-12-13 17:16:53 -08:00
|
|
|
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
|
2020-12-13 13:24:31 -08:00
|
|
|
echo "can't persist $Instance as it must be running first"
|
2020-12-13 17:16:53 -08:00
|
|
|
fi
|