-
Notifications
You must be signed in to change notification settings - Fork 3
/
pgupdate
169 lines (140 loc) · 10.9 KB
/
pgupdate
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
############# https://github.com/plexguide/PlexGuide.com/graphs/contributors ###
pgupdate_ending () {
echo ""
cat << "EOF"
[38;5;33m┌[0m[38;5;33m─[0m[38;5;33m─[0m[38;5;33m─[0m[38;5;33m─[0m[38;5;33m─[0m[38;5;33m─[0m[38;5;33m─[0m[38;5;33m─[0m[38;5;39m─[0m[38;5;39m─[0m[38;5;39m─[0m[38;5;39m─[0m[38;5;39m─[0m[38;5;39m─[0m[38;5;39m─[0m[38;5;39m─[0m[38;5;39m─[0m[38;5;38m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;43m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;49m┐[0m
[38;5;33m│[0m[38;5;33m░[0m[38;5;33m░[0m[38;5;33m░[0m[38;5;33m░[0m[38;5;33m░[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;38m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;43m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;48m░[0m[38;5;48m│[0m
[38;5;33m│[0m[38;5;33m░[0m[38;5;33m█[0m[38;5;39m▀[0m[38;5;39m█[0m[38;5;39m░[0m[38;5;39m█[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;39m█[0m[38;5;39m▀[0m[38;5;38m▀[0m[38;5;44m░[0m[38;5;44m█[0m[38;5;44m░[0m[38;5;44m█[0m[38;5;44m░[0m[38;5;44m█[0m[38;5;44m▀[0m[38;5;44m▀[0m[38;5;44m░[0m[38;5;44m█[0m[38;5;44m░[0m[38;5;43m█[0m[38;5;49m░[0m[38;5;49m▀[0m[38;5;49m█[0m[38;5;49m▀[0m[38;5;49m░[0m[38;5;49m█[0m[38;5;49m▀[0m[38;5;49m▄[0m[38;5;49m░[0m[38;5;48m█[0m[38;5;48m▀[0m[38;5;48m▀[0m[38;5;48m░[0m[38;5;48m│[0m
[38;5;39m│[0m[38;5;39m░[0m[38;5;39m█[0m[38;5;39m▀[0m[38;5;39m▀[0m[38;5;39m░[0m[38;5;39m█[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;38m░[0m[38;5;44m█[0m[38;5;44m▀[0m[38;5;44m▀[0m[38;5;44m░[0m[38;5;44m▄[0m[38;5;44m▀[0m[38;5;44m▄[0m[38;5;44m░[0m[38;5;44m█[0m[38;5;44m░[0m[38;5;44m█[0m[38;5;43m░[0m[38;5;49m█[0m[38;5;49m░[0m[38;5;49m█[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m█[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m█[0m[38;5;48m░[0m[38;5;48m█[0m[38;5;48m░[0m[38;5;48m█[0m[38;5;48m▀[0m[38;5;48m▀[0m[38;5;48m░[0m[38;5;48m│[0m
[38;5;39m│[0m[38;5;39m░[0m[38;5;39m▀[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;38m▀[0m[38;5;44m▀[0m[38;5;44m▀[0m[38;5;44m░[0m[38;5;44m▀[0m[38;5;44m▀[0m[38;5;44m▀[0m[38;5;44m░[0m[38;5;44m▀[0m[38;5;44m░[0m[38;5;44m▀[0m[38;5;44m░[0m[38;5;43m▀[0m[38;5;49m▀[0m[38;5;49m▀[0m[38;5;49m░[0m[38;5;49m▀[0m[38;5;49m▀[0m[38;5;49m▀[0m[38;5;49m░[0m[38;5;49m▀[0m[38;5;49m▀[0m[38;5;48m▀[0m[38;5;48m░[0m[38;5;48m▀[0m[38;5;48m▀[0m[38;5;48m░[0m[38;5;48m░[0m[38;5;48m▀[0m[38;5;48m▀[0m[38;5;48m▀[0m[38;5;84m░[0m[38;5;83m│[0m
[38;5;39m│[0m[38;5;39m░[0m[38;5;39m░[0m[38;5;38m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;44m░[0m[38;5;43m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;49m░[0m[38;5;48m░[0m[38;5;48m░[0m[38;5;48m░[0m[38;5;48m░[0m[38;5;48m░[0m[38;5;48m░[0m[38;5;48m░[0m[38;5;48m░[0m[38;5;48m░[0m[38;5;84m░[0m[38;5;83m░[0m[38;5;83m░[0m[38;5;83m░[0m[38;5;83m│[0m
[38;5;38m└[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;44m─[0m[38;5;43m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;49m─[0m[38;5;48m─[0m[38;5;48m─[0m[38;5;48m─[0m[38;5;48m─[0m[38;5;48m─[0m[38;5;48m─[0m[38;5;48m─[0m[38;5;48m─[0m[38;5;48m─[0m[38;5;84m─[0m[38;5;83m─[0m[38;5;83m─[0m[38;5;83m─[0m[38;5;83m─[0m[38;5;83m─[0m[38;5;83m─[0m[38;5;83m┘[0m
EOF
cat << "EOF"
┌─────────────────────────────────────┐
│ EXITING PG Version X │
│ ————————————————————————————————————│
│ Star PG: plexguide.com/github │
│ Donate: plexguide.com/donate │
│ ————————————————————————————————————│
│ Restart PlexGuide: plexguide │
│ Update PlexGuide: pgupdate │
│ ——————————————————————————————————— │
│ An Original Admin9705 Project │
│ │
│ Dedicated to: │
│ Deiteq, YasQueen84 & JasMarie │
└─────────────────────────────────────┘
EOF
exit
}
pgupdate_start () {
rm -rf /pg/tmp/install/update
git clone -b v1 --single-branch https://github.com/plexguide/install.git /pg/tmp/install/update
cp -f /pg/tmp/install/update/pgupdate /bin/
chmod 0755 /bin/pgupdate
chown 1000:1000 /bin/pgupdate
fmt -w 79 /pg/tmp/install/update/versions > /pg/tmp/install/update/wrap
versions=$(cat /pg/tmp/install/update/wrap)
# FUNCTIONS ####################################################################
common_message() {
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
$1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
$2
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
}
common_header() {
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
$1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
}
common_number() {
read -p '↘️ Type Selection | Press [ENTER]: ' typed < /dev/tty
}
common_confirm() {
read -p 'Confirm Information | Press [ENTER] ' typed </dev/tty
}
common_fcreate_silent() {
mkdir -p "$1"
chown 1000:1000 "$1"
chmod 0775 "$1"
}
# PREUSER EXECUTION ############################################################
if [[ ! -e "/pg/var/user.check" ]]; then
common_fcreate_silent /pg/var
if [[ $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}') ]]; then
usermod -aG sudo $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}')
sudo usermod -s /bin/bash $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}')
sudo usermod -aG video $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}')
sudo usermod -aG docker $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}')
echo
echo '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
echo " ✅ PASSED ! We found the user UID:" $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}')
echo '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
touch /pg/var/user.check
common_confirm
else
common_message "🚀 PG Update Interface - 💾 Add User" "$versions
⌛ INFO ! Only lowercase and dont empty parts
⌛ INFO ! Enter a password (8+ chars)
"
read -p "Enter username : " username
read -s -p "Enter password : " password
egrep "^$username" /etc/passwd >/dev/null
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
useradd -m -p $pass $username
usermod -aG sudo $username
sudo usermod -s /bin/bash $username
usermod -aG video $username
usermod -aG docker $username
common_message "🚀 PG Update Interface - 💾 Add User" "✅ PASSED !
Username: $Username
Password: $Password"
touch /pg/var/user.check
common_confirm
fi; fi
# EXECUTION ####################################################################
common_message "🚀 PG Update Interface - 💾 Type a Version to Update" "$versions
[Z] Exit Interface"
common_number
case $typed in
Z ) pgupdate_ending && exit ;;
z ) pgupdate_ending && exit ;;
* ) a=a ;;
esac
install_version=$typed
common_header "💾 Install PG Version - $install_version? [y/n]"
common_number
case $typed in
N ) pgupdate_ending && exit ;;
n ) pgupdate_ending && exit ;;
y ) a=a ;;
Y ) a=a ;;
* ) pgupdate_start && exit ;;
esac
if [[ "$install_version" == "alpha" ]]; then
common_fcreate_silent /pg/var/version && echo "Alpha" > /pg/var/version/pg.build
sudo wget -nc https://raw.githubusercontent.com/plexguide/PlexGuide.com/alpha/mods/install/main.sh -O- | sudo bash && exit
fi
catch_num=$(cat /pg/tmp/install/update/versions | grep -c -w "\<$install_version\>")
if [[ "$catch_num" == "1" ]]; then
rm -rf /tmp/PlexGuide*
sudo wget "https://github.com/plexguide/PlexGuide.com/archive/${install_version}.zip" -P /tmp
if [[ ! -e "/usr/bin/unzip" ]]; then apt-get install unzip -y; fi
unzip "/tmp/${install_version}.zip" -d /tmp
common_fcreate_silent /pg/var/version && echo "${install_version}" > /pg/var/version/pg.build
bash "/tmp/PlexGuide.com-${install_version}/mods/install/main.sh"
exit && exit
else
common_header "⛔️ WARNING! DOES NOT EXIST - $install_version! Try Again!"
common_confirm
pgupdate_start && exit
fi
}
pgupdate_start