File: alamin-server.postinst

package info (click to toggle)
alamin 0.3.7-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,208 kB
  • ctags: 142
  • sloc: perl: 4,402; sh: 356; makefile: 92
file content (93 lines) | stat: -rw-r--r-- 3,217 bytes parent folder | download | duplicates (3)
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
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
# postinst script for alamin-server 

set -e
# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see /usr/share/doc/packaging-manual/
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.

case "$1" in
    configure)
	# Setup alamin user/group and log dir/perms.
	addgroup --quiet alamin 2>/dev/null || true
	adduser --quiet --system \
		--ingroup alamin \
		--no-create-home \
		--disabled-password \
		alamin 2>/dev/null || true
	usermod -c "Alamin GSM SMS Gateway" \
		-d /var/spool/alamin \
		-g alamin \
		-G dialout \
		alamin
	mkdir -p /var/log/alamin
	touch /var/log/alamin/gsgd-accounting.log
	chown -R alamin.alamin /var/log/alamin
	chmod 2770 /var/log/alamin
	mkdir -p /var/run/alamin
	chown -R alamin.alamin /var/run/alamin
	chmod 2770 /var/run/alamin
	for dir in q1 q2 q3 q4 q5 q6 q7 q8 q9 tmp fail success;
            do mkdir -p /var/spool/alamin/${dir}
	done
	chown -R alamin.alamin /var/spool/alamin
	chmod -R 2770 /var/spool/alamin
	# Sorry, syslog-facility apparently doesn't understand \ to
	# indicate a new line :(
	EXEC_FAC="/usr/sbin/syslog-facility"
	SFU="/etc/alamin/syslog_facility_used"
	if ! test -f "$SFU"; then
	    if test -f "$EXEC_FAC"; then
	        ${EXEC_FAC} set all /var/log/alamin/gsgd_all.log info /var/log/alamin/gsgd_info.log warn /var/log/alamin/gsgd_warn.log err /var/log/alamin/gsgd_err.log debug /var/log/alamin/gsgd_debug.log > ${SFU} | exit 0
	        LOG_FAC=`cat $SFU`
	        if test ${LOG_FAC} = "none"; then
                    echo "Syslog facilities could not be added"
                    echo "Please read /usr/share/doc/alamin/LOGGING"
                else
                    perl -pi -e "s/^syslog syslog-facility/syslog ${LOG_FAC}/" \
		    /etc/alamin/gsgd.conf
		    echo "Syslog facilities successfully added"
  	        fi
            else
                echo "Your system does not have syslog-facility"
                echo "Perhaps you are using syslog-ng instead of sysklogd"
                echo "Syslog facilities could not be added"
                echo "Please read /usr/share/doc/alamin/LOGGING"
	    fi
	else 
	    LOG_FAC=`cat $SFU`
	    perl -pi -e "s/^syslog syslog-facility/syslog ${LOG_FAC}/" \
	    /etc/alamin/gsgd.conf
	fi

    ;;

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

    ;;

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

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#

exit 0