summaryrefslogtreecommitdiff
path: root/debian/hurd.postinst
blob: 081c039b81d1ddf718299f239a12fd959b61c914 (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh

set -e

if [ "$1" = configure ] && [ "$2" ]; then
	# Upgrade from old version: drop /libexec/runsystem
	update-alternatives --quiet \
		--remove runsystem /libexec/runsystem.gnu
fi
update-alternatives --quiet \
	--install /etc/hurd/runsystem runsystem /etc/hurd/runsystem.gnu 5 \
	--slave /sbin/halt halt /sbin/halt-hurd \
	--slave /sbin/reboot reboot /sbin/reboot-hurd

update-alternatives \
	--install /usr/bin/fakeroot fakeroot /usr/bin/fakeroot-hurd 60

update-alternatives \
	--install /bin/ps ps /bin/ps-hurd 60

update-alternatives \
	--install /usr/bin/uptime uptime /usr/bin/uptime-hurd 30

update-alternatives \
	--install /usr/bin/vmstat vmstat /usr/bin/vmstat-hurd 60

update-alternatives \
	--install /usr/bin/w w /usr/bin/w-hurd 60

ADDUSERCONF='/etc/adduser.conf'

if test -f $ADDUSERCONF; then
    FIRST_SYSTEM_UID=$(sed -n "s/^[[:space:]]*FIRST_SYSTEM_UID[[:space:]]*=[[:space:]]*[\"']\?\([^\"']*\)[\"']\?/\1/p" $ADDUSERCONF)
    LAST_SYSTEM_UID=$(sed -n "s/^[[:space:]]*LAST_SYSTEM_UID[[:space:]]*=[[:space:]]*[\"']\?\([^\"']*\)[\"']\?/\1/p" $ADDUSERCONF)
    FIRST_SYSTEM_GID=$(sed -n "s/^[[:space:]]*FIRST_SYSTEM_GID[[:space:]]*=[[:space:]]*[\"']\?\([^\"']*\)[\"']\?/\1/p" $ADDUSERCONF)
    LAST_SYSTEM_GID=$(sed -n "s/^[[:space:]]*LAST_SYSTEM_GID[[:space:]]*=[[:space:]]*[\"']\?\([^\"']*\)[\"']\?/\1/p" $ADDUSERCONF)
fi

if test -z "$FIRST_SYSTEM_UID"; then
    FIRST_SYSTEM_UID=100
fi
if test -z "$LAST_SYSTEM_UID"; then
    LAST_SYSTEM_UID=999
fi
if test -z "$FIRST_SYSTEM_GID"; then
    FIRST_SYSTEM_GID=100
fi
if test -z "$LAST_SYSTEM_GID"; then
    LAST_SYSTEM_GID=999
fi

if [ "$1" = configure ]; then
  add-shell /bin/loginpr || true
  if ! getent passwd login >/dev/null; then
    useradd -K UID_MIN=$FIRST_SYSTEM_UID -K UID_MAX=$LAST_SYSTEM_UID \
      -K GID_MIN=$FIRST_SYSTEM_GID -K GID_MAX=$LAST_SYSTEM_GID \
      --home-dir /etc/login --no-create-home \
      --shell /bin/loginpr --comment "login user" \
      --user-group login
  fi
fi

#DEBHELPER#

# Remove alternative introduced by 20111106-1
update-alternatives --remove random /dev/random-hurd

if [ "$1" = configure ] && [ "$2" ]; then
	# Upgrade: create the missing device and server nodes
	if showtrans /dev/random 2> /dev/null | grep -q /tmp/entropy.sock
	then
		# old random-egd translator, remove
		settrans -go /dev/random
		settrans -go /dev/urandom
		( cd /dev ; rm -f random urandom )
	fi
	/usr/lib/hurd/setup-translators -K

	# upgrade pfinet into using DDE node
	if PFINET=`showtrans /servers/socket/2` 2> /dev/null
	then
		PFINET=`echo "$PFINET" | sed 's_ eth_ /dev/eth_'`
		PFINET=`echo "$PFINET" | sed 's_=eth_=/dev/eth_'`
		settrans -pk /servers/socket/2 $PFINET
	fi
	if PFINET6="`showtrans /servers/socket/26`" 2> /dev/null
	then
		PFINET6=`echo "$PFINET6" | sed 's_ eth_ /dev/eth_'`
		PFINET6=`echo "$PFINET6" | sed 's_=eth_=/dev/eth_'`
		settrans -pk /servers/socket/26 $PFINET6
	fi
fi

update-alternatives --install /hurd/random.sh random.sh /hurd/random-hurd.sh 10 \
		    --slave /hurd/urandom.sh urandom.sh /hurd/urandom-hurd.sh

if [ "$1" = configure ] ; then
	# Generate initial pool
	UMASK=`umask`
	umask 077
	[ -f /var/spool/random-seed ] || dd < /dev/urandom > /var/spool/random-seed bs=1 count=600 2> /dev/null
        # TODO: will need to run settrans -ga /dev/random at system stop to make
        # it save it back
	umask $UMASK
fi