Upload etc/init.d/hwclock.sh with huggingface_hub
Browse files- etc/init.d/hwclock.sh +120 -0
etc/init.d/hwclock.sh
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
# hwclock.sh Set and adjust the CMOS clock.
|
| 3 |
+
#
|
| 4 |
+
# Version: @(#)hwclock.sh 2.00 14-Dec-1998 [email protected]
|
| 5 |
+
#
|
| 6 |
+
# Patches:
|
| 7 |
+
# 2000-01-30 Henrique M. Holschuh <[email protected]>
|
| 8 |
+
# - Minor cosmetic changes in an attempt to help new
|
| 9 |
+
# users notice something IS changing their clocks
|
| 10 |
+
# during startup/shutdown.
|
| 11 |
+
# - Added comments to alert users of hwclock issues
|
| 12 |
+
# and discourage tampering without proper doc reading.
|
| 13 |
+
# 2012-02-16 Roger Leigh <[email protected]>
|
| 14 |
+
# - Use the UTC/LOCAL setting in /etc/adjtime rather than
|
| 15 |
+
# the UTC setting in /etc/default/rcS. Additionally
|
| 16 |
+
# source /etc/default/hwclock to permit configuration.
|
| 17 |
+
|
| 18 |
+
### BEGIN INIT INFO
|
| 19 |
+
# Provides: hwclock
|
| 20 |
+
# Required-Start: mountdevsubfs
|
| 21 |
+
# Required-Stop: mountdevsubfs
|
| 22 |
+
# Should-Stop: umountfs
|
| 23 |
+
# Default-Start: S
|
| 24 |
+
# X-Start-Before: checkroot
|
| 25 |
+
# Default-Stop: 0 6
|
| 26 |
+
# Short-Description: Sync hardware and system clock time.
|
| 27 |
+
### END INIT INFO
|
| 28 |
+
|
| 29 |
+
# These defaults are user-overridable in /etc/default/hwclock
|
| 30 |
+
BADYEAR=no
|
| 31 |
+
HWCLOCKACCESS=yes
|
| 32 |
+
HWCLOCKPARS=
|
| 33 |
+
HCTOSYS_DEVICE=rtc0
|
| 34 |
+
|
| 35 |
+
# We only want to use the system timezone or else we'll get
|
| 36 |
+
# potential inconsistency at startup.
|
| 37 |
+
unset TZ
|
| 38 |
+
|
| 39 |
+
hwclocksh()
|
| 40 |
+
{
|
| 41 |
+
[ ! -x /sbin/hwclock ] && return 0
|
| 42 |
+
[ ! -r /etc/default/rcS ] || . /etc/default/rcS
|
| 43 |
+
[ ! -r /etc/default/hwclock ] || . /etc/default/hwclock
|
| 44 |
+
|
| 45 |
+
. /lib/lsb/init-functions
|
| 46 |
+
verbose_log_action_msg() { [ "$VERBOSE" = no ] || log_action_msg "$@"; }
|
| 47 |
+
|
| 48 |
+
case "$BADYEAR" in
|
| 49 |
+
no|"") BADYEAR="" ;;
|
| 50 |
+
yes) BADYEAR="--badyear" ;;
|
| 51 |
+
*) log_action_msg "unknown BADYEAR setting: \"$BADYEAR\""; return 1 ;;
|
| 52 |
+
esac
|
| 53 |
+
|
| 54 |
+
case "$1" in
|
| 55 |
+
start)
|
| 56 |
+
# If the admin deleted the hwclock config, create a blank
|
| 57 |
+
# template with the defaults.
|
| 58 |
+
if [ -w /etc ] && [ ! -f /etc/adjtime ] && [ ! -e /etc/adjtime ]; then
|
| 59 |
+
printf "0.0 0 0.0\n0\nUTC\n" > /etc/adjtime
|
| 60 |
+
fi
|
| 61 |
+
|
| 62 |
+
if [ -d /run/udev ] || [ -d /dev/.udev ]; then
|
| 63 |
+
return 0
|
| 64 |
+
fi
|
| 65 |
+
|
| 66 |
+
if [ "$HWCLOCKACCESS" != no ]; then
|
| 67 |
+
log_action_msg "Setting the system clock"
|
| 68 |
+
|
| 69 |
+
# Just for reporting.
|
| 70 |
+
if sed '3!d' /etc/adjtime | grep -q '^UTC$'; then
|
| 71 |
+
UTC="--utc"
|
| 72 |
+
else
|
| 73 |
+
UTC=
|
| 74 |
+
fi
|
| 75 |
+
# Copies Hardware Clock time to System Clock using the correct
|
| 76 |
+
# timezone for hardware clocks in local time, and sets kernel
|
| 77 |
+
# timezone. DO NOT REMOVE.
|
| 78 |
+
if /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --hctosys $HWCLOCKPARS $BADYEAR; then
|
| 79 |
+
# Announce the local time.
|
| 80 |
+
verbose_log_action_msg "System Clock set to: `date $UTC`"
|
| 81 |
+
else
|
| 82 |
+
log_warning_msg "Unable to set System Clock to: `date $UTC`"
|
| 83 |
+
fi
|
| 84 |
+
else
|
| 85 |
+
verbose_log_action_msg "Not setting System Clock"
|
| 86 |
+
fi
|
| 87 |
+
;;
|
| 88 |
+
stop|restart|reload|force-reload)
|
| 89 |
+
#
|
| 90 |
+
# Updates the Hardware Clock with the System Clock time.
|
| 91 |
+
# This will *override* any changes made to the Hardware Clock.
|
| 92 |
+
#
|
| 93 |
+
# WARNING: If you disable this, any changes to the system
|
| 94 |
+
# clock will not be carried across reboots.
|
| 95 |
+
#
|
| 96 |
+
|
| 97 |
+
if [ "$HWCLOCKACCESS" != no ]; then
|
| 98 |
+
log_action_msg "Saving the system clock"
|
| 99 |
+
if /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --systohc $HWCLOCKPARS $BADYEAR; then
|
| 100 |
+
verbose_log_action_msg "Hardware Clock updated to `date`"
|
| 101 |
+
fi
|
| 102 |
+
else
|
| 103 |
+
verbose_log_action_msg "Not saving System Clock"
|
| 104 |
+
fi
|
| 105 |
+
;;
|
| 106 |
+
show)
|
| 107 |
+
if [ "$HWCLOCKACCESS" != no ]; then
|
| 108 |
+
/sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --show $HWCLOCKPARS $BADYEAR
|
| 109 |
+
fi
|
| 110 |
+
;;
|
| 111 |
+
*)
|
| 112 |
+
log_success_msg "Usage: hwclock.sh {start|stop|reload|force-reload|show}"
|
| 113 |
+
log_success_msg " start sets kernel (system) clock from hardware (RTC) clock"
|
| 114 |
+
log_success_msg " stop and reload set hardware (RTC) clock from kernel (system) clock"
|
| 115 |
+
return 1
|
| 116 |
+
;;
|
| 117 |
+
esac
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
hwclocksh "$@"
|