-
Notifications
You must be signed in to change notification settings - Fork 1
/
dmount
executable file
·70 lines (64 loc) · 1.39 KB
/
dmount
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
if [[ "$USER" == "root" ]]; then
:;
else
if [[ `command -v sudo` ]]; then
export LANG=$LANG:C
if [[ $EUID -ne 0 ]]; then
sudo "$0" "$@"
exit
fi
else
echo "Please run this as root or with sudo privileges."
exit 0
fi
fi
# host machine
DISTRO=`cat /etc/os-release | grep -w NAME | sed 's/NAME=//g' | sed 's/"//g' | sed 's/ GNU\/Linux//g'`
CODENAME=`cat /etc/os-release | grep -w "VERSION_CODENAME" | sed 's/VERSION_CODENAME=//g'`
ARCH=`uname -m`
# manual
NODE="/dev/sda1"
POINT="/mnt/external"
if [ $# -eq 0 ]; then
echo "Missing options!"
echo "(run $0 -h for help)"
echo ""
exit 0
fi
while getopts "muh" OPTION; do
case $OPTION in
m)
if [[ -e "${NODE}" ]] && [[ -e "${POINT}" ]]; then
mount ${NODE} ${POINT}
if [[ "$DISTRO" == "Debian" || "$DISTRO" == "Kali" || "$DISTRO" == "Raspbian" || "$DISTRO" == "Ubuntu" ]]; then
systemctl daemon-reload
fi
else
mkdir -p ${POINT}
sleep .75
mount ${NODE} ${POINT}
if [[ "$DISTRO" == "Debian" || "$DISTRO" == "Kali" || "$DISTRO" == "Raspbian" || "$DISTRO" == "Ubuntu" ]]; then
systemctl daemon-reload
fi
fi
;;
u)
if [[ -e "${NODE}" ]] && [[ -e "${POINT}" ]]; then
umount ${POINT}
fi
;;
h)
echo ""
echo -e "Mount Drive"
echo ""
echo -e "\t-m\tMount"
echo -e "\t-u\tUnmount"
echo ""
echo -e "\t-h\tHelp"
echo ""
exit 0
;;
esac
done
exit 0