1#!/bin/sh
2### BEGIN INIT INFO
3# Provides:          bootmisc
4# Required-Start:    $local_fs mountvirtfs
5# Required-Stop:     $local_fs
6# Default-Start:     S
7# Default-Stop:      0 6
8# Short-Description: Misc and other.
9### END INIT INFO
10
11TIMESTAMP_FILE=/etc/timestamp
12
13. /etc/default/rcS
14[ -f /etc/default/timestamp ] && . /etc/default/timestamp
15#
16# Put a nologin file in /etc to prevent people from logging in before
17# system startup is complete.
18#
19if test "$DELAYLOGIN" = yes
20then
21  echo "System bootup in progress - please wait" > /etc/nologin
22  cp /etc/nologin /etc/nologin.boot
23fi
24
25#
26# Set pseudo-terminal access permissions.
27#
28if test -c /dev/ttyp0
29then
30	chmod 666 /dev/tty[p-za-e][0-9a-f]
31	chown root:tty /dev/tty[p-za-e][0-9a-f]
32fi
33
34#
35# Apply /proc settings if defined
36#
37SYSCTL_CONF="/etc/sysctl.conf"
38if [ -f "${SYSCTL_CONF}" ]
39then
40	if [ -x "/sbin/sysctl" ]
41	then
42		# busybox sysctl does not support -q
43		VERBOSE_REDIR="1>/dev/null"
44		if [ "${VERBOSE}" != "no" ]; then
45			VERBOSE_REDIR="1>&1"
46		fi
47		eval /sbin/sysctl -p "${SYSCTL_CONF}" $VERBOSE_REDIR
48	else
49		echo "To have ${SYSCTL_CONF} applied during boot, install package <procps>."
50	fi
51fi
52
53#
54# Update /etc/motd.
55#
56if test "$EDITMOTD" != no
57then
58	uname -a > /etc/motd.tmp
59	sed 1d /etc/motd >> /etc/motd.tmp
60	mv /etc/motd.tmp /etc/motd
61fi
62
63#
64# This is as good a place as any for a sanity check
65#
66# Set the system clock from hardware clock
67# If the timestamp is more recent than the current time,
68# use the timestamp instead.
69test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh start
70if test -e "$TIMESTAMP_FILE"
71then
72	SYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M%2S`
73	read TIMESTAMP < "$TIMESTAMP_FILE"
74	if [ ${TIMESTAMP} -gt $SYSTEMDATE ]; then
75		# format the timestamp as date expects it (2m2d2H2M4Y.2S)
76		TS_YR=${TIMESTAMP%??????????}
77		TS_SEC=${TIMESTAMP#????????????}
78		TS_FIRST12=${TIMESTAMP%??}
79		TS_MIDDLE8=${TS_FIRST12#????}
80		date -u ${TS_MIDDLE8}${TS_YR}.${TS_SEC}
81		test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh stop
82	fi
83fi
84: exit 0
85