summaryrefslogtreecommitdiff
path: root/debian/soledad-server.init
blob: 58c10c3a4b439a77f9a4af4b223bfcbba7293389 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh
### BEGIN INIT INFO
# Provides:          soledad
# Required-Start:    $network $named $remote_fs $syslog $time
# Required-Stop:     $network $named $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start soledad daemon at boot time
# Description:       Synchronization of locally encrypted data among devices
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
PIDFILE=/var/run/soledad.pid
RUNDIR=/var/lib/soledad/
OBJ=leap.soledad.server.application
LOGFILE=/var/log/soledad.log
HTTPS_PORT=2424
CERT_PATH=/etc/leap/soledad-server.pem
PRIVKEY_PATH=/etc/leap/soledad-server.pem
TWISTD_PATH=/usr/bin/twistd
HOME=/var/lib/soledad/

[ -r /etc/default/soledad ] && . /etc/default/soledad

test -r /etc/leap/ || exit 0

. /lib/lsb/init-functions

is_true() {
    if [ "x$1" = "xtrue" -o "x$1" = "xyes" -o "x$1" = "x0" ] ; then
        return 0
    else
        return 1
    fi
}

case "$1" in
    start)
        if is_true "$START" ; then
            echo -n "Starting soledad: twistd"
            start-stop-daemon --start --quiet --exec $TWISTD_PATH -- \
                --pidfile=$PIDFILE \
                --logfile=$LOGFILE \
                web \
                --wsgi=$OBJ \
                --port=ssl:$HTTPS_PORT:privateKey=$PRIVKEY_PATH:certKey=$CERT_PATH
            echo "."
        else
            echo ""
            echo "soledad-server is not configured to start, please edit /etc/default/soledad to enable"
        fi
        ;;
    stop)
        echo -n "Stopping soledad: twistd"
        start-stop-daemon --stop --quiet  \
            --pidfile $PIDFILE
        echo "."
        ;;

    restart)
        $0 stop
        $0 start
        ;;

    force-reload)
        $0 restart
        ;;

    status)
        status_of_proc -p $PIDFILE $TWISTD_PATH soledad && exit 0 || exit $?
        ;;

    *)
        echo "Usage: /etc/init.d/soledad {start|stop|restart|force-reload|status}" >&2
        exit 1
        ;;
esac

exit 0