File: weakforced.postinst

package info (click to toggle)
weakforced 3.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,040 kB
  • sloc: cpp: 20,397; python: 2,002; sh: 700; makefile: 432
file content (40 lines) | stat: -rwxr-xr-x 1,146 bytes parent folder | download
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
#!/bin/sh

set -e

WFORCECONF=/etc/wforce/wforce.conf
WFORCECONF_NEW="${WFORCECONF}.new"

case "$1" in
  configure)
    cp -a "/usr/share/doc/weakforced/config_example/wforce.conf" "${WFORCECONF_NEW}"
    if [ ! -e "${WFORCECONF}" ]; then
        cp -a "/usr/share/doc/weakforced/config_example/wforce.conf" "${WFORCECONF}"
        echo -n "Modifying ${WFORCECONF_NEW} to replace password and key as no original conf file exists."
        SETKEY=`echo "makeKey()" | wforce | grep setKey`
        WEBPWD=`dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 | rev | cut -b 2-14 | rev`
        sed -e "s#--WEBPWD#$WEBPWD#" -e "s#--SETKEY#$SETKEY#" -i "${WFORCECONF_NEW}"
    fi

    ucf --three-way --debconf-ok "${WFORCECONF_NEW}" "${WFORCECONF}"
    ucfr weakforced "${WFORCECONF}"
    chmod 0640 "${WFORCECONF}"
    chown wforce:wforce "${WFORCECONF}"
    rm -f "${WFORCECONF_NEW}"
  ;;

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

# Init script has errors in previous versions. Postinst script should just
# return the exit status of this script
initscript_error() {
	return $1
}

#DEBHELPER#

exit 0