File: wforce.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 (54 lines) | stat: -rwxr-xr-x 1,746 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
#
#

set -e

WFORCECONF=/etc/wforce/wforce.conf

case "$1" in
  configure)
    if [ -z "`getent group wforce`" ]; then
      addgroup --quiet --system wforce
    fi
    if [ -z "`getent passwd wforce`" ]; then
      echo -n "Creating user and group wforce..."
      adduser --quiet --system --home /var/spool/wforce --shell /bin/false --ingroup wforce --disabled-password --disabled-login --gecos "wforce" wforce
      echo "done"
    fi
    if [ -e "/etc/wforce.conf" ]; then
       echo "Found old config file /etc/wforce.conf. Copying it to /etc/wforce/wforce.conf"
       if [ -e "/etc/wforce/wforce.conf" ]; then
          echo "Found also new config file /etc/wforce/wforce.conf"
          mv /etc/wforce/wforce.conf /etc/wforce/wforce.conf.backup.$$ && \
          echo "Renamed /etc/wforce/wforce.conf to /etc/wforce/wforce.conf.backup.$$"
       fi
       cp -a /etc/wforce.conf /etc/wforce.conf.backup.$$ && \
       echo "Renamed old /etc/wforce.conf to /etc/wforce.conf.backup.$$"
       mv /etc/wforce.conf /etc/wforce/wforce.conf && \
       echo "Moved /etc/wforce.conf to /etc/wforce/wforce.conf"
    fi
    if [ -z "$2" ]; then
        echo -n "Modifying wforce.conf to replace password and key..."
        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
        echo "done"
    fi
  ;;

  *)
    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