#!/bin/bash # # readonly Mount IDE harddrive filesystems as read-only # # Authors: Jake Sprouse # # chkconfig: 345 25 75 # description: Remounts currently mounted /dev/hd* as read-only # Function to do the remount remount() { RET=0 for name in $1; do ! mount -n -o remount,$2 $name && let RET=$RET+1 done return $RET } # Source function library. . /etc/rc.d/init.d/functions FSLIST=`mount | grep "/dev/hd" | awk '{ print $1 }'` # See how we were called. case "$1" in start) if [ -n "$FSLIST" ]; then if remount "$FSLIST" ro; then action "Remounting HDD filesystems as read-only" /bin/true else action "Remounting HDD filesystems as read-only" /bin/false fi fi touch /var/lock/subsys/readonly ;; stop) if [ -n "$FSLIST" ]; then if remount "$FSLIST" rw; then action "Remounting HDD filesystems as read-write" /bin/true else action "Remounting HDD filesystems as read-write" /bin/false fi fi rm -f /var/lock/subsys/readonly ;; *) echo "Usage: readonly {start|stop}" exit 1 esac exit 0