Last active
May 3, 2019 13:54
-
-
Save XieJiSS/3df9a5ca5f7bcdc5d6cc261cb6d7497d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description = AWTRIX Service | |
After network.target = awtrix.service | |
[Service] | |
Type = forking | |
WorkingDirectory = /usr/local/awtrix | |
ExecStart = /usr/local/bin/awtrix.sh start | |
ExecStop = /usr/local/bin/awtrix.sh stop | |
ExecReload = /usr/local/bin/awtrix.sh reload | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
SERVICE_NAME=awtrix | |
PATH_TO_JAR=/usr/local/awtrix/awtrix.jar | |
PID_PATH_NAME=/tmp/awtrix-pid | |
case $1 in | |
start) | |
echo "Starting $SERVICE_NAME ..." | |
if [ ! -f $PID_PATH_NAME ]; then | |
sudo nohup java -jar $PATH_TO_JAR /tmp 2>> /dev/null >> /dev/null & echo $! > $PID_PATH_NAME | |
echo "$SERVICE_NAME started."; | |
else | |
echo "$SERVICE_NAME is already running."; | |
fi | |
;; | |
stop) | |
if [ -f $PID_PATH_NAME ]; then | |
PID=$(cat $PID_PATH_NAME); | |
kill $PID; | |
echo "$SERVICE_NAME stopped."; | |
rm $PID_PATH_NAME; | |
else | |
echo "$SERVICE_NAME isn't running."; | |
fi | |
;; | |
restart) | |
if [ -f $PID_PATH_NAME ]; then | |
PID=$(cat $PID_PATH_NAME); | |
echo "Stopping $SERVICE_NAME ..."; | |
kill $PID; | |
rm $PID_PATH_NAME | |
echo "Starting $SERVICE_NAME ..." | |
sudo nohup java -jar $PATH_TO_JAR /tmp 2>> /dev/null >> /dev/null & echo $! > $PID_PATH_NAME | |
echo "$SERVICE_NAME started."; | |
else | |
echo "$SERVICE_NAME is not running. Use 'awtrix.sh start' instead."; | |
fi | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment