#! /bin/sh ### BEGIN INIT INFO # Provides: umountfs # Required-Start: # Required-Stop: umountroot # Default-Start: # Default-Stop: 0 6 # Short-Description: Turn off swap and unmount all local file systems. # Description: ### END INIT INFO PATH=/sbin:/usr/sbin:/bin:/usr/bin . /lib/init/vars.sh . /lib/lsb/init-functions umask 022 # Print in order of decreasing length # # Algorithm: Find and print longest argument, then call self # to print remaining arguments in order of decreasing length # # This function runs at one tenth the speed of the sort program # but we use the function because we don't want to rely on any # programs in /usr/. # # N.B.: Arguments must not be null and must not contain whitespace # pioodl() { [ "$1" ] || return 0 ARGNUM=1 ARGNUM_LONGEST=0 ARGLENGTH_LONGEST=0 for ARG in "$@" do ARGLENGTH="${#ARG}" if [ "$ARGLENGTH" -gt "$ARGLENGTH_LONGEST" ] then ARGLENGTH_LONGEST="$ARGLENGTH" ARGNUM_LONGEST="$ARGNUM" fi ARGNUM=$(($ARGNUM + 1)) done # The method of passing prevargs assumes that args can be # delimited with spaces ARGNUM=1 PREVARGS="" while [ "$ARGNUM" -lt "$ARGNUM_LONGEST" ] do PREVARGS="$PREVARGS $1" shift ARGNUM=$(($ARGNUM + 1)) done echo "$1" shift pioodl $PREVARGS "$@" } do_stop () { exec 9<&0 /dev/null log_action_end_msg $? else log_daemon_msg "Will now deactivate swap" swapoff -a -v log_end_msg $? fi # # Unmount local filesystems # if [ "$REG_MTPTS" ] then REG_MTPTS="$(pioodl $REG_MTPTS)" if [ "$VERBOSE" = no ] then log_action_begin_msg "Unmounting local filesystems" umount -f -r -d $REG_MTPTS log_action_end_msg $? else log_daemon_msg "Will now unmount local filesystems" umount -f -v -r -d $REG_MTPTS log_end_msg $? fi fi } case "$1" in start) # No-op ;; restart|reload|force-reload) echo "Error: argument '$1' not supported" >&2 exit 3 ;; stop) do_stop ;; *) echo "Usage: $0 start|stop" >&2 exit 3 ;; esac :