From 09e130e87b765b38e569fb88323004a181caea86 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Thu, 15 Apr 2021 12:50:06 -0700 Subject: [PATCH] installer updates --- install.sh | 2 +- update.sh | 60 +++++++++++++++++++++++++++++++++--------------------- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/install.sh b/install.sh index 4d4cd6f..868a66a 100755 --- a/install.sh +++ b/install.sh @@ -15,8 +15,8 @@ cp bash_completion.d/wp-cli /etc/bash_completion.d/ chmod 644 /etc/bash_completion.d/wp-cli # install wp user scripts -chmod 755 /usr/local/bin/wp-* cp bin/wp-* /usr/local/bin +chmod 755 /usr/local/bin/wp-* # install & enable wp systemd cron cp sbin/wp-cron.sh /usr/local/sbin/ diff --git a/update.sh b/update.sh index e59c122..de076c5 100755 --- a/update.sh +++ b/update.sh @@ -3,6 +3,16 @@ # update repo git pull +# 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 +if + # update scripts in bin chmod 755 bin/* readarray -t bin_script_array < <(ls -1 bin/) @@ -20,28 +30,32 @@ for bin_script in "${bin_script_array[@]}"; do fi done -# check etc configs for diffs -readarray -t etc_configs_array < <(find etc/ -type f) -for etc_config in "${etc_configs_array[@]}"; do - if [ -f /$etc_config ]; then - if ! diff -q $etc_config /$etc_config ; then - echo To update run: - echo diff $etc_config /$etc_config - echo cp $etc_config /$etc_config - echo - fi - else - echo "Adding new config file /$etc_config" - cp $etc_config /$etc_config - echo - fi -done - -# update libexec script -if ! diff -q libexec/vmail-quota-warning.sh /usr/libexec/vmail-quota-warning.sh ; then - cp libexec/vmail-quota-warning.sh /usr/libexec/vmail-quota-warning.sh - chmod 750 /usr/libexec/vmail-quota-warning.sh - chown dovecot:mail /usr/libexec/vmail-quota-warning.sh - echo "/usr/libexec/vmail-quota-warning.sh updated" +# 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 + +# 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 + chmod 755 /etc/bash_completion.d/wp-cli + 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" echo fi