File: open-isns-discoveryd.postinst

package info (click to toggle)
open-isns 0.100-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,472 kB
  • sloc: ansic: 19,959; sh: 3,211; python: 1,083; perl: 839; makefile: 213
file content (81 lines) | stat: -rw-r--r-- 2,778 bytes parent folder | download | duplicates (6)
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
80
81
#!/bin/sh
# postinst script for open-isns-discoveryd

. /usr/share/debconf/confmodule

set -e

start=0

case "$1" in
    configure)
        db_get open-isns-discoveryd/isns-server
        if [ -n "$RET" ] ; then
            start=1
            SERVER_PUBKEY=""
            OWNKEY=""
            SERVER="$RET"
            RET=""
            db_get open-isns-discoveryd/server-pubkey || true
            if [ -n "$RET" ] && [ -f "$RET" ] ; then
                SERVER_PUBKEY="$RET"
            fi
            RET=""
            db_get open-isns-discvoeryd/own-key || true
            if [ -n "$RET" ] && [ -f "$RET" ] ; then
                OWNKEY="$RET"
            fi
            # Only install keys if no previous keys exist, but only
            # install them we'll end up with both keys.
            if [ -n "$SERVER_PUBKEY" ] && ( [ -n "$OWNKEY" ] || [ -f /etc/isns/auth_key ] ) && [ ! -e /etc/isns/server_key.pub ] ; then
                cp -a "$SERVER_PUBKEY" /etc/isns/server_key.pub
                chown root:root /etc/isns/server_key.pub
                chmod 0644 /etc/isns/server_key.pub
            fi
            if [ -f /etc/isns/server_key.pub ] && [ -n "$OWNKEY" ] && [ ! -e /etc/isns/auth_key ] ; then
                cp -a "$OWNKEY" /etc/isns/auth_key
                chown root:root /etc/isns/auth_key
                chmod 0600 /etc/isns/auth_key
            fi
            # Modify configuration file (config script determines
            # if we should or not)
            RET=false
            db_get open-isns-discoveryd/isns-server-override || true
            if [ "$RET" = true ] ; then
                sed -i 's~^[[:space:]]*#*[[:space:]]*ServerAddress[[:space:]]*=.*~ServerAddress  = '"$SERVER"'~' /etc/isns/isnsdd.conf
                db_set open-isns-discoveryd/isns-server-override false
            fi
        else
            # test if ServerAddress is properly configured; if so, start/restart
            # the server
            RET="$(grep -E '^[[:space:]]*ServerAddress[[:space:]]*=' /etc/isns/isnsdd.conf | cut -d= -f2- | cut -d# -f1 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
            if [ -n "$RET" ] ; then
                start=1
            fi
        fi
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

#DEBHELPER#

# Start isnsdd, but only if the user specified a remote server,
# because otherwise it won't work. Close fd 3 (used by debconf)
# to make sure that it's not left open by the daemon on
# sysvinit systems.
if [ $start -eq 1 ] && [ -x "/etc/init.d/isnsdd" ] ; then
    if [ -n "$2" ] ; then
        invoke-rc.d isnsdd restart 3>&-
    else
        invoke-rc.d isnsdd start 3>&-
    fi
fi

exit 0