-
Notifications
You must be signed in to change notification settings - Fork 4
/
meson-update.sh
109 lines (82 loc) · 3.68 KB
/
meson-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
#!/bin/bash
cpu_arch="$(uname -m)"
freespace="$(df --output=avail -h "$PWD" | sed '1d;s/[^0-9]//g')" # print free space
installdir="$(findmnt -n -T .)" # print installation partion / disk
find_amd="$(find . -name meson_cdn-linux-amd64)"
find_arm="$(find . -name meson_cdn-linux-arm64)"
# functions
now() {
date +"%Y/%m/%d %H:%M:%S"
} # display current time
printf '\n%.0s' {1,100}
echo "
░█▀▄▀█ ░█▀▀▀ ░█▀▀▀█ ░█▀▀▀█ ░█▄─░█ ▀█▀ ░█▄─░█ ░█▀▀▀█ ▀▀█▀▀ ─█▀▀█ ░█─── ░█─── ░█▀▀▀ ░█▀▀█
░█░█░█ ░█▀▀▀ ─▀▀▀▄▄ ░█──░█ ░█░█░█ ░█─ ░█░█░█ ─▀▀▀▄▄ ─░█── ░█▄▄█ ░█─── ░█─── ░█▀▀▀ ░█▄▄▀
░█──░█ ░█▄▄▄ ░█▄▄▄█ ░█▄▄▄█ ░█──▀█ ▄█▄ ░█──▀█ ░█▄▄▄█ ─░█── ░█─░█ ░█▄▄█ ░█▄▄█ ░█▄▄▄ ░█─░█\
"
printf '\n%.0s' {1,100}
# x86_64 update
# detect x86_64 CPUs
if [ "${cpu_arch}" = "x86_64" ]; then
echo "$(now) Nice to see you again
Your current configuration:
"
cd $find_amd
sudo ./meson_cdn config show
read -p "
Press ENTER to change your configuration:"
read -p "
Please re-enter your token: " token
read -p "
Define a new port [default is 443. press ENTER for defaut]: " port
port="${port:-443}" #default value if imput is empty
read -p "
Change the cache size [minimum requried: 20GB, available: ${freespace}GB, Default: 30GB. press ENTER for default]:" storage
storage="${storage:-30}" #default value if imput is empty
read -p "
Your new token: $token
New selected port: $port
New cache: ${storage}GB of ${freespace}GB free space in ${installdir}
Please ENTER to verify:"
echo " $(now) Reconfiguration started!"
sudo ufw allow $port
sudo systemctl restart ufw
echo "$(now) Firewall updated"
echo "$(now) Port $port opened"
sudo ./meson_cdn config set --token=$token --https_port=$port --cache.size=$storage
sudo ./service restart meson_cdn
echo "
$(now) That's it! Updated"
# arm64 update
# detect arm64 CPUs
elif [[ "${cpu_arch}" = "arm64" ]] || [[ "${cpu_arch}" = "aarch64" ]]; then
echo "$(now) Nice to see you again
Your current configuration:
"
cd $find_arm
sudo ./meson_cdn config show
read -p "
Press ENTER to change your configuration:"
read -p "
Please re-enter your token: " token
read -p "
Define a new port [default is 443. press ENTER for defaut]: " port
port="${port:-443}" #default value if imput is empty
read -p "
Change the cache size [minimum requried: 20GB, available: ${freespace}GB, Default: 30GB. press ENTER for default]:" storage
storage="${storage:-30}" #default value if imput is empty
read -p "
Your new token: $token
New selected port: $port
New cache: ${storage}GB of ${freespace}GB free space in ${installdir}
Please ENTER to verify:"
echo " $(now) Reconfiguration started!"
sudo ufw allow $port
sudo systemctl restart ufw
echo "$(now) Firewall updated"
echo "$(now) Port $port opened"
sudo ./meson_cdn config set --token=$token --https_port=$port --cache.size=$storage
sudo ./service restart meson_cdn
echo "
$(now) That's it! Updated"
fi