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