-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathpgpatrol.sh
171 lines (137 loc) · 6.75 KB
/
pgpatrol.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
#!/bin/bash
#
# Title: PGBlitz (Reference Title File)
# Author(s): Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
################################################################################
# KEY VARIABLE RECALL & EXECUTION
mkdir -p /var/plexguide/pgpatrol
# FUNCTIONS START ##############################################################
# FIRST FUNCTION
variable() {
file="$1"
if [ ! -e "$file" ]; then echo "$2" >$1; fi
}
deploycheck() {
dcheck=$(systemctl status pgpatrol | grep "\(running\)\>" | grep "\<since\>")
if [ "$dcheck" != "" ]; then
dstatus="✅ DEPLOYED"
else dstatus="⚠️ NOT DEPLOYED"; fi
}
plexcheck() {
pcheck=$(docker ps | grep "\<plex\>")
if [ "$pcheck" == "" ]; then
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⛔️ WARNING! - Plex is Not Installed or Running! Exiting!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p 'Confirm Info | PRESS [ENTER] ' typed </dev/tty
exit
fi
}
token() {
touch /var/plexguide/plex.token
ptoken=$(cat /var/plexguide/plex.token)
if [ "$ptoken" == "" ]; then
bash /opt/plexguide/menu/plex/token.sh
ptoken=$(cat /var/plexguide/plex.token)
if [ "$ptoken" == "" ]; then
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⛔️ WARNING! - Failed to Generate a Valid Plex Token! Exiting Deployment!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p 'Confirm Info | PRESS [ENTER] ' typed </dev/tty
exit
fi
fi
}
# BAD INPUT
badinput() {
echo
read -p '⛔️ ERROR - BAD INPUT! | PRESS [ENTER] ' typed </dev/tty
question1
}
selection1() {
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Instantly Kick Video Transcodes?
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚡ Reference: http://pgpatrol.pgblitz.com
[1] False
[2] True
EOF
read -p 'Type Number | PRESS [ENTER] ' typed </dev/tty
if [ "$typed" == "1" ]; then
echo "False" >/var/plexguide/pgpatrol/video.transcodes && question1
elif [ "$typed" == "2" ]; then
echo "True" >/var/plexguide/pgpatrol/video.transcodes && question1
else badinput; fi
}
selection2() {
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Limit Amount of Different IPs a User Can Make?
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚡ Reference: http://pgpatrol.pgblitz.com
Set a Number from [1] 99
EOF
read -p 'Type Number | PRESS [ENTER] ' typed </dev/tty
if [[ "$typed" -ge "1" && "$typed" -le "99" ]]; then
echo "$typed" >/var/plexguide/pgpatrol/multiple.ips && question1
else badinput; fi
}
selection3() {
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Limit How Long a User Can Pause For!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚡ Reference: http://pgpatrol.pgblitz.com
Set a Number from [5] 999 Mintues
EOF
read -p 'Type Number | PRESS [ENTER] ' typed </dev/tty
if [[ "$typed" -ge "1" && "$typed" -le "999" ]]; then
echo "$typed" >/var/plexguide/pgpatrol/kick.minutes && question1
else badinput; fi
}
# FIRST QUESTION
question1() {
video=$(cat /var/plexguide/pgpatrol/video.transcodes)
ips=$(cat /var/plexguide/pgpatrol/multiple.ips)
minutes=$(cat /var/plexguide/pgpatrol/kick.minutes)
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 PG Patrol Interface
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚡ Reference: http://pgpatrol.pgblitz.com
[1] Instantly Kick Video Transcodes? [$video]
[2] UserName | Multiple IPs? [$ips]
[3] Minutes | Kick Paused Transcode? [$minutes]
[4] Deploy PGPatrol [$dstatus]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[Z] Exit
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p '↘️ Type Number | Press [ENTER]: ' typed </dev/tty
if [ "$typed" == "1" ]; then
selection1
elif [ "$typed" == "2" ]; then
selection2
elif [ "$typed" == "3" ]; then
selection3
elif [ "$typed" == "4" ]; then
ansible-playbook /opt/pgpatrol/pgpatrol.yml && question1
elif [[ "$typed" == "Z" || "$typed" == "z" ]]; then
exit
else badinput; fi
}
# FUNCTIONS END ##############################################################
plexcheck
token
variable /var/plexguide/pgpatrol/video.transcodes "False"
variable /var/plexguide/pgpatrol/multiple.ips "2"
variable /var/plexguide/pgpatrol/kick.minutes "1"
deploycheck
question1