slitaz-tools view tinyutils/mountbox @ rev 368

mountbox: add devmapper support + misc fixes
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Aug 02 15:15:19 2009 +0200 (2009-08-02)
parents f03d03012bdd
children 0f505d6877d4
line source
1 #!/bin/sh
2 #
3 # Gtkdialog box for the mount/umount commands. Part of SliTaz tools.
4 # libmountbox: /usr/lib/slitaz/libmountbox
5 #
6 # (C) 2009 - SliTaz GNU/Linux project.
7 #
8 VERSION=20090802
9 # Mountbox is only for root.
10 if test $(id -u) != 0 ; then
11 exec subox mountbox
12 exit 0
13 fi
15 # Commom mount point in /mnt
16 mkdir -p /mnt/harddisk
18 # Just basic help.
19 export HELP='
20 <window title="Mountbox - Help" icon-name="help">
21 <vbox>
22 <text use-markup="true" width-chars="56">
23 <label>"
24 <b>SliTaz Mountbox - Help</b>"
25 </label>
26 </text>
28 <frame English>
29 <text wrap="true" use-markup="true">
30 <label>
31 "Mountbox lets you mount devices on mount points. A device
32 can be a cdrom, flash key, USB disk or local HD partition.
33 Mount points are generated from /media and /mnt.
34 "
35 </label>
36 </text>
37 </frame>
38 <frame Français>
39 <text wrap="true" use-markup="true">
40 <label>
41 "Mountbox permet de monter des périphériques (devices)
42 sur des points de montage. Un device peut être un cdrom,
43 une clé USB ou un disque dur local. La liste des points
44 de montage est généré depuis /media te /mnt.
45 "
46 </label>
47 </text>
48 </frame>
50 <hbox>
51 <button ok>
52 <action type="closewindow">HELP</action>
53 </button>
54 </hbox>
55 </vbox>
56 </window>'
58 # Mount and umount buttons with fiel for devive and mount point.
59 MAIN_DIALOG='
60 <window title="Mountbox" icon-name="media-flash">
61 <vbox>
63 <tree>
64 <width>520</width><height>120</height>
65 <variable>MOUNTED</variable>
66 <label>Mounted fs|Size|Used|Available|Use%|Mounted on</label>'
68 # /dev/root
69 RES=`df -h / | grep rootfs`
70 dev="/dev/root"
71 SIZE=`echo $RES | cut -d " " -f 2`
72 USED=`echo $RES | cut -d " " -f 3`
73 AVAILABLE=`echo $RES | cut -d " " -f 4`
74 PCT=`echo $RES | cut -d " " -f 5`
75 MOUNTED_ON=`echo $RES | cut -d " " -f 6`
76 if [ $SIZE != 0 ]; then
77 ROOT_ITEM="
78 <item icon=\"drive-harddisk\">$dev | $SIZE | $USED | $AVAILABLE | $PCT | $MOUNTED_ON</item>"
79 fi
80 MAIN_DIALOG=${MAIN_DIALOG}${ROOT_ITEM}
82 # Now we have rootfs and icons, list all mounted fs.
83 DEVICE='<input>/usr/lib/slitaz/libmountbox list-mounted</input>
84 <action>/usr/lib/slitaz/libmountbox mounted-fs-infos</action>
85 <action>refresh:MOUNTED</action>
86 <action>refresh:DEVICE</action>
87 </tree>
89 <tree>
90 <width>500</width><height>120</height>
91 <variable>DEVICE</variable>
92 <label>Umounted dev|Size|System|Type|Label|Boot|Start|End|Blocks|Id|UUID</label>
93 <input>/usr/lib/slitaz/libmountbox list-umounted</input>
94 <action>/usr/lib/slitaz/libmountbox umounted-fs-infos</action>
95 <action>refresh:MOUNTED</action>
96 <action>refresh:DEVICE</action>
97 </tree>
98 <hbox>
99 <text use-markup="true">
100 <label>"<b>Mount selected device on:</b>"</label>
101 </text>
102 <combobox>
103 <variable>MOUNT_POINT</variable>'
105 # Get the mount points list.
106 MAIN_DIALOG=${MAIN_DIALOG}${DEVICE}
107 for dir in $(ls -d /media/* /mnt/*)
108 do
109 MOUNT_POINTS_ITEMS="<item>$dir</item>"
110 MAIN_DIALOG=${MAIN_DIALOG}${MOUNT_POINTS_ITEMS}
111 done
113 # Actions buttons (mount, umount, eject, etc).
114 ACTIONS='
115 </combobox>
116 <button>
117 <label>Browse</label>
118 <input file icon="folder-open"></input>
119 <action>file-manager $MOUNT_POINT &</action>
120 </button>
121 </hbox>
122 <hbox>
123 <button>
124 <label>Mount</label>
125 <input file icon="edit-redo"></input>
126 <action>mkdir -p $MOUNT_POINT</action>
127 <action>mount $DEVICE $MOUNT_POINT</action>
128 <action>refresh:MOUNTED</action>
129 <action>refresh:DEVICE</action>
130 </button>
131 <button>
132 <label>Umount</label>
133 <input file icon="undo"></input>
134 <action>umount $MOUNT_POINT; sleep 1</action>
135 <action>refresh:MOUNTED</action>
136 <action>refresh:DEVICE</action>
137 </button>
138 <button>
139 <label>Device list</label>
140 <input file icon="reload"></input>
141 <action>refresh:DEVICE</action>
142 </button>
143 <button>
144 <label>Eject</label>
145 <input file icon="media-cdrom"></input>
146 <action>eject</action>
147 </button>
148 <button>
149 <label>Crypt</label>
150 <input file icon="passwd"></input>
151 <action>cryptobox &</action>
152 </button>
153 <button help>
154 <input file icon="help"></input>
155 <action type="launch">HELP</action>
156 </button>
157 <button>
158 <label>Quit</label>
159 <input file icon="exit"></input>
160 <action type="exit">Exit</action>
161 </button>
163 </hbox>
165 </vbox>
166 </window>'
168 export MAIN_DIALOG=${MAIN_DIALOG}${ACTIONS}
169 gtkdialog --center --program=MAIN_DIALOG >/dev/null
171 exit 0