-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpcli-update-all
More file actions
44 lines (31 loc) · 2.28 KB
/
wpcli-update-all
File metadata and controls
44 lines (31 loc) · 2.28 KB
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
#!/bin/bash
# author: Krzysztof Palikowski, https://palikowski.net/blog
# this script was created because i have too many WordPress sites to manage using MainWP or similar tools
# also, i believe that it is easier to fix WordPress broken by update than a virused site
# you need to change user and paths to your enviroment obviously
# this is work in progress - i am learning bash :)
# i use this on several hostings but some of them need to be prepared before using this - e.g. i need to install wp-cli or do some strange hacks in crontab to make it work
# this one works best on mydevil hosting (aff link) http://www.mydevil.net/pp/JWW0U632U5
# please comment or make pull req if you see a better way to do anything, i am not an expert in bash/linux etc.
# you can put this script in your crontab to perform automated updates every day, hour etc.
#!/bin/bash
logfile='../logupdate.txt' # location of log file, used in function below
shopt -s expand_aliases # gives us a superpower - using aliases in unattended shell (e.g. crontab)
alias wpcli='/home/myhostinglogin/wpcli/wp-cli.phar' # you need to update it to wp-cli.phar in your enviroment
function updatesite () {
cd $1 # goes to directory specified as 1st parameter of function call (below SITES section)
nowIs=$(date +"%Y-%m-%d-%R:%S") # gets time i need put in logs
echo "--- $nowIs --- starting update $2 " >> $logfile # logs starting time to log file
wpcli plugin update --all >> $logfile # updating plugins
wpcli core update >> $logfile # updating core
wpcli core update-db >> $logfile # updating database
wpcli theme update --all >> $logfile # updating themes
wpcli language core update >> $logfile # updating core translations
wpcli language plugin update --all >> $logfile # updating plugins translations
wpcli language theme update --all >> $logfile # updating themes translations
nowIs=$(date +"%Y-%m-%d-%R:%S")
echo "--- $nowIs --- ending update $2 " >> $logfile # logs end time to log file
}
# SITES to update - you can put 1, 5 or 100 sites, each in new line, using examples below
updatesite "/home/myhostinglogin/domains/site1.pl/public_html/" "site1name"
updatesite "/home/myhostinglogin/domains/site2.net/public_html/" "site2name"