forked from vermaden/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nfs.sh
executable file
·74 lines (62 loc) · 1.31 KB
/
nfs.sh
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
74
#! /bin/sh
SUDO_WHICH=0
SUDO=0
DOAS_WHICH=0
DOAS=1
ROOT=0
# CHECK doas(8) WITH which(1)
if which doas 1> /dev/null 2> /dev/null
then
DOAS_WHICH=1
else
DOAS_WHICH=0
fi
# CHECK sudo(8) WITH which(1)
if which sudo 1> /dev/null 2> /dev/null
then
SUDO_WHICH=1
else
SUDO_WHICH=0
fi
# CHECK USER WITH whoami(1)
if [ "$( whoami )" = "root" ]
then
ROOT=1
fi
# CHOOSE ONE FROM doas(8) AND sudo(8)
if [ ${DOAS_WHICH} -eq 1 -o ${SUDO_WHICH} -eq 1 ]
then
if [ ${DOAS} -eq 0 -a ${SUDO} -eq 1 -a ${SUDO_WHICH} -eq 1 ]
then
CMD=sudo
elif [ ${DOAS} -eq 1 -a ${SUDO} -eq 0 -a ${DOAS_WHICH} -eq 1 ]
then
CMD=doas
elif [ ${DOAS} -eq 1 -a ${SUDO} -eq 1 -a ${DOAS_WHICH} -eq 1 ]
then
CMD=doas
fi
elif [ ${ROOT} -eq 1 ]
then
CMD=''
else
echo "NOPE: This script needs 'doas' or 'sudo' to work properly."
exit 1
fi
unset SUDO_WHICH
unset DOAS_WHICH
unset ROOT
MNT=/media/blackbox
DIR=/data
mount -t nfs | grep -q ${MNT} || {
# FSTAB
# 10.0.0.2:/data /media/blackbox nfs rw,noauto,noatime,soft
# ${CMD} mount /media/blackbox
${CMD} mkdir -p ${MNT}
${CMD} chown 1000:1000 ${MNT}
${CMD} mount -t nfs \
-o rw,noatime,soft,retrycnt=5,retrans=1,readahead=4,nolockd,nocto,rsize=1048576,wsize=1048576 \
10.0.0.2:/data ${MNT}
}
caja --browser --no-desktop ${MNT} &
echo '1' >> ~/scripts/stats/${0##*/}