#!/bin/bash # # livecd-isomd5sum Check ISO-implanted MD5 sum # # chkconfig: 345 99 01 # description: checkisomd5 wrapper for live images # Do not load RH compatibility interface. WITHOUT_RC_COMPAT=1 # Source function library. . /etc/init.d/functions LOCKFILE=/var/lock/subsys/livecd-isomd5sum RETVAL=3 # live environment boot device is expected to be mounted at /image get_dev() { awk '/\W\/image\W/ { print $1; exit; }' /proc/mounts || exit 1 } # /etc/rc.d/rc: "action " please start() { local dev="`get_dev`" [ -n "$dev" ] || return 1 echo -n "Verifying ISO MD5 sum for $dev: none" while read i; do case "$i" in [0-9]*) echo -ne "\b\b\b\b"; printf '%3s%%' $i;; *PASS.) echo_success; RETVAL=0;; *FAIL.) echo_failure; RETVAL=1;; *NA.) echo_passed; RETVAL=2;; esac done < <(checkisomd5 --gauge "$dev" 2>&1) # hence bash echo return $RETVAL } # See how we were called. case "$1" in start|restart|reload|condrestart|condreload) start ;; stop|condstop) RETVAL=0 ;; status) checkisomd5 --md5sumonly "`get_dev`" RETVAL=$? ;; *) msg_usage "${0##*/} {start|status}" RETVAL=1 esac exit $RETVAL