slitaz-tools view lib/libmountbox @ rev 252

Fix spelling, typos, wording, etc.
author Mike D. Smith <MikeDSmith25@gmail.com>
date Sat Jul 19 06:35:45 2008 +0000 (2008-07-19)
parents dbaa9c4f319c
children 426e821a7516
line source
1 #!/bin/sh
2 #
3 # Libmountbox provides devices list in suitable format for GTK tree
4 # and various dialog boxes to mount, umount, etc.
5 #
6 # (C) 2008 - SliTaz GNU/Linux project.
7 #
9 # Short usage.
10 usage()
11 {
12 echo -e "\nUsage: $0 command\n
13 Output commands:
14 list-mounted List all mounted devices in suitable GTK tree format.
15 list-umounted List all umounted in suitable GTK tree format.
17 GTKdialog boxes
18 mounted-fs-infos Display a mounted devices infos with actions.
19 umounted-fs-infos Display a umounted devices infos with actions.\n"
20 }
22 # Format df -h output for GTK tree.
23 mounted_fs_data()
24 {
25 SIZE=`echo $RES | cut -d " " -f 2`
26 USED=`echo $RES | cut -d " " -f 3`
27 AVAILABLE=`echo $RES | cut -d " " -f 4`
28 PCT=`echo $RES | cut -d " " -f 5`
29 MOUNTED_ON=`echo $RES | cut -d " " -f 6`
30 }
32 case $1 in
33 list-mounted)
34 # List all fs found by: df -h
35 #
36 for dev in `df -h | grep ^/dev/[c-s]d | cut -d " " -f 1`
37 do
38 RES=`df -h $dev | grep ^$dev`
39 mounted_fs_data
40 echo "$dev | $SIZE | $USED | $AVAILABLE | $PCT | $MOUNTED_ON"
41 done ;;
42 list-umounted)
43 # List all umounted fs found by: fdisk -l
44 #
45 for dev in `fdisk -l | grep ^/dev | cut -d " " -f 1`
46 do
47 RES=`fdisk -l | grep $dev | sed s/*//g`
48 START=`echo $RES | cut -d " " -f 2`
49 END=`echo $RES | cut -d " " -f 3`
50 BLOCKS=`echo $RES | cut -d " " -f 4`
51 ID=`echo $RES | cut -d " " -f 5`
52 SYSTEM=`echo $RES | cut -d " " -f 6`
53 # Bootable...
54 if fdisk -l | grep $dev | grep -q "*"; then
55 BOOT="*"
56 else
57 BOOT="-"
58 fi
59 # Skip swap, extended, and mounted partitions.
60 if echo $RES | grep -q "swap" || echo $RES | grep -q "Extended" ; then
61 continue
62 elif mount | grep -q "^$dev"; then
63 continue
64 else
65 echo "$dev | $BOOT | $START | $END | $BLOCKS | $ID | $SYSTEM"
66 fi
67 done ;;
68 mounted-fs-infos)
69 # Mounted fs info and actions, rootfs or other fs.
70 #
71 if [ "$MOUNTED" == "/dev/root" ]; then
72 export MOUNTED_DEVICE="
73 <window title=\"Device: rootfs\" icon-name=\"media-flash\">
74 <vbox>
75 <text use-markup=\"true\" width-chars=\"56\">
76 <label>\"
77 <b>/dev/root</b>
78 \"
79 </label>
80 </text>
81 <text use-markup=\"true\" width-chars=\"56\">
82 <input>df -h / | grep ^rootfs</input>
83 </text>
84 <hbox>
85 <button>
86 <label>Browse</label>
87 <input file icon=\"folder-open\"></input>
88 <action>pcmanfm / &</action>
89 <action type=\"closewindow\">MOUNTED_DEVICE</action>
90 </button>
91 <button>
92 <input file icon=\"gtk-close\"></input>
93 <action type=\"closewindow\">MOUNTED_DEVICE</action>
94 </button>
95 </hbox>
96 </vbox>
97 </window>"
98 gtkdialog --center --program=MOUNTED_DEVICE
99 else
100 UUID=`blkid | grep ^$MOUNTED | sed 's/.*UUID=\"\([^ ]*\)\".*/\1/'`
101 TYPE=`blkid | grep ^$MOUNTED | sed 's/.*TYPE=\"\([^ ]*\)\".*/\1/'`
102 RES=`df -h $MOUNTED | grep ^$MOUNTED`
103 mounted_fs_data
104 export MOUNTED_DEVICE="
105 <window title=\"Device: $MOUNTED\" icon-name=\"media-flash\">
106 <vbox>
107 <text use-markup=\"true\" width-chars=\"56\">
108 <label>\"
109 Device <b>$MOUNTED</b> is mounted on <b>$MOUNTED_ON</b>
111 UUID: $UUID
112 Type: $TYPE
113 \"
114 </label>
115 </text>
116 <hbox>
117 <button>
118 <label>Browse</label>
119 <input file icon=\"folder-open\"></input>
120 <action>pcmanfm $MOUNTED_ON &</action>
121 <action type=\"closewindow\">MOUNTED_DEVICE</action>
122 </button>
123 <button>
124 <label>Umount</label>
125 <input file icon=\"undo\"></input>
126 <action>umount $MOUNTED_ON</action>
127 <action type=\"closewindow\">MOUNTED_DEVICE</action>
128 </button>
129 <button>
130 <input file icon=\"gtk-close\"></input>
131 <action type=\"closewindow\">MOUNTED_DEVICE</action>
132 </button>
133 </hbox>
134 </vbox>
135 </window>"
136 gtkdialog --center --program=MOUNTED_DEVICE
137 fi ;;
138 umounted-fs-infos)
139 # Mounted fs info and actions, rootfs or other fs.
140 #
141 UUID=`blkid | grep ^$DEVICE | sed 's/.*UUID=\"\([^ ]*\)\".*/\1/'`
142 TYPE=`blkid | grep ^$DEVICE | sed 's/.*TYPE=\"\([^ ]*\)\".*/\1/'`
143 export UMOUNTED_DEVICE="
144 <window title=\"Device: $DEVICE\" icon-name=\"media-flash\">
145 <vbox>
146 <text use-markup=\"true\" width-chars=\"56\">
147 <label>\"
148 Mount <b>$DEVICE</b> on <b>$MOUNT_POINT</b>
150 UUID: $UUID
151 Type: $TYPE
152 \"
153 </label>
154 </text>
156 <hbox>
157 <button>
158 <label>Mount</label>
159 <input file icon=\"edit-redo\"></input>
160 <action>mkdir -p $MOUNT_POINT</action>
161 <action>mount $DEVICE $MOUNT_POINT</action>
162 <action type=\"closewindow\">MOUNTED_DEVICE</action>
163 </button>
165 <button>
166 <label>e2fsck check</label>
167 <input file icon=\"drive-harddisk\"></input>
168 <action>xterm -T \"e2fsck -p $DEVICE\" \
169 --geomery 80x12 \
170 -e \"echo; e2fsck -p $DEVICE; \
171 echo -e '----\nENTER to close Termianl'; \
172 read i\" &</action>
173 <action type=\"closewindow\">MOUNTED_DEVICE</action>
174 </button>
176 <button>
177 <input file icon=\"gtk-close\"></input>
178 <action type=\"closewindow\">UMOUNTED_DEVICE</action>
179 </button>
180 </hbox>
181 </vbox>
182 </window>"
183 gtkdialog --center --program=UMOUNTED_DEVICE ;;
184 *)
185 usage ;;
186 esac
188 exit 0