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