forked from aelfa/scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mergerfs-rclone-update.sh
145 lines (108 loc) · 5.13 KB
/
mergerfs-rclone-update.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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
# Copyright (c) 2020, MrDoob
# All rights reserved
function badinput() {
echo
read -p '⛔️ ERROR - Bad Input! | Press [ENTER] ' typed </dev/tty
}
function rclone_update_stable() {
curl https://rclone.org/install.sh | sudo bash
}
function rclone_update_beta() {
curl https://rclone.org/install.sh | sudo bash -s beta
}
function mergerupdate() {
mgversion="$(curl -s https://api.github.com/repos/trapexit/mergerfs/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')"
wget https://github.com/trapexit/mergerfs/releases/download/${mgversion}/mergerfs_${mgversion}.ubuntu-bionic_amd64.deb -O /tmp/mergerfs.deb
dpkg -i /tmp/mergerfs.deb
rm -rf /tmp/mergerfs.deb
}
function sudocheck () {
if [[ $EUID -ne 0 ]]; then
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⛔️ You Must Execute as a SUDO USER (with sudo) or as ROOT!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
exit 0
fi
}
function updateall() {
apt-get update -y
apt-get upgrade -y
apt-get dist-upgrade -y
apt-get autoremove -y
apt-get autoclean -y
}
function mergerfsupdate() {
mgversion="$(curl -s https://api.github.com/repos/trapexit/mergerfs/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')"
mgstored="$(mergerfs -v | grep 'mergerfs version:' | awk '{print $3}')"
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
mergerfs Update Panel --local version $mgstored
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
mergerfs installed version = $mgstored
mergerfs latest version = $mgversion
[Y] UPDATE to lateste version
[Z] Exit
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p '↘️ Type .... and press [ENTER]: ' typed </dev/tty
case $typed in
Y) mergerupdate ;;
y) mergerupdate ;;
z) clear && exit ;;
Z) clear && exit ;;
*) badinput ;;
esac
}
function rcloneupdate() {
rcversion="$(curl -s https://api.github.com/repos/rclone/rclone/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')"
rcstored="$(rclone --version | awk '{print $2}' | tail -n 3 | head -n 1)"
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
rClone Update Panel $rcstored
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
rclone installed version = $rcstored
rclone latest version = $rcversion
Update to STABLE = [ S / s ]
Update to BETA = [ B / b ]
[ Z / z ] = Exit
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p '↘️ Type .... and press [ENTER]: ' typed </dev/tty
case $typed in
S) rclone_update_stable ;;
s) rclone_update_stable ;;
B) rclone_update_beta ;;
b) rclone_update_beta ;;
z) clear && exit ;;
Z) clear && exit ;;
*) badinput ;;
esac
}
function update() {
sudocheck
updateall
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
>>> ---- Update INTERFACE ---- <<<<
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
rclone update panel = [ R / r ]
mergerfs update panel = [ M / m ]
EXIT the interface = [ Z / z ]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p '↘️ Type .... and press [ENTER]: ' typed </dev/tty
case $typed in
R) rcloneupdate ;;
r) rcloneupdate ;;
M) mergerfsupdate ;;
m) mergerfsupdate ;;
z) clear && exit ;;
Z) clear && exit ;;
*) badinput ;;
esac
}
update