slitaz-tools view tinyutils/mountbox @ rev 220
bootfloppybox: add non free plop to boot from USB
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Jun 25 10:05:29 2008 +0000 (2008-06-25) |
parents | dbaa9c4f319c |
children | 5de884166be4 |
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=20080510
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 let you mount devices on mount points. Device
33 can be cdrom, flash key, USB disk or local HD partitions.
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</label>
94 <item icon="drive-harddisk">/dev/cdrom | - | - | - | CD/DVD | - | iso9660</item>
95 <input>/usr/lib/slitaz/libmountbox list-umounted</input>
96 <action>/usr/lib/slitaz/libmountbox umounted-fs-infos</action>
97 <action>refresh:MOUNTED</action>
98 <action>refresh:DEVICE</action>
99 </tree>
100 <hbox>
101 <text use-markup="true">
102 <label>"<b>Mount selected device on:</b>"</label>
103 </text>
104 <combobox>
105 <variable>MOUNT_POINT</variable>'
107 # Get the mount points list.
108 MAIN_DIALOG=${MAIN_DIALOG}${DEVICE}
109 for dir in $(ls -d /media/* /mnt/*)
110 do
111 MOUNT_POINTS_ITEMS="<item>$dir</item>"
112 MAIN_DIALOG=${MAIN_DIALOG}${MOUNT_POINTS_ITEMS}
113 done
115 # Actions buttons (moun, umount, eject, etc).
116 ACTIONS='
117 </combobox>
118 <button>
119 <label>Browse</label>
120 <input file icon="folder-open"></input>
121 <action>pcmanfm $MOUNT_POINT &</action>
122 </button>
123 </hbox>
125 <hbox>
126 <button>
127 <label>Mount</label>
128 <input file icon="edit-redo"></input>
129 <action>mkdir -p $MOUNT_POINT</action>
130 <action>mount $DEVICE $MOUNT_POINT</action>
131 <action>refresh:MOUNTED</action>
132 <action>refresh:DEVICE</action>
133 </button>
134 <button>
135 <label>Umount</label>
136 <input file icon="undo"></input>
137 <action>umount $MOUNT_POINT; sleep 1</action>
138 <action>refresh:MOUNTED</action>
139 <action>refresh:DEVICE</action>
140 </button>
141 <button>
142 <label>Device list</label>
143 <input file icon="reload"></input>
144 <action>refresh:DEVICE</action>
145 </button>
146 <button>
147 <label>Eject</label>
148 <input file icon="media-cdrom"></input>
149 <action>eject</action>
150 </button>
151 <button help>
152 <input file icon="help"></input>
153 <action type="launch">HELP</action>
154 </button>
155 <button>
156 <label>Quit</label>
157 <input file icon="exit"></input>
158 <action type="exit">Exit</action>
159 </button>
161 </hbox>
163 </vbox>
164 </window>'
166 export MAIN_DIALOG=${MAIN_DIALOG}${ACTIONS}
167 gtkdialog --center --program=MAIN_DIALOG >/dev/null
169 exit 0