aboutsummaryrefslogtreecommitdiff
path: root/zot/rc.zot
blob: ec63fa805efe16edf59f8fdf8da3ab7afbcf99b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/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