File: postinst

package info (click to toggle)
stunnel4 3%3A5.50-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,492 kB
  • sloc: ansic: 15,914; sh: 5,645; pascal: 2,719; perl: 988; cpp: 650; makefile: 216
file content (67 lines) | stat: -rw-r--r-- 1,519 bytes parent folder | download | duplicates (9)
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
#!/bin/sh

set -e

USER="stunnel4"
CHOWN="/bin/chown"
#USERDEL="/usr/sbin/userdel"
ADDUSER="/usr/sbin/adduser"
ID="/usr/bin/id"
GROUPMOD="/usr/sbin/groupmod"
#GROUPDEL="/usr/sbin/groupdel"

###
# 1. get current stunnel uid and gid if user exists.
set -e
if $ID $USER > /dev/null 2>&1; then
   IUID=`$ID --user $USER`
   IGID=`$ID --group $USER`
else
   IUID="NONE"
   IGID="NONE"
fi

###
# 2. Ensure that no standard account or group will remain before adding the
#    new user
#if [ "$IUID" != "NONE" ]; then # remove existing user
#  $USERDEL $USER
#fi

#if $GROUPMOD $USER > /dev/null 2>&1; then 
#  $GROUPDEL $USER;
#fi

if [ "$IUID" = "NONE" ]; then
  $ADDUSER --system --disabled-password --disabled-login	\
           --home /var/run/stunnel4			\
	   --no-create-home --group $USER
fi

# /var/run/stunnel4 is not a directory, create it...
if ! test -d /var/run/stunnel4; then
  rm -rf /var/run/stunnel4;
  mkdir /var/run/stunnel4
fi
$CHOWN $USER:$USER /var/run/stunnel4 || true

# /var/log/stunnel4 is not a directory, create it...
if ! test -d /var/log/stunnel4; then
  rm -rf /var/log/stunnel4;
  mkdir /var/log/stunnel4
fi
$CHOWN -R $USER:$USER /var/log/stunnel4

# /var/lib/stunnel4 is not a directory, create it...
if ! test -d /var/lib/stunnel4; then
  rm -rf /var/lib/stunnel4;
  mkdir /var/lib/stunnel4
fi
$CHOWN -R $USER:$USER /var/lib/stunnel4

if ! test -f /var/log/stunnel4/stunnel.log; then
  touch /var/log/stunnel4/stunnel.log
  $CHOWN -R $USER:$USER /var/log/stunnel4/stunnel.log
fi

#DEBHELPER#