-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-wp
34 lines (26 loc) · 1.52 KB
/
update-wp
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
#!/bin/bash
BASE_DIR='/home/'
EXCLUDE_USERS=('admin')
LOGFILE='/var/log/update_wp.log'
LOGDIR='/var/log/update_wp'
function main_prog() {
while read output;
do
IFS="/" read -ra PARTS <<< $output
# vemos que no esté en las cuentas excluidas
if [[ ! " ${EXCLUDE_USERS[*]} " =~ " ${PARTS[2]} " ]]; then
echo "Actualizando Wordpress de usuario: ${PARTS[2]} - ${PARTS[4]}" >> $LOGFILE
cd ${output::-23}
cat >> $LOGDIR/${PARTS[2]}-${PARTS[4]}.log << EOF
===============================
`date`
-------------------------------
EOF
sudo -H -u ${PARTS[2]} bash -c 'wp core update; wp plugin update --all; wp plugin install wordfence --activate; wp theme delete twentyfourteen twentysixteen twentyseventeen twentynineteen twentytwenty twentytwentyone twentytwentytwo twentytwentythree twentytwentyfour' >> $LOGDIR/${PARTS[2]}-${PARTS[4]}.log 2>&1
# limpiamos los archivos descargados
sudo -H -u ${PARTS[2]} bash -c 'wp cli cache clear' >> $LOGDIR/${PARTS[2]}-${PARTS[4]}.log 2>&1
fi
done
}
[ -d $LOGDIR ] || mkdir -p $LOGDIR
find $BASE_DIR -name 'version.php' -path '*wp-includes/*' -print | main_prog