forked from littlebizzy/slickstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathss-check.txt
342 lines (299 loc) · 16.6 KB
/
ss-check.txt
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#!/bin/bash
####################################################################################################
#### author: SlickStack ############################################################################
#### link: https://slickstack.io ###################################################################
#### mirror: http://mirrors.slickstack.io/ss-check.txt #############################################
#### path: /var/www/ss-check #######################################################################
#### destination: n/a (not a boilerplate) ##########################################################
#### purpose: Downloads latest SlickStack Core files (except itself = done by ss-worker) ###########
#### module version: Ubuntu 20.04 LTS ##############################################################
####################################################################################################
## include SlickStack configuration ##
source /var/www/ss-config
## include SlickStack functions ##
# source /var/www/ss-functions
####################################################################################################
#### SlickStack: Critical Bash Functions (Aliases) For This Script To Work #########################
####################################################################################################
## the below functions are hardcoded into every SlickStack script to ensure reliability ##
## this also speeds up processing times by avoiding repeated inline commands ##
## variables ##
UBUNTU_VERSION=`lsb_release -rs`
## apt alias flags ##
function apt {
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_PRIORITY=critical
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
command /usr/bin/apt --yes --quiet --option Dpkg::Options::=--force-confold --option Dpkg::Options::=--force-confdef "$@"
}
## add-apt-repository alias flags ##
function add-apt-repository {
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_PRIORITY=critical
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
command /usr/bin/add-apt-repository --yes "$@"
}
## wget alias flags ##
function wget {
command wget --no-check-certificate --no-cache --no-cookies --tries=3 --timeout=15 "$@"
}
## mysql alias flags ##
function mysql {
command mysql --user=root --host=localhost --protocol=socket --port=3306 --force "$@"
}
## cp alias flags ##
function cp {
command cp -R -f -d --no-preserve=mode,ownership "$@"
}
## rsync alias flags ##
function rsync {
command rsync -aI --ignore-errors "$@"
}
## unzip alias flags ##
function unzip {
command unzip -o "$@"
}
## mkdir alias flags ##
function mkdir {
command mkdir -p "$@"
}
## rm alias flags ##
function rm {
command rm -R -f "$@"
}
## ln alias flags ##
function ln {
command ln -s -f "$@"
}
####################################################################################################
#### SlickStack: Pretty Colors Make The Shell More Pleasing ########################################
####################################################################################################
## these color variables help maintain cleaner and prettier Bash scripts in SlickStack ##
## we substitute e.g. ${BLUE} within an echo line then use ${NOCOLOR} to revert ##
## pretty Bash colors ##
NOCOLOR='\033[0m'
DARKRED='\033[0;31m'
LIGHTRED='\033[1;31m'
ORANGE='\033[0;33m'
YELLOW='\033[1;33m'
DARKGREEN='\033[0;32m'
LIGHTGREEN='\033[1;32m'
DARKCYAN='\033[0;36m'
LIGHTCYAN='\033[1;36m'
DARKBLUE='\033[0;34m'
LIGHTBLUE='\033[1;34m'
DARKPURPLE='\033[0;35m'
LIGHTPURPLE='\033[1;35m'
DARKGRAY='\033[1;30m'
LIGHTGRAY='\033[0;37m'
WHITE='\033[1;37m'
## pretty Bash styles ##
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
####################################################################################################
#### SS-Check: Delete Any Previous / Leftover (Conflicting) Temporary Files ########################
####################################################################################################
## delete temp files ##
rm /tmp/ss*
rm /tmp/*cron*
####################################################################################################
#### SS-Check: Download Latest SlickStack Core Files (Does Not Download Any Modules) ###############
####################################################################################################
## download latest core cron jobs ##
wget -O /tmp/00-crontab http://mirrors.slickstack.io/00-crontab.txt
wget -O /tmp/01-cron-often http://mirrors.slickstack.io/01-cron-often.txt
wget -O /tmp/02-cron-regular http://mirrors.slickstack.io/02-cron-regular.txt
wget -O /tmp/03-cron-quarter-hourly http://mirrors.slickstack.io/03-cron-quarter-hourly.txt
wget -O /tmp/04-cron-half-hourly http://mirrors.slickstack.io/04-cron-half-hourly.txt
wget -O /tmp/05-cron-hourly http://mirrors.slickstack.io/05-cron-hourly.txt
wget -O /tmp/06-cron-quarter-daily http://mirrors.slickstack.io/06-cron-quarter-daily.txt
wget -O /tmp/07-cron-half-daily http://mirrors.slickstack.io/07-cron-half-daily.txt
wget -O /tmp/08-cron-daily http://mirrors.slickstack.io/08-cron-daily.txt
wget -O /tmp/09-cron-half-weekly http://mirrors.slickstack.io/09-cron-half-weekly.txt
wget -O /tmp/10-cron-weekly http://mirrors.slickstack.io/10-cron-weekly.txt
wget -O /tmp/11-cron-half-monthly http://mirrors.slickstack.io/11-cron-half-monthly.txt
wget -O /tmp/12-cron-monthly http://mirrors.slickstack.io/12-cron-monthly.txt
wget -O /tmp/13-cron-sometimes http://mirrors.slickstack.io/13-cron-sometimes.txt
## download latest core Bash scripts (except ss-check) ##
# wget -O /tmp/ss-backup http://mirrors.slickstack.io/ss-backup.txt
wget -O /tmp/ss-clean http://mirrors.slickstack.io/ss-clean.txt
wget -O /tmp/ss-config-sample http://mirrors.slickstack.io/ss-config-sample.txt
wget -O /tmp/ss-dos2unix http://mirrors.slickstack.io/ss-dos2unix.txt
wget -O /tmp/ss-dump http://mirrors.slickstack.io/ss-dump.txt
wget -O /tmp/ss-encrypt http://mirrors.slickstack.io/ss-encrypt.txt
wget -O /tmp/ss-functions http://mirrors.slickstack.io/ss-functions.txt
wget -O /tmp/ss-import http://mirrors.slickstack.io/ss-import.txt
wget -O /tmp/ss-install-adminer http://mirrors.slickstack.io/ss-install-adminer.txt
wget -O /tmp/ss-install-clamav http://mirrors.slickstack.io/ss-install-clamav.txt
wget -O /tmp/ss-install-craft-config http://mirrors.slickstack.io/ss-install-craft-config.txt
wget -O /tmp/ss-install-craft-core http://mirrors.slickstack.io/ss-install-craft-core.txt
wget -O /tmp/ss-install-magento-config http://mirrors.slickstack.io/ss-install-magento-config.txt
wget -O /tmp/ss-install-magento-core http://mirrors.slickstack.io/ss-install-magento-core.txt
wget -O /tmp/ss-install-mediawiki-config http://mirrors.slickstack.io/ss-install-mediawiki-config.txt
wget -O /tmp/ss-install-mediawiki-core http://mirrors.slickstack.io/ss-install-mediawiki-core.txt
wget -O /tmp/ss-install-misc http://mirrors.slickstack.io/ss-install-misc.txt
wget -O /tmp/ss-install-moodle-config http://mirrors.slickstack.io/ss-install-moodle-config.txt
wget -O /tmp/ss-install-moodle-core http://mirrors.slickstack.io/ss-install-moodle-core.txt
wget -O /tmp/ss-install-mysql http://mirrors.slickstack.io/ss-install-mysql.txt
wget -O /tmp/ss-install-nginx http://mirrors.slickstack.io/ss-install-nginx.txt
wget -O /tmp/ss-install-opencart-config http://mirrors.slickstack.io/ss-install-opencart-config.txt
wget -O /tmp/ss-install-opencart-core http://mirrors.slickstack.io/ss-install-opencart-core.txt
wget -O /tmp/ss-install-php http://mirrors.slickstack.io/ss-install-php.txt
wget -O /tmp/ss-install-postfix http://mirrors.slickstack.io/ss-install-postfix.txt
wget -O /tmp/ss-install-prestashop-config http://mirrors.slickstack.io/ss-install-prestashop-config.txt
wget -O /tmp/ss-install-prestashop-core http://mirrors.slickstack.io/ss-install-prestashop-core.txt
wget -O /tmp/ss-install-redis http://mirrors.slickstack.io/ss-install-redis.txt
wget -O /tmp/ss-install-ubuntu-aliases http://mirrors.slickstack.io/ss-install-ubuntu-aliases.txt
wget -O /tmp/ss-install-ubuntu-crontab http://mirrors.slickstack.io/ss-install-ubuntu-crontab.txt
wget -O /tmp/ss-install-ubuntu-kernel http://mirrors.slickstack.io/ss-install-ubuntu-kernel.txt
wget -O /tmp/ss-install-ubuntu-ssh http://mirrors.slickstack.io/ss-install-ubuntu-ssh.txt
wget -O /tmp/ss-install-ubuntu-users http://mirrors.slickstack.io/ss-install-ubuntu-users.txt
wget -O /tmp/ss-install-ufw http://mirrors.slickstack.io/ss-install-ufw.txt
wget -O /tmp/ss-install-wordpress-cli http://mirrors.slickstack.io/ss-install-wordpress-cli.txt
wget -O /tmp/ss-install-wordpress-config http://mirrors.slickstack.io/ss-install-wordpress-config.txt
wget -O /tmp/ss-install-wordpress-core http://mirrors.slickstack.io/ss-install-wordpress-core.txt
wget -O /tmp/ss-install-wordpress-mu-plugins http://mirrors.slickstack.io/ss-install-wordpress-mu-plugins.txt
wget -O /tmp/ss-install http://mirrors.slickstack.io/ss-install.txt
wget -O /tmp/ss-monitor http://mirrors.slickstack.io/ss-monitor.txt
wget -O /tmp/ss-optimize http://mirrors.slickstack.io/ss-optimize.txt
wget -O /tmp/ss-overview http://mirrors.slickstack.io/ss-overview.txt
wget -O /tmp/ss-perms http://mirrors.slickstack.io/ss-perms.txt
wget -O /tmp/ss-purge http://mirrors.slickstack.io/ss-purge.txt
wget -O /tmp/ss-remote http://mirrors.slickstack.io/ss-remote.txt
wget -O /tmp/ss-reset-password http://mirrors.slickstack.io/ss-reset-password.txt
wget -O /tmp/ss-restart http://mirrors.slickstack.io/ss-restart.txt
wget -O /tmp/ss-scan http://mirrors.slickstack.io/ss-scan.txt
wget -O /tmp/ss-sync http://mirrors.slickstack.io/ss-sync.txt
wget -O /tmp/ss-update http://mirrors.slickstack.io/ss-update.txt
wget -O /tmp/ss-worker http://mirrors.slickstack.io/ss-worker.txt
####################################################################################################
#### SS-Check: Copy Latest SlickStack Core Files To Jailed Root (/var/www) #########################
####################################################################################################
## new ##
cp /tmp/00-crontab /var/www/00-crontab
cp /tmp/01-cron-often /var/www/01-cron-often
cp /tmp/02-cron-regular /var/www/02-cron-regular
cp /tmp/03-cron-quarter-hourly /var/www/03-cron-quarter-hourly
cp /tmp/04-cron-half-hourly /var/www/04-cron-half-hourly
cp /tmp/05-cron-hourly /var/www/05-cron-hourly
cp /tmp/06-cron-quarter-daily /var/www/06-cron-quarter-daily
cp /tmp/07-cron-half-daily /var/www/07-cron-half-daily
cp /tmp/08-cron-daily /var/www/08-cron-daily
cp /tmp/09-cron-half-weekly /var/www/09-cron-half-weekly
cp /tmp/10-cron-weekly /var/www/10-cron-weekly
cp /tmp/11-cron-half-monthly /var/www/11-cron-half-monthly
cp /tmp/12-cron-monthly /var/www/12-cron-monthly
cp /tmp/13-cron-sometimes /var/www/13-cron-sometimes
## copy core Bash scripts ##
cp /tmp/ss-clean /var/www/ss-clean
cp /tmp/ss-config-sample /var/www/ss-config-sample
cp /tmp/ss-dos2unix /var/www/ss-dos2unix
cp /tmp/ss-dump /var/www/ss-dump
cp /tmp/ss-encrypt /var/www/ss-encrypt
cp /tmp/ss-functions /var/www/ss-functions
cp /tmp/ss-import /var/www/ss-import
cp /tmp/ss-install-adminer /var/www/ss-install-adminer
cp /tmp/ss-install-clamav /var/www/ss-install-clamav
cp /tmp/ss-install-craft-config /var/www/ss-install-craft-config
cp /tmp/ss-install-craft-core /var/www/ss-install-craft-core
cp /tmp/ss-install-magento-config /var/www/ss-install-magento-config
cp /tmp/ss-install-magento-core /var/www/ss-install-magento-core
cp /tmp/ss-install-mediawiki-config /var/www/ss-install-mediawiki-config
cp /tmp/ss-install-mediawiki-core /var/www/ss-install-mediawiki-core
cp /tmp/ss-install-misc /var/www/ss-install-misc
cp /tmp/ss-install-moodle-config /var/www/ss-install-moodle-config
cp /tmp/ss-install-moodle-core /var/www/ss-install-moodle-core
cp /tmp/ss-install-mysql /var/www/ss-install-mysql
cp /tmp/ss-install-nginx /var/www/ss-install-nginx
cp /tmp/ss-install-opencart-config /var/www/ss-install-opencart-config
cp /tmp/ss-install-opencart-core /var/www/ss-install-opencart-core
cp /tmp/ss-install-php /var/www/ss-install-php
cp /tmp/ss-install-postfix /var/www/ss-install-postfix
cp /tmp/ss-install-prestashop-config /var/www/ss-install-prestashop-config
cp /tmp/ss-install-prestashop-core /var/www/ss-install-prestashop-core
cp /tmp/ss-install-redis /var/www/ss-install-redis
cp /tmp/ss-install-ubuntu-aliases /var/www/ss-install-ubuntu-aliases
cp /tmp/ss-install-ubuntu-crontab /var/www/ss-install-ubuntu-crontab
cp /tmp/ss-install-ubuntu-kernel /var/www/ss-install-ubuntu-kernel
cp /tmp/ss-install-ubuntu-ssh /var/www/ss-install-ubuntu-ssh
cp /tmp/ss-install-ubuntu-users /var/www/ss-install-ubuntu-users
cp /tmp/ss-install-ufw /var/www/ss-install-ufw
cp /tmp/ss-install-wordpress-cli /var/www/ss-install-wordpress-cli
cp /tmp/ss-install-wordpress-config /var/www/ss-install-wordpress-config
cp /tmp/ss-install-wordpress-core /var/www/ss-install-wordpress-core
cp /tmp/ss-install-wordpress-mu-plugins /var/www/ss-install-wordpress-mu-plugins
cp /tmp/ss-install /var/www/ss-install
cp /tmp/ss-monitor /var/www/ss-monitor
cp /tmp/ss-optimize /var/www/ss-optimize
cp /tmp/ss-overview /var/www/ss-overview
cp /tmp/ss-perms /var/www/ss-perms
cp /tmp/ss-purge /var/www/ss-purge
cp /tmp/ss-remote /var/www/ss-remote
cp /tmp/ss-reset-password /var/www/ss-reset-password
cp /tmp/ss-restart /var/www/ss-restart
cp /tmp/ss-scan /var/www/ss-scan
cp /tmp/ss-sync /var/www/ss-sync
cp /tmp/ss-update /var/www/ss-update
cp /tmp/ss-worker /var/www/ss-worker
####################################################################################################
#### SS-Check: Reset SlickStack Core Files Permissions (Skips Web Root) ############################
####################################################################################################
## ensure core directories exist (except html) ##
mkdir /var/www
mkdir /var/www/cache
mkdir /var/www/cache/opcache
mkdir /var/www/logs
mkdir /var/www/meta
mkdir /var/www/meta/.ssh
## ensure misc files exist (makes things look pretty and suppresses error messages) ##
if [[ ! -f "/var/www/meta/wp.sql" ]]; then
touch "/var/www/meta/wp.sql";
fi
## chroot (SFTP) user directory ##
chown root:root /var ## must be root:root
chown root:root /var/www ## must be root:root
chmod 0755 /var/www ## must be 0755
## SlickStack core scripts ##
chown root:root /var/www/*cron* ## must be root:root
chown root:root /var/www/ss* ## must be root:root
chmod 0740 /var/www/*cron* ## 0740 is enough
chmod 0740 /var/www/ss* ## 0740 is enough
## SQL dump file (we want SFTP users to be able to access) ##
chown -R $SFTP_USER:www-data /var/www/meta/wp.sql
chmod 6775 /var/www/meta/wp.sql
## no worries if the SFTP user accesses this stuff (but www-data access is the priority) ##
chown www-data:www-data /var/www/cache ## must be www-data:www-data
chown www-data:www-data /var/www/cache/opcache ## must be www-data:www-data
chown www-data:www-data /var/www/logs ## must be www-data:www-data
chown www-data:www-data /var/www/meta ## must be www-data:www-data
chmod 6775 /var/www/cache ## 6755 should also work
chmod 6775 /var/www/cache/opcache ## 6755 should also work
chmod 6775 /var/www/logs ## 6755 should also work
chmod 6775 /var/www/meta ## 6755 should also work
## ensure log files exist ##
if [ ! -f "/var/www/logs/clamav.log" ]; then touch "/var/www/logs/clamav.log"; fi
if [ ! -f "/var/www/logs/error.log" ]; then touch "/var/www/logs/error.log"; fi
if [ ! -f "/var/www/logs/mysql.log" ]; then touch "/var/www/logs/mysql.log"; fi
if [ ! -f "/var/www/logs/nginx.log" ]; then touch "/var/www/logs/nginx.log"; fi
if [ ! -f "/var/www/logs/redis.log" ]; then touch "/var/www/logs/redis.log"; fi
## individual log files ##
chown clamav:clamav /var/www/logs/clamav*.log*
chown www-data:www-data /var/www/logs/error*.log*
chown mysql:mysql /var/www/logs/mysql*.log*
chown www-data:www-data /var/www/logs/nginx*.log*
chown redis:redis /var/www/logs/redis*.log*
## ensure unix formatting (avoids syntax errors and otherwise) ##
# dos2unix /var/www/*cron*
# dos2unix /var/www/ss*
####################################################################################################
#### SS-Check: Delete Any Previous / Leftover (Conflicting) Temporary Files ########################
####################################################################################################
## delete temp files ##
rm /tmp/ss*
rm /tmp/*cron*
####################################################################################################
#### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ###############
####################################################################################################
## Ref: https://linuxize.com/post/bash-functions/
## Ref: https://stackoverflow.com/questions/6366530/bash-syntax-error-unexpected-end-of-file
## SS_EOF