-
Notifications
You must be signed in to change notification settings - Fork 1
/
nmount
executable file
·73 lines (68 loc) · 1.36 KB
/
nmount
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
71
72
73
#!/bin/bash
# depends on cifs-utils
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
GHURL="https://raw.githubusercontent.com/pyavitz/scripts/master"
if [ -f ~/.config/nmount ]; then
source ~/.config/nmount
else
ADDR="10.0.0.1"
FOLDER="Name"
MNT="/your/location"
USER="user"
USERID="user"
PASSWD="password"
fi
# Commands
if [ $# -eq 0 ]; then
echo "Missing options!"
echo "(run $0 -h for help)"
echo ""
exit 0
fi
while getopts "muUh" OPTION; do
case $OPTION in
m)
mount -t cifs //$ADDR/$FOLDER $MNT -o username=$USER,password=$PASSWD,rw,uid=$USERID
;;
u)
umount $MNT
;;
U)
if [[ `wget -S --spider ${GHURL}/nmount 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then
mv -f /usr/local/bin/nmount /usr/local/bin/nmount.orig;
wget -cq ${GHURL}/nmount -P /usr/local/bin;
if [ -f /usr/local/bin/nmount ]; then
chmod +x /usr/local/bin/nmount;
rm -f /usr/local/bin/nmount.orig;
else
mv -f /usr/local/bin/nmount.orig /usr/local/bin/nmount;
fi
fi
nmount -h
;;
h)
echo ""
echo -e "Mount Network Share"
echo ""
echo -e "\t-m\tMount"
echo -e "\t-u\tUnmount"
echo ""
echo -e "\t-h\tHelp"
echo ""
exit 0
;;
esac
done