From dfac71239116c4804081d925e9cf3021680b1e2c Mon Sep 17 00:00:00 2001 From: spiralman Date: Sun, 01 Sep 2002 14:42:39 +0000 Subject: initial import of gonz's opie-sh scripts --- (limited to 'noncore/tools/opie-sh/scripts/filesystem_mounter.sh') diff --git a/noncore/tools/opie-sh/scripts/filesystem_mounter.sh b/noncore/tools/opie-sh/scripts/filesystem_mounter.sh new file mode 100755 index 0000000..faaf37c --- a/dev/null +++ b/noncore/tools/opie-sh/scripts/filesystem_mounter.sh @@ -0,0 +1,126 @@ +#!/bin/sh + +# filesystem_mounter.sh - a demonstration of opie-sh +# +# Copyright (C) 2002 gonz@directbox.com +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 20020524-2 - using df from diskfree now +# 20020524-1 - just code optix +# 20020519-1 - added information screen with manpage excerpt, added +# better returncode-checking +# 20020517-2 - fixed output bug +# 20020517-1 - nicer fullscreen, added about, tried icon +# + +OPIE_SH=/opt/QtPalmtop/bin/opie-sh + +###################################################################### +# subroutines + +about() { + ( echo "" + echo "

About

" + echo "This little App should make it possible for you to " + echo "easily mount and unmount filesystems from /etc/fstab" + echo "

" + ) | $OPIE_SH -t fsmounter -f & + SCREENCLEAN=$! + sleep 1 +} + +beforemount() { + ( echo "" + echo "

mount or unmount $MOUNTPOINT ?

" + echo "excerpt from MOUNT(8) manpage:

" + echo "All files accessible in a Unix system are arranged in one + big tree, the file hierarchy, rooted at /. These files + can be spread out over several devices. The mount command + serves to attach the file system found on some device to + the big file tree. Conversely, the umount(8) command will + detach it again." + echo "

" + ) | $OPIE_SH -t fsmounter -f & + SCREENCLEAN2=$! + sleep 1 +} + + +cleanup() { + kill $SCREENCLEAN $SCREENCLEAN2 + rm -f /tmp/qcop-msg-filesystem_mounter.sh +} + +get_action() { +# ask what to do (start/stop/status) +# +$OPIE_SH -m -t "Select Action" \ + -M "action for $MOUNTPOINT ?" \ + -g -0 mount -1 umount +RETURNCODE=$? + +case $RETURNCODE in + -1|255) echo unexpected input detected, exiting. | $OPIE_SH -f + cleanup ;; + 0) ACTION=mount ;; + 1) ACTION=umount ;; +esac +kill $SCREENCLEAN2 +} + +select_mountpoint() { +# present service list and choose +# +MOUNTPOINT=` cat /etc/fstab | cut -f1 \ + | cut -d " " -f1 \ + | egrep -v "(tmpfs|proc|devpts|^#)" \ + | $OPIE_SH -i -l \ + -g -t "SELECT MOUNTPOINT" \ + -L "select fs: " ` +} + +###################################################################### +# main + +about +select_mountpoint +beforemount +get_action + +if [ "$MOUNTPOINT" = "" ] +then echo "ugly error...." | $OPIE_SH -f ; cleanup +fi + +( echo "" + echo "

Output of $ACTION $MOUNTPOINT :

" + echo "
"
+  $ACTION $MOUNTPOINT  2>&1
+  echo "

" + echo "

diskfree

how much space is left ?
" + echo "

" + + df -Ph \ + | grep -v "Mounted on" \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed "s/ / /g" \ + | cut -d " " -f4- \ + | sed 's/ /<\/td>
/g' \ + | sed 's/$/<\/td><\/tr>/' \ + | sed 's/^/
/' ; echo "
" \ +) | $OPIE_SH -f + +cleanup -- cgit v0.9.0.2