-
Notifications
You must be signed in to change notification settings - Fork 16
/
functions.sh
186 lines (154 loc) · 5.16 KB
/
functions.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/bash
#
# Title: PGBlitz (Reference Title File)
# Author(s): Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
################################################################################
variable () {
file="$1"
if [ ! -e "$file" ]; then echo "$2" > $1; fi
}
################################################################################
common () {
echo "${apps}" > /pg/var/role.name
mkdir -p "/pg/data/${apps}"
variable /pg/var/tld.status ""
variable /pg/var/oauth.status ""
variable /pg/var/domain.status "NOT-SET"
variable /pg/var/port.status ""
variable /pg/var/tld.status "portainer"
if [[ "apps" != "plex" ]]; then
chown -R 1000:1000 "/pg/data/${apps}"
chmod -R 775 "/pg/data/${apps}"
else
chown 1000:1000 "/pg/data/${apps}"
chmod 775 "/pg/data/${apps}"
fi
docker stop "${apps}" 1>/dev/null 2>&1
docker rm "${apps}" 1>/dev/null 2>&1
}
################################################################################
appgen () {
### Blank Out Temp List
rm -rf /pg/var/program.temp && touch /pg/var/program.temp
### List Out Apps In Readable Order (One's Not Installed)
sed -i -e "/templates/d" /pg/var/app.list
touch /pg/tmp/test.99
num=0
while read p; do
echo -n $p >> /pg/var/program.temp
echo -n " " >> /pg/var/program.temp
num=$[num+1]
if [ "$num" == 10 ]; then
num=0
echo " " >> /pg/var/program.temp
fi
done </pg/var/app.list
notrun=$(cat /pg/var/program.temp)
buildup=$(cat /pg/var/pgbox.output)
if [ "$buildup" == "" ]; then buildup="NONE"; fi
}
################################################################################
userlistgen () {
echo "$typed" >> /pg/var/pgbox.buildup
num=0
touch /pg/var/pgbox.output && rm -rf /pg/var/pgbox.output
while read p; do
echo -n $p >> /pg/var/pgbox.output
echo -n " " >> /pg/var/pgbox.output
if [ "$num" == 8 ]; then
num=0
echo " " >> /pg/var/pgbox.output
fi
done </pg/var/pgbox.buildup
sed -i "/^$typed\b/Id" /pg/var/app.list
question1
}
################################################################################
badinput () {
echo
read -p '⛔️ ERROR - Bad Input! | Press [ENTER] ' typed < /dev/tty
}
badinput1 () {
echo
read -p '⛔️ ERROR - Bad Input! | Press [ENTER] ' typed < /dev/tty
question1
}
variable () {
file="$1"
if [ ! -e "$file" ]; then echo "$2" > $1; fi
}
initial () {
rm -rf /pg/var/pgbox.output 1>/dev/null 2>&1
rm -rf /pg/var/pgbox.buildup 1>/dev/null 2>&1
rm -rf /pg/var/program.temp 1>/dev/null 2>&1
rm -rf /pg/var/app.list 1>/dev/null 2>&1
touch /pg/var/pgbox.output
touch /pg/var/program.temp
touch /pg/var/app.list
touch /pg/var/pgbox.buildup
# from _appsgen.sh (generates the list of apps to install)
appslistgen
docker ps | awk '{print $NF}' | tail -n +2 > /pg/var/pgbox.running
}
queued () {
echo
read -p '⛔️ ERROR - APP Already Queued! | Press [ENTER] ' typed < /dev/tty
question1
}
exists () {
echo ""
echo "⛔️ ERROR - APP Already Installed!"
read -p '⚠️ Do You Want To ReInstall ~ y or n | Press [ENTER] ' foo < /dev/tty
if [ "$foo" == "y" ]; then part1;
elif [ "$foo" == "n" ]; then question1;
else exists; fi
}
final () {
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
read -p '✅ Process Complete! | PRESS [ENTER] ' typed < /dev/tty
echo
exit
}
part1 () {
echo "$typed" >> /pg/var/pgbox.buildup
num=0
touch /pg/var/pgbox.output && rm -rf /pg/var/pgbox.output
while read p; do
echo -n $p >> /pg/var/pgbox.output
echo -n " " >> /pg/var/pgbox.output
if [ "$num" == 7 ]; then
num=0
echo " " >> /pg/var/pgbox.output
fi
done </pg/var/pgbox.buildup
sed -i "/^$typed\b/Id" /pg/var/app.list
question1
}
# Multi-Image Selector #########################################################
multiimage() {
# Checks Image List
file="/pg/apps/image/$apps"
if [ ! -e "$file" ]; then exit; fi
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌵 PG Multi Image Selector - $apps
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
count=1
while read p; do
echo "[$count] $p"
echo "$p" >/tmp/display$count
count=$((count + 1))
done </pg/apps/image/$apps
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
read -p '🚀 Type Number | PRESS [ENTER]: ' typed </dev/tty
if [[ "$typed" -ge "1" && "$typed" -lt "$count" ]]; then
cat "/tmp/display$typed" > "/pg/var/image.select"
else
multiimage
fi
}
# END OF MULTIIMAGE ############################################################