#!/bin/bash ### BEGIN INIT INFO # # Provides: vb shared folders # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: mounts vbox shared folders # Description: mounts and unmounts the VBox shares # ### END INIT INFO PNAME=$(basename $0) . /lib/lsb/init-functions USAGE="mount.shares start|restart|stop|status|help" SHARES[0]=common SHARES[1]=local statusflag=0 getfs() { log_daemon_msg $PNAME mounting $1 mount -t vboxsf -o rw,uid=1000 $1 /import/$1 log_end_msg $? } umountfs() { log_daemon_msg $PNAME unmounting $1 umount $1 log_end_msg $? } statusfs() { log_daemon_msg $PNAME status of $1 lines=$(df | grep $1 | wc -l) case $lines in 0) : # bad leg log_end_msg 1 ;; *) : # goodleg log_end_msg 0 esac } case $1 in start) : for sfs in ${SHARES[*]};do getfs $sfs done ;; stop) for sfs in ${SHARES[*]};do umountfs $sfs done ;; restart) : for sfs in ${SHARES[*]};do umountfs $sfs sleep 2 getfs $sfs done ;; status) : for fs in ${SHARES[*]};do statusfs $fs if [ $? != 0 ];then statusflag=1 fi done if [ $statusflag != 0 ];then exit 1 fi ;; help) echo $USAGE; exit 2 ;; esac