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