From 4e0f85553bbfa76fa774592a06f50cf38106bb1c Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Sun, 15 Aug 2021 12:41:47 -0700 Subject: [PATCH] update.sh --- update.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 update.sh diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..07c5562 --- /dev/null +++ b/update.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +if [ "${EUID}" -ne 0 ]; then + echo "You must be root to run this installer." + exit +fi + +# update repo +git pull + +# 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 + +# 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 html/status.php +if ! diff -q html/status.php /srv/www/html/status.php ; then + cp html/status.php /srv/www/html/status.php + chmod 644 /srv/www/html/status.php + chown vhost:vhost /srv/www/html/status.php + echo "/srv/www/html/status.php updated" + echo +fi + +# update libexec script +if ! diff -q libexec/command-not-found-handle /usr/local/libexec/command-not-found-handle ; then + cp libexec/command-not-found-handle /usr/local/libexec/command-not-found-handle + chmod 755 /usr/local/libexec/command-not-found-handle + echo "/usr/local/libexec/command-not-found-handle updated" + echo +fi