Project

General

Profile

Packaging Request #3384 ยป yggdrasil.txt

Gentoo yggdrasil init-scrypt /etc/init.d/yggdrasil - anonymous, 2023-01-25 01:03 AM

 
1
#!/sbin/openrc-run
2

    
3
description="An experiment in scalable routing as an encrypted IPv6 overlay network."
4

    
5
CONFFILE="/etc/yggdrasil.conf"
6
pidfile="/run/${RC_SVCNAME}.pid"
7

    
8
command="/usr/bin/yggdrasil"
9
extra_started_commands="reload"
10

    
11
depend() {
12
        use net dns logger
13
}
14

    
15
start_pre() {
16
        if [ ! -f "${CONFFILE}" ]; then
17
                ebegin "Generating new configuration file into ${CONFFILE}"
18
                if ! eval ${command} -genconf > ${CONFFILE}; then
19
                        eerror "Failed to generate configuration file"
20
                        exit 1
21
                fi
22
        fi
23

    
24
        if [ ! -e /dev/net/tun ]; then
25
                ebegin "Inserting TUN module"
26
                if ! modprobe tun;  then
27
                        eerror "Failed to insert TUN kernel module"
28
                        exit 1
29
                fi
30
        fi
31
}
32

    
33
start() {
34
        ebegin "Starting ${RC_SVCNAME}"
35
        start-stop-daemon --start --quiet \
36
                --pidfile "${pidfile}" \
37
                --make-pidfile \
38
                --background \
39
                --stdout /var/log/yggdrasil.stdout.log \
40
                --stderr /var/log/yggdrasil.stderr.log \
41
                --exec "${command}" -- -useconffile "${CONFFILE}"
42
        eend $?
43
}
44

    
45
reload() {
46
        ebegin "Reloading ${RC_SVCNAME}"
47
        start-stop-daemon --signal HUP --pidfile "${pidfile}"
48
        eend $?
49
}
50

    
51
stop() {
52
        ebegin "Stopping ${RC_SVCNAME}"
53
        start-stop-daemon --stop --pidfile "${pidfile}" --exec "${command}"
54
        eend $?
55
}
    (1-1/1)