#!/bin/bash PIDFILE=/var/run/zot.pid LOGFILE=/var/log/zot.log CONFIG_FILE=/etc/zot/config.yaml zot_start() { if [ -s $PIDFILE ]; then echo "zot is already running: $(cat $PIDFILE)." exit 1 fi /usr/bin/zot serve $CONFIG_FILE >> $LOGFILE 2>&1 & pidof /usr/bin/zot > $PIDFILE } zot_stop() { if [ -s $PIDFILE ]; then kill $(cat $PIDFILE) rm -f $PIDFILE else echo "zot is not running." fi } zot_restart() { zot_stop sleep 1 zot_start } zot_status() { if [ -s $PIDFILE ]; then echo "zot is running: $(cat $PIDFILE)." else echo "zot is not running." fi } case "$1" in 'start') zot_start ;; 'stop') zot_stop ;; 'restart') zot_restart ;; 'status') zot_status ;; *) echo "usage: $0 start|stop|restart|status" ;; esac