15
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
COMMENT
17
17
18
- version=" mnttools v0.4.0 "
18
+ version=" mnttools v0.4.1 "
19
19
blue=' \e[0;34m' ; green=' \e[0;32m' ; red=' \e[0;31m' ; yellow=' \e[0;33m' ; bold=' \e[1m' ; none=' \e[0m'
20
20
function menu {
21
21
n=0
@@ -84,35 +84,23 @@ function udevunmount() {
84
84
function devicemenu {
85
85
mntopts=" -o $general_mntopts "
86
86
if [[ $1 ]]; then
87
- i=(` sudo blkid -o value " $1 " ` )
88
- [[ $i ]] || return
89
- DEVNAME=$1
90
- [[ ${i[2]} = ntfs ]] && fs=" -t ntfs-3g" || fs=" -t ${i[2]} "
91
- [[ $fs =~ vfat| ntfs ]] && mntopts=" $mntopts ,$winfs_mntopts "
92
- label=${i[0]:= ${DEVNAME##*/ } }
93
- mntpoint=$mntroot /$label
94
- _mount
95
- return
96
- fi
97
- IFS=$' \n '
98
- d=(` sudo blkid -o list | grep " not mounted" ` )
99
- if [[ $d ]]; then
87
+ eval " ` lsblk -P -o NAME,FSTYPE,LABEL $1 ` "
88
+ [[ $FSTYPE ]] || return
89
+ else
90
+ IFS=$' \n '
91
+ d=(` lsblk -P -o NAME,FSTYPE,LABEL,MOUNTPOINT | grep -e MOUNTPOINT=\"\" | grep -v -e FSTYPE=\"\" | cut -d' ' -f1-3` )
100
92
menutitle=" Device Menu"
101
93
menu ${d[@]} " Main Menu"
102
94
IFS=$oIFS
103
95
if [[ $choice = " Main Menu" ]]; then mainmenu; return ; fi
104
- i=($choice )
105
- DEVNAME=${i[0]}
106
- [[ ${i[1]} = ntfs ]] && fs=" -t ntfs-3g" || fs=" -t ${i[1]} "
107
- [[ $fs =~ vfat| ntfs ]] && mntopts=" $mntopts ,$winfs_mntopts "
108
- label=${i[2]:= ${DEVNAME##*/ } }
109
- mntpoint=$mntroot /$label
110
- _mount
111
- else
112
- IFS=$oIFS
113
- echo -e " ${red} Cannot find any not mounted device $none "
114
- mainmenu
96
+ eval " $choice "
115
97
fi
98
+ DEVNAME=/dev/$NAME
99
+ [[ $FSTYPE = ntfs ]] && fs=" -t ntfs-3g" || fs=" -t $FSTYPE "
100
+ [[ $fs =~ vfat| ntfs ]] && mntopts=" $mntopts ,$winfs_mntopts "
101
+ label=${LABEL:= ${DEVNAME##*/ } }
102
+ mntpoint=$mntroot /$label
103
+ _mount
116
104
}
117
105
118
106
function imagemenu {
@@ -283,7 +271,7 @@ function histsave {
283
271
284
272
function mainmenu {
285
273
menutitle=" Main Menu"
286
- menu " Mount devices on this computer" " Mount image file" " Mount Samba share" " Mount SSH" " Mount FTP" " Mount NFS" " Mount from history" " Unmount"
274
+ menu " Mount devices on this computer" " Mount image file" " Mount Samba share" " Mount SSH" " Mount FTP" " Mount NFS" " Mount from history" " Unmount" " Remove all entries from conkyrc " " Remount Device "
287
275
case $choice in
288
276
* devices* ) devicemenu ;;
289
277
* image* ) imagemenu ;;
@@ -293,11 +281,13 @@ function mainmenu {
293
281
* NFS) nfsmenu ;;
294
282
* history) histmenu ;;
295
283
Unmount) unmountmenu ;;
284
+ * conkyfc) modconkyrc removeall ;;
285
+ Remount* ) remountmenu ;;
296
286
esac
297
287
}
298
288
299
289
function unmountmenu {
300
- if [ $1 ]; then
290
+ if [[ $1 ] ]; then
301
291
[[ $1 = $mntroot ]] && mntpoint=$1 || mntpoint=` mount | grep " $1 " | cut -d' ' -f3`
302
292
unmount " $mntpoint "
303
293
return
@@ -323,6 +313,23 @@ function unmountmenu {
323
313
mainmenu
324
314
}
325
315
316
+ function remountmenu {
317
+ if [[ $1 ]]; then
318
+ eval " ` lsblk -P -o NAME,MOUNTPOINT | grep ${1##*/ } ` "
319
+ else
320
+ IFS=$' \n '
321
+ d=(` lsblk -P -o NAME,MOUNTPOINT | grep $mntroot ` )
322
+ menutitle=" Remount Device Menu"
323
+ menu ${d[@]} " Main Menu"
324
+ IFS=$oIFS
325
+ if [[ $choice = " Main Menu" ]]; then mainmenu; return ; fi
326
+ eval " $choice "
327
+ fi
328
+ unmount " $MOUNTPOINT "
329
+ sleep 1
330
+ devicemenu " /dev/$NAME "
331
+ }
332
+
326
333
function _mount() { # require: DEVNAME mntpoint mntopts
327
334
[[ $DEVNAME && $mntpoint ]] || return 1
328
335
if i=` mount | grep -q " $DEVNAME " ` ; then
@@ -338,7 +345,7 @@ function _mount() { #require: DEVNAME mntpoint mntopts
338
345
-t* ftpfs) curlftpfs " $DEVNAME " " $mntpoint " $mntopts ; echo " mount command: curlftpfs $DEVNAME $mntpoint $mntopts " ;;
339
346
* ) $runasroot mount $fs $mntopts " $DEVNAME " " $mntpoint " ; echo " mount command: $runasroot mount $fs $mntopts $DEVNAME $mntpoint " ;;
340
347
esac
341
- if [[ $? -eq 0 ]] ; then
348
+ if mount | grep -q " $mntpoint " ; then
342
349
histsave
343
350
modconkyrc add
344
351
echo " $DEVNAME is mounted at $mntpoint "
@@ -372,9 +379,12 @@ function modconkyrc {
372
379
for i in " ${conkyrc[@]} " ; do
373
380
[[ -f $i ]] || continue
374
381
if [[ $1 = add && $DEVNAME = /dev/* ]]; then
375
- echo -e " \$ {color slate grey}${mntpoint##*/ } :\$ {fs_size $mntpoint } \$ {color orange}U:\$ {fs_used $mntpoint } \$ {color}F:\$ {fs_free $mntpoint }\n\$ color\$ {fs_bar $mntpoint } \$ {color orange}\$ {diskio ${DEVNAME##*/ } }" >> " $i "
382
+ echo -e " \$ {color slate grey}${mntpoint##*/ } :\$ {fs_size $mntpoint } \$ {color orange}U:\$ {fs_used $mntpoint } \$ {color}F:\$ {fs_free $mntpoint } \$ {if_empty mnttools_entry}\$ endif" >> " $i "
383
+ echo -e " \$ color\$ {fs_bar $mntpoint } \$ {color orange}\$ {diskio ${DEVNAME##*/ } } \$ {if_empty mnttools_entry}\$ endif" >> " $i "
376
384
elif [[ $1 = remove ]]; then
377
- sed -i " /${mntpoint##* \/ } /d" " $i "
385
+ sed -i " /${mntpoint##* \/ } .*mnttools/d" " $i "
386
+ elif [[ $1 = removeall ]]; then
387
+ sed -i " /mnttools_entry/d" " $i "
378
388
fi
379
389
done
380
390
}
@@ -421,6 +431,8 @@ $0 unmount [mountpoint|device name] #unmount mountpoint in mount folder
421
431
$0 editcfg #create/edit cfg
422
432
$0 readme #show readme
423
433
$0 tray #show trayicon
434
+ $0 conkyrc_remove #remove all mnttools conkyrc entries
435
+ $0 remount [mountpoint|device name] #remount device
424
436
EOF
425
437
exit
426
438
}
@@ -458,10 +470,12 @@ case $action in
458
470
ftpfs) ftpmenu ;;
459
471
samba) smbmenu ;;
460
472
device) devicemenu "$2 " ;;
473
+ remount) remountmenu "$2 " ;;
461
474
hist) histmenu ;;
462
475
unmount) unmountmenu "$2 ";;
463
476
editcfg) [[ -f $cfg ]] || writecfg; xdg-open "$cfg " ;;
464
477
readme) readme=` readlink -f " $0 " ` .readme; cat "$readme " ;;
478
+ conkyrc_remove) modconkyrc removeall ;;
465
479
-h|*help) usage ;;
466
480
*) mainmenu ;;
467
481
esac
0 commit comments