slitaz-tools view tinyutils/mountbox @ rev 80

Mountbox can browser mount point and eject cdrom
author Christophe Lincoln <pankso@slitaz.org>
date Thu Mar 06 22:44:32 2008 +0100 (2008-03-06)
parents 8ea52c365e03
children bcdf06f0074a
line source
1 #! /bin/sh
2 #
3 # Gtkdialog box for the mount command. Part of SliTaz tools.
4 #
5 VERSION=20080113
7 # Check if user is root.
8 check_root()
9 {
10 if test $(id -u) != 0 ; then
11 echo -e "
12 You must be root to run `basename $0`. Please type 'su' and
13 root password to become super-user.\n"
14 exit 0
15 fi
16 }
18 export FDISK_LIST='
19 <window title="Fdisk -l" icon-name="media-flash">
20 <vbox>
21 <text use-markup="true">
22 <label>"
23 <b>Harddisk devices list</b>"
24 </label>
25 </text>
26 <frame Partitions table>
27 <text wrap="false" width-chars="58">
28 <input>fdisk -l | grep ^/dev</input>
29 </text>
30 </frame>
31 <hbox>
32 <button>
33 <input file icon="exit"></input>
34 <action type="closewindow">FDISK_LIST</action>
35 </button>
36 </hbox>
37 </vbox>
38 </window>
39 '
41 export MOUNTED='
42 <window title="Mounted devices" icon-name="media-flash">
43 <vbox>
44 <text use-markup="true">
45 <label>"
46 <b>Mounted devices list</b>"
47 </label>
48 </text>
49 <frame Devices and mount points>
50 <text wrap="false" width-chars="58">
51 <input>mount | grep ^/dev/[c-s]d</input>
52 </text>
53 </frame>
54 <hbox>
55 <button>
56 <input file icon="exit"></input>
57 <action type="closewindow">MOUNTED</action>
58 </button>
59 </hbox>
60 </vbox>
61 </window>
62 '
64 # Mount and umount buttons with fiel for devive and mount point.
65 #
66 export MOUNT_DIALOG='
67 <window title="Mountbox" icon-name="media-flash">
68 <vbox>
70 <text use-markup="true">
71 <label>
72 "
73 <b>SliTaz - Mountbox</b>"
74 </label>
75 </text>
76 <text wrap="true" width-chars="44" use-markup="true">
77 <label>
78 "
79 Mount device on a mount point. Device can be cdrom,
80 flash key, USB disk or local HD partitions.
81 "
82 </label>
83 </text>
85 <frame Configuration>
86 <hbox>
87 <text use-markup="true">
88 <label>"<b>Device : </b>"</label>
89 </text>
90 <combobox>
91 <variable>DEVICE</variable>
92 <item>/dev/sda1</item>
93 <item>/dev/sdb2</item>
94 <item>/dev/cdrom</item>
95 <item>/dev/hda1</item>
96 </combobox>
97 <button>
98 <label>List</label>
99 <input file icon="drive-harddisk"></input>
100 <action type="launch">FDISK_LIST</action>
101 </button>
102 </hbox>
104 <hbox>
105 <text use-markup="true">
106 <label>"<b>Mount point : </b>"</label>
107 </text>
108 <combobox>
109 <variable>MOUNT_POINT</variable>
110 <item>/media/flash</item>
111 <item>/media/usbdisk</item>
112 <item>/media/cdrom</item>
113 <item>/mnt/harddisk</item>
114 </combobox>
115 <button>
116 <label>List</label>
117 <input file icon="drive-harddisk"></input>
118 <action type="launch">MOUNTED</action>
119 </button>
120 </hbox>
121 </frame>
123 <hbox>
124 <button>
125 <label>Mount</label>
126 <input file icon="forward"></input>
127 <action>echo "Mounting $DEVICE..."</action>
128 <action>mkdir -p $MOUNT_POINT; mount $DEVICE $MOUNT_POINT; sleep 1</action>
129 <action>mount | grep $DEVICE; echo "Done."</action>
130 </button>
131 <button>
132 <label>Umount</label>
133 <input file icon="undo"></input>
134 <action>echo "Unmounting $MOUNT_POINT..."</action>
135 <action>umount $MOUNT_POINT; sleep 1</action>
136 <action>mount | grep $DEVICE; echo "Done."</action>
137 </button>
138 <button>
139 <label>Browse</label>
140 <input file icon="folder"></input>
141 <action>emelfm2 --one=$MOUNT_POINT</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 <input file icon="exit"></input>
150 <action type="exit">Exit</action>
151 </button>
152 </hbox>
153 </vbox>
154 </window>
155 '
157 # Only root can mount.
158 check_root
159 gtkdialog --program=MOUNT_DIALOG
161 exit 0