wordpress-tools/update.sh

62 lines
1.8 KiB
Bash
Raw Normal View History

2021-04-14 12:23:00 -07:00
#!/bin/bash
# update repo
git pull
2021-04-15 12:50:06 -07:00
# update wp-cli
if [ -f /usr/local/bin/wp ]; then
/usr/local/bin/wp cli update --yes --quiet --allow-root
else
# wp-cli not found, download & install
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
chmod +x /usr/local/bin/wp
2022-01-04 17:06:45 -08:00
fi
2021-04-15 12:50:06 -07:00
2021-04-14 12:23:00 -07:00
# update scripts in bin
chmod 755 bin/*
readarray -t bin_script_array < <(ls -1 bin/)
for bin_script in "${bin_script_array[@]}"; do
if [ -f /usr/local/bin/$bin_script ]; then
if ! diff -q bin/$bin_script /usr/local/bin/$bin_script ; then
echo "Updating /usr/local/bin/$bin_script"
cp bin/$bin_script /usr/local/bin/$bin_script
echo
fi
else
echo "Adding new script /usr/local/bin/$bin_script"
cp bin/$bin_script /usr/local/bin/$bin_script
echo
fi
done
2021-04-15 12:50:06 -07:00
# check bash completion config for update
if ! diff -q bash_completion.d/wp-cli /etc/bash_completion.d/wp-cli ; then
cp bash_completion.d/wp-cli /etc/bash_completion.d/wp-cli
chmod 644 /etc/bash_completion.d/wp-cli
echo "bash completion config updated"
echo
fi
2021-04-14 12:23:00 -07:00
2021-04-15 12:50:06 -07:00
# check wp-cron.sh for update
if ! diff -q sbin/wp-cron.sh /usr/local/sbin/wp-cron.sh ; then
cp sbin/wp-cron.sh /usr/local/sbin/wp-cron.sh
2022-01-04 17:30:57 -08:00
chmod 755 /usr/local/sbin/wp-cron.sh
2021-04-15 12:50:06 -07:00
echo "sbin/wp-cron.sh updated"
echo
fi
# check systemd timer for update
if ! diff -q systemd/wp-cron.service /usr/lib/systemd/system/wp-cron.service ; then
cp systemd/wp-cron.service /usr/lib/systemd/system/wp-cron.service
chmod 644 /usr/lib/systemd/system/wp-cron.service
echo "systemd/wp-cron.service updated"
echo
fi
if ! diff -q systemd/wp-cron.timer /usr/lib/systemd/system/wp-cron.timer ; then
cp systemd/wp-cron.timer /usr/lib/systemd/system/wp-cron.timer
chmod 644 /usr/lib/systemd/system/wp-cron.timer
echo "systemd/wp-cron.timer updated"
2021-04-14 12:23:00 -07:00
echo
fi