startup-mediacheck-0.2.2/000075500000000000000000000000001233433405300152665ustar00rootroot00000000000000startup-mediacheck-0.2.2/inittab.mediacheck000064400000000000000000000022631233433405300207220ustar00rootroot00000000000000# The default runlevel. id:3:initdefault: # Boot-time system configuration/initialization script. # This is run first except when booting in emergency (-b) mode. si::sysinit:/etc/rc.d/rc.sysinit.mediacheck # /etc/rc.d/rc executes the S and K scripts upon change of runlevel. # # Runlevel 0 is halt. # Runlevel 1 is single-user. # Runlevels 2-5 are multi-user. # Runlevel 6 is reboot. l0:0:wait:/etc/rc.d/rc 0 l1:1:wait:/etc/rc.d/rc 1 l2:2:wait:/etc/rc.d/rc 2 l3:3:wait:/etc/rc.d/rc 3 l4:4:wait:/etc/rc.d/rc 4 l5:5:wait:/etc/rc.d/rc 5 l6:6:wait:/etc/rc.d/rc 6 # Normally not reached, but fallthrough in case of emergency. z6:6:respawn:/sbin/sulogin # What to do when CTRL-ALT-DEL is pressed. ca:012345:ctrlaltdel:/sbin/shutdown -t3 -r now # Action on special keypress (ALT-UpArrow). kb::kbrequest:/bin/echo "Keyboard Request -- edit /etc/inittab to let this work." # What to do when the power fails/returns. pf::powerwait:/etc/rc.d/rc.powerfail start pn::powerfailnow:/etc/rc.d/rc.powerfail now po::powerokwait:/etc/rc.d/rc.powerfail stop # Format: # ::: 1:2345:respawn:/bin/openvt -elfw -c 1 -- /bin/bash -l 2:2345:respawn:/bin/openvt -elfw -c 2 -- /bin/bash -l startup-mediacheck-0.2.2/rc.sysinit.mediacheck000075500000000000000000000033001233433405300213710ustar00rootroot00000000000000#!/bin/bash # Based on rc.sysinit.rescue from startup-rescue-0.15-alt1 trap '' SIGPIPE WITHOUT_RC_COMPAT=1 # Source function library . /etc/init.d/functions PrintMargin() { [ "$BOOTUP" != serial ] || return 0 local n n="`printf %s "$*" |wc -c`" 2>/dev/null && tput hpa $(( ($COLUMNS - $n)/2 )) } WELCOME="Welcome to " BANNER="ALT Linux (mediacheck)" echo PrintMargin "$WELCOME$BANNER" printf %s "$WELCOME" SETCOLOR_INFO printf %s "$BANNER" SETCOLOR_NORMAL echo tmout_OK=10 tmout_NO=3600 # live environment boot device is expected to be mounted at /image get_dev() { sed -rn 's,^(/[^ ]+)\W+/image\W+.*,\1,p' /proc/mounts || exit 1 } say() { echo -e "\n\n**\n** $*\n**"; } say_OK() { say "This media looks good, hope you like its contents too!"; } say_NO() { say "Ouch, better re-download and re-write this, looks broken!"; } # manual action() check_media() { local dev="`get_dev`" [ -n "$dev" -o ! -b "$dev" ] || return 44 echo if [ -s /image/.disk/info ]; then echo -n "Found " cat /image/.disk/info fi echo -n "Will reboot upon completion: " echo "in $tmout_OK sec if OK, $tmout_NO otherwise" echo -n "Verifying ISO MD5 sum for $dev: none" while read i; do case "$i" in [0-9]*) printf '\b\b\b\b%3s%%' $i;; *PASS.) echo_success; say_OK; RETVAL=0;; *FAIL.) echo_failure; say_NO; RETVAL=1;; *NA.) echo_passed; RETVAL=2;; esac done < <(checkisomd5 --gauge "$dev" 2>&1) # hence bash echo return $RETVAL } mount -n -t proc proc /proc # fire and reboot if grep -iwqs 'mediacheck=1' /proc/cmdline; then check_media if [ "$?" -eq "0" ]; then tmout="$tmout_OK" else tmout="$tmout_NO" fi printf "reboot in $tmout seconds..." read -s -n 1 -t $tmout echo b > /proc/sysrq-trigger fi