slitaz-tools view tinyutils/mountbox @ rev 381

mountbox: add read-only status
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Aug 17 16:00:00 2009 +0200 (2009-08-17)
parents 9eafe366717d
children ef63980837c1
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|Option</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 <entry accept="directory">
103 <default>/media/cdrom</default>
104 <variable>MOUNT_POINT</variable>'
106 # Get the mount points list.
107 MAIN_DIALOG=${MAIN_DIALOG}${DEVICE}
109 # Actions buttons (mount, umount, eject, etc).
110 ACTIONS='
111 </entry>
112 <button>
113 <label>Browse</label>
114 <input file icon="folder-open"></input>
115 <action type="fileselect">MOUNT_POINT</action>
116 </button>
117 </hbox>
118 <hbox>
119 <button>
120 <label>Mount</label>
121 <input file icon="edit-redo"></input>
122 <action>mkdir -p $MOUNT_POINT</action>
123 <action>mount $DEVICE $MOUNT_POINT</action>
124 <action>refresh:MOUNTED</action>
125 <action>refresh:DEVICE</action>
126 </button>
127 <button>
128 <label>Umount</label>
129 <input file icon="undo"></input>
130 <action>umount $MOUNT_POINT; sleep 1</action>
131 <action>refresh:MOUNTED</action>
132 <action>refresh:DEVICE</action>
133 </button>
134 <button>
135 <label>Device list</label>
136 <input file icon="reload"></input>
137 <action>refresh:DEVICE</action>
138 </button>
139 <button>
140 <label>Eject</label>
141 <input file icon="media-cdrom"></input>
142 <action>eject</action>
143 </button>
144 <button>
145 <label>Loop</label>
146 <input file icon="go-jump"></input>
147 <action>/usr/lib/slitaz/libmountbox loopmgr</action>
148 <action>refresh:MOUNTED</action>
149 <action>refresh:DEVICE</action>
150 </button>
151 <button>
152 <label>Crypto</label>
153 <input file icon="passwd"></input>
154 <action>/usr/lib/slitaz/libmountbox cryptomgr</action>
155 <action>refresh:DEVICE</action>
156 </button>
157 <button help>
158 <input file icon="help"></input>
159 <action type="launch">HELP</action>
160 </button>
161 <button>
162 <label>Quit</label>
163 <input file icon="exit"></input>
164 <action type="exit">Exit</action>
165 </button>
167 </hbox>
169 </vbox>
170 </window>'
172 export MAIN_DIALOG=${MAIN_DIALOG}${ACTIONS}
173 gtkdialog --center --program=MAIN_DIALOG >/dev/null
175 exit 0