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