#!/bin/bash # # Copyright 2007 Karljohan Lundin Palmerius # All rights reserved. # # This script is as of yet not released under any "free" # license - no guarantees are given whatsoever and the code # may not be redistributed in any unmodified or modified # form. Please contact the author if you require alternative # terms. ON_ERROR_CHECK_LSOF=1 df=`df` if [ -e ~/.fstab ] then for row in `cat ~/.fstab | grep fuse | sed "s/ */|/g"` do point=`echo $row | cut -d '|' -f 2` name=`echo $point | sed "s/.*\///g"` mounted=`echo $df | grep $point > /dev/null && echo M || echo U` MENU_LIST="$MENU_LIST user|$point ${mounted}--$name" done fi for row in `cat /etc/fstab | grep fuse | sed "s/ */|/g"` do point=`echo $row | cut -d '|' -f 2` name=`echo $point | sed "s/.*\///g"` mounted=`echo $df | grep $point > /dev/null && echo M || echo U` MENU_LIST="$MENU_LIST system|$point ${mounted}--$name" done select=`kdialog --menu "Mount Point" $MENU_LIST` if [ -n "$select" ] then source=`echo $select | cut -d '|' -f 1` point=`echo $select | cut -d '|' -f 2` name=`echo $point | sed "s/.*\///g"` mounted=`echo $df | grep $point > /dev/null && echo un` if [ -z "$mounted" ] then case "$source" in ("system") kdialog --warningcontinuecancel "Point is not mounted. Continue to mount '$name'." --dontagain fusedialog:mount-warning && MESSAGE=`mount $point 2>&1` ;; ("user") row=`cat ~/.fstab 2> /dev/null | grep $point | sed "s/ */|/g"` remote=`echo $row | cut -d '|' -f 1` options=`echo $row | cut -d '|' -f 2` kdialog --warningcontinuecancel "Point is not mounted. Continue to mount '$name'." --dontagain fusedialog:mount-warning && MESSAGE=`mount.fuse $remote $point -o $options` ;; esac else kdialog --warningcontinuecancel "Point is mounted. Continue to un-mount '$name'." --dontagain fusedialog:unmount-warning && MESSAGE=`fusermount -u $point 2>&1` fi if [ -n "$MESSAGE" ] then if [ -n "$ON_ERROR_CHECK_LSOF" ] then pids=`lsof +t +d $point` prgs="" for pid in $pids do prg=`ps -p $pid -o comm=` if [ -z "$prgs" ] then prgs="$prg" else prgs="$prgs, $prg" fi done if [ -n "$prgs" ] then MESSAGE="$MESSAGE\nMount used by $prgs" fi fi kdialog --error "$MESSAGE" else kdialog --title "FuseDialog" \ --passivepopup \ "Successfully ${mounted}mounted $name." fi fi