-
Notifications
You must be signed in to change notification settings - Fork 0
/
mnt-image
40 lines (31 loc) · 854 Bytes
/
mnt-image
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
# 20161029 saintless for Retro-Debian
# GNU GPL v3 applies. No warranty of any kind.
# Includes moded code from examples in linux forums and man pages like:
# http://stackoverflow.com/questions/226703/how-do-i-prompt-for-input-in-a-linux-shell-script
# https://github.com/MintPup/DebianDog-Wheezy/tree/master/scripts
if [ "$(whoami)" != "root" ]; then
echo "You have to run this script as Superuser!"
exit
fi
IMG="$1"
if [ ! "$IMG" ]; then
echo "usage: mnt-image /path-to-file"
exit
fi
MP=/media/$(basename "$IMG").dir
mkdir -p "$MP"
if ! mount | grep "$MP"; then
mount -o loop "$IMG" "$MP"
echo mounted on "$MP"
# echo
# read -p "Open $MP in ROX now? (y/n)?" choose #If I need prompt to open in Rox later.
# case "$choose" in
# y|Y ) rox "$MP";;
# * ) exit;;
#esac
else
umount "$MP"
rmdir "$MP"
echo "$MP" unmounted.
fi