summarylogtreecommitdiffstats
path: root/10-openntpd
blob: 64b3550ac01778349947abf38ee28bfcf6157328 (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
#!/bin/sh

if [ -e "/run/systemd/system" ]; then
    case "$2" in
        up | vpn-up)
            systemctl start openntpd.service
        ;;
        down | vpn-down)
            # Check if still online (e.g. because of another network connection)
            if [ ! "$(nmcli networking connectivity)" = "full" ]; then
                systemctl stop openntpd.service
            fi
        ;;
    esac
elif [ -e "/etc/rc.d/openntpd" ]; then
    case "$2" in
        up | vpn-up)
            /etc/rc.d/openntpd start
        ;;
        down | vpn-down)
            # Check if still online (e.g. because of another network connection)
            if [ ! "$(nmcli networking connectivity)" = "full" ]; then
                /etc/rc.d/openntpd stop
            fi
        ;;
    esac
else
    echo "Init system not detected, doing nothing!"
    exit 2
fi