-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_nzedb_installer.sh
179 lines (147 loc) · 5.94 KB
/
test_nzedb_installer.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
#!/bin/bash
<<GPLV3
Script for running the https://github.com/nZEDb/nZEDb web installer from the command line.
This was written with the intention of nzedb developpers using it to see if the installer
works correctly, but can be used by end users to set up nzedb.
Change the settings below.
@TODO Display errors on command line.
Copyright (C) 2016 kevinlekiller
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
GPLV3
############################################################################################################
########################################### Settings #######################################################
############################################################################################################
# nzedb path
NZEDBPATH="/var/www/nZEDb"
# Web hostname for nzedb site (http://$HOST/)
HOST="localhost"
# Set to https if the site is https only.
HTTP="http"
AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/51.0.2704.79 Chrome/51.0.2704.79 Safari/537.36"
# mysql settings (step 2 of installer)
DBUSER="admin"
DBPASS="123"
DBHOST="127.0.0.1"
DBPORT="3306"
DBSOCKET="/var/run/mysqld/mysqld.sock"
DBNAME="nzedb"
# ssl settings (step 3 of installer)
SSLCAFILE=""
SSLCAPATH=""
SSLVERIFYPEER="0"
SSLVERIFYHOST="0"
SSLALLOWSELFSIGNED="1"
# nntp settings (step 4 of installer)
# User and password can be left empty if you are just testing the installer.
NNTPSERVER="news.astraweb.com"
NNTPUSER=""
NNTPPASS=""
NNTPPORT="119"
NNTPSSL="0"
NNTPSOCKTIMEOUT="120"
NNTPSERVER2=""
NNTPUSER2=""
NNTPPASS2=""
NNTPPORT2=""
NNTPSSL2=""
NNTPSOCKTIMEOUT2="120"
# admin settings (step 6 of installer)
ADMINUSER="admin"
ADMINPASS="123"
ADMINFIRSTNAME=""
ADMINLASTNAME=""
ADMINEMAIL="[email protected]"
# file paths (step 7 of installer)
COVERPATH="$NZEDBPATH/resources/covers/"
NZBPATH="$NZEDBPATH/resources/nzb/"
TMPPATH="$NZEDBPATH/resources/tmp/unrar/"
############################################################################################################
############################################################################################################
############################################################################################################
if [[ -e $NZEDBPATH/configuration/install.lock ]]; then
echo "ERROR: $NZEDBPATH/configuration/install.lock exists! Please remove the file before continuing."
exit 1
fi
which curl 1> /dev/null
if [[ $? != 0 ]]; then
echo "ERROR: curl is required."
exit 1
fi
PAGE=$(curl --head -s -L --url "$HTTP://$HOST/install" 2> /dev/null)
if [[ ! $PAGE =~ "200 OK" ]]; then
echo "ERROR: Problem connecting to '$HTTP://$HOST/install/'"
exit 1
fi
COOKIE=$(echo "$PAGE" | grep -Po "PHPSESSID.+?$")
if [[ $COOKIE == "" ]]; then
echo "Could not find cookie!"
exit 1
fi
curlPage() {
if [[ -z $3 ]]; then
if [[ -z $2 ]]; then
REFERER=""
else
REFERER="$2"
fi
PAGE=$(curl \
--url "$HTTP://$HOST/install/$1" \
-L -s \
--cookie "$COOKIE" \
--header "Host: $HOST" \
--header "Connection: keep-alive" \
--header "Upgrade-Insecure-Requests: 1" \
--header "User-Agent: $AGENT" \
--header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" \
--header "Referer: $HTTP://$HOST/install/$REFERER" \
--header "Accept-Language: en-US,en;q=0.8"
)
else
PAGE=$(curl \
--data "$3" \
--url "$HTTP://$HOST/install/$1" \
-L -s \
--cookie "$COOKIE" \
--header "Host: $HOST" \
--header "Connection: keep-alive" \
--header "Upgrade-Insecure-Requests: 1" \
--header "User-Agent: $AGENT" \
--header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" \
--header "Referer: $HTTP://$HOST/install/$2" \
--header "Accept-Language: en-US,en;q=0.8" \
--header "Content-Type:application/x-www-form-urlencoded"
)
fi
}
checkPage() {
if [[ ! $PAGE =~ "$1" ]]; then
echo "$PAGE"
echo "ERROR: Problem on $HTTP://$HOST/install/step$2.php"
exit 1
fi
echo "Success: $HTTP://$HOST/install/step$2.php ; $1"
}
curlPage "step1.php?"
checkPage "No problems were found and you are ready to install." 1
curlPage "step2.php?" "step1.php?" "db_system=mysql&host=$DBHOST&sql_port=$DBPORT&sql_socket=$DBSOCKET&user=$DBUSER&pass=$DBPASS&db=$DBNAME"
checkPage "The database setup is correct, you may continue to the next step." 2
curlPage "step3.php?" "step2.php?" "cafile=$SSLCAFILE&capath=$SSLCAPATH&verifypeer=$SSLVERIFYPEER&verifyhost=$SSLVERIFYHOST&allowselfsigned=$SSLALLOWSELFSIGNED"
checkPage "The openssl setup looks correct, you may continue to the next step." 3
curlPage "step4.php?" "step3.php?" "server=$NNTPSERVER&user=$NNTPUSER&pass=$NNTPPASS&port=$NNTPPORT&socket_timeout=$NNTPSOCKTIMEOUT&servera=$NNTPSERVER2&usera=$NNTPUSER2&passa=$NNTPPASS2&porta=$NNTPPORT2&socket_timeouta=$NNTPSOCKTIMEOUT2"
checkPage "The news server setup is correct, you may continue to the next step." 4
curlPage "step5.php?" "step4.php?"
checkPage "The configuration file has been saved, you may continue to the next step." 5
curlPage "step6.php?" "step5.php?" "user=$ADMINUSER&fname=$ADMINFIRSTNAME&lname=$ADMINLASTNAME&pass=$ADMINPASS&email=$ADMINEMAIL"
checkPage "The admin user has been setup, you may continue to the next step." 6
curlPage "step7.php?" "step6.php?" "coverspath=$COVERPATH&nzbpath=$NZBPATH&tmpunrarpath=$TMPPATH"
checkPage "Install Complete!" 7
echo "Install finished succesfully. You can now head to $HTTP://$HOST/admin/"