-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsideload-mount
executable file
·103 lines (78 loc) · 2.45 KB
/
sideload-mount
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
source sideloader-config
osCheck
if [ ${EUID:-$(id -u)} -eq 0 ]; then
echo "PLEASE DO NOT RUN THIS SCRIPT USING ROOT"
exit 1
fi
clearLog
#MOUNTSUCCESS=false # nog gecomment wnat andere check nie in orde
#check already mounted set $MOUNTSUCCESS
if [ "$(ls -A $MNTLOC/ 2>/dev/null)" ]; then
MOUNTSUCCESS=true
ok "Drive mounted at: $MNTLOC ($(ls $MNTLOC | wc -l) folders available)\n\n"
dialogLog
exit 0
fi
info "Starting mount process"
CLOC="/tmp/c"
KLOC="/tmp/k"
curl --silent https://raw.githubusercontent.com/whitewhidow/quest-sideloader-linux/main/extras/c -o "$CLOC" > /dev/null
curl --silent https://raw.githubusercontent.com/whitewhidow/quest-sideloader-linux/main/extras/k -o "$KLOC" > /dev/null
cr=`echo $'\n.'`
cr=${cr%.}
C=$(cat $CLOC | base64 --decode)
k=$(cat $KLOC | base64 --decode)
C=$(echo "${C/XXX/$KLOC}" )
$(echo "$C" > $CLOC)
$(echo "$k" > $KLOC)
sleep 1
if [ $(rclone --config=$CLOC listremotes | wc -l) != "1" ]; then
error "Something is wrong, we cannot seem to find the remote"
error "If you report this at github.com/whitewhidow/quest-sideloader-linux, I will be happy to help"
read -p "$cr$cr Press [ENTER] to continue. $cr$cr" < "$(tty 0>&2)"
exit 1
else
ok "Mount-config detected successfully: $(rclone --config=$CLOC listremotes)"
fi
#has path
fusermount -uz $MNTLOC 2> /dev/null
umount $MNTLOC 2> /dev/null
rm -r $MNTLOC > /dev/null 2> /dev/null
mkdir -p $MNTLOC > /dev/null
REM=$(rclone --config=$CLOC listremotes)
nohup rclone mount -vv --no-modtime --read-only --config=$CLOC $REM $MNTLOC &
x=1
while [ $x -le 8 ] && [ -z $MOUNTSUCCESS ]
do
info "Checking if drive is mounted (attempt $x/8)"
sleep 3
x=$(( $x + 1 ))
if [ "$(ls -A $MNTLOC)" ]; then
MOUNTSUCCESS=true
fi
done
if [ -z $MOUNTSUCCESS ] && [ $OSTYPE == "mac" ]; then
info "Re-attempting with Cmount for bullshit osx"
nohup rclone cmount -vv --no-modtime --read-only --config=$CLOC $REM $MNTLOC &
x=1
while [ $x -le 8 ] && [ -z $MOUNTSUCCESS ]
do
info "Checking if drive is mounted (attempt $x/8)"
sleep 3
x=$(( $x + 1 ))
if [ "$(ls -A $MNTLOC)" ]; then
MOUNTSUCCESS=true
fi
done
fi
if [ ! -z $MOUNTSUCCESS ]; then
ok "Drive mounted at: $MNTLOC ($(ls $MNTLOC | wc -l) folders available)\n\n"
else
error "Something is wrong, we cannot seem to mount the drive."
error "If you report this at github.com/whitewhidow/quest-sideloader-linux, I will be happy to help"
dialogLog
exit 1
fi
dialogLog
exit 0