summaryrefslogtreecommitdiff
path: root/debian/rc
blob: f623aeb9e8f914d0d4830344bff8eea6d4e057b1 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
PATH=/bin:/sbin

swapon -a

if [ -r /fastboot ]
then
	rm -f /fastboot
	echo Fast boot ... skipping disk checks
elif [ $1x = autobootx ]
then
	echo Automatic boot in progress...
	date

	/sbin/fsck --preen --writable

	case $? in
	# Successful completion
	0)
		;;
	# Filesystem modified (but ok now)
	1 | 2)
		;;
	# Fsck couldn't fix it.
	4 | 8)
		echo "Automatic boot failed... help!"
		exit 1
		;;
	# Signal that really interrupted something
	20 | 130 | 131)
		echo "Boot interrupted"
		exit 1
		;;
	# Special `let fsck finish' interruption (SIGQUIT)
	12)
		echo "Boot interrupted (filesystem checks complete)"
		exit 1
		;;
	# Oh dear.
	*)
		echo "Unknown error during fsck"
		exit 1
		;;
	esac
fi

echo -n cleaning up left over files...
rm -f /etc/nologin
rm -f /var/lock/LCK.*
if test -d /tmp; then

  # Forcibly remove all translators in the directory.
  # It is then safe to attempt to remove files and descend directories.
  # All parameters must begin with "./".
  function remove_translators() {
    local f
    for f; do
      settrans -pagfS "$f"
      if [ -L "$f" ] || [ ! -d "$f" ]; then
	rm "$f"
      else
	remove_translators "$f"/* "$f"/.[!.] "$f"/.??*
	rmdir "$f"
      fi
    done
  }

  (cd /tmp
   shopt -s nullglob
   for f in * .[!.] .??*; do
     case "$f" in
     'lost+found'|'quotas') ;;
     *) remove_translators "./$f"
     esac
   done)

  unset -f remove_translators  # because it relies on nullglob

fi

if test -d /var/run; then
  (cd /var/run && {
    find . ! -type d ! -name utmp ! -name innd.pid ! -name random-seed \
      -exec rm -f -- {} \;
    cp /dev/null utmp
    if grep -q ^utmp: /etc/group
    then
	chmod 664 utmp
	chgrp utmp utmp
    fi; })
fi

echo done

# This file must exist for e2fsck to work. XXX
touch /var/run/mtab

#echo -n restoring pty permissions...
#chmod 666 /dev/tty[pqrs]*
#echo done

#echo -n updating /etc/motd...
#echo GNU\'s Not Unix Version `uname --release` > /tmp/newmotd
#egrep -v 'GNU|Version' /etc/motd >> /tmp/newmotd
#mv /tmp/newmotd /etc/motd
#echo done

chmod 664 /etc/motd

(
	trap ":" INT QUIT TSTP

	if [ -d /etc/rc.boot ]
	then
		for i in /etc/rc.boot/S*
		do
			[ ! -f $i ] && continue
			$i start
		done
	fi
	if [ -d /etc/rc2.d ]
	then
		for i in /etc/rc2.d/S*
		do
			[ ! -f $i ] && continue
			$i start
		done
	fi
)

date