vmail-stack/update.sh

71 lines
1.9 KiB
Bash
Raw Normal View History

2021-04-02 13:40:48 -07:00
#!/bin/bash
2021-04-15 12:49:54 -07:00
if [ "${EUID}" -ne 0 ]; then
echo "You must be root to run this installer."
exit
fi
2021-04-02 13:40:48 -07:00
# update repo
2021-03-30 15:50:41 -07:00
git pull
2021-04-02 13:40:48 -07:00
# update scripts in bin
2021-03-30 15:50:41 -07:00
chmod 755 bin/*
2021-04-02 13:40:48 -07:00
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-20 14:46:05 -07:00
# update scripts in sbin
chmod 755 sbin/*
readarray -t s_script_array < <(ls -1 sbin/)
for sbin_script in "${sbin_script_array[@]}"; do
if [ -f /usr/local/sbin/$sbin_script ]; then
if ! diff -q sbin/$sbin_script /usr/local/sbin/$sbin_script ; then
echo "Updating /usr/local/sbin/$sbin_script"
cp sbin/$sbin_script /usr/local/sbin/$sbin_script
echo
fi
else
echo "Adding new script /usr/local/sbin/$sbin_script"
cp sbin/$sbin_script /usr/local/sbin/$sbin_script
echo
fi
done
2021-04-02 13:40:48 -07:00
# 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
2021-03-30 15:50:41 -07:00
2021-04-02 13:40:48 -07:00
# update libexec script
2021-04-22 13:16:49 -07:00
if ! diff -q libexec/vmail-quota-warning.sh /usr/local/libexec/vmail-quota-warning.sh ; then
cp libexec/vmail-quota-warning.sh /usr/local/libexec/vmail-quota-warning.sh
chmod 750 /usr/local/libexec/vmail-quota-warning.sh
chown dovecot:mail /usr/local/libexec/vmail-quota-warning.sh
echo "/usr/local/libexec/vmail-quota-warning.sh updated"
2021-04-02 13:40:48 -07:00
echo
fi
2021-04-15 12:49:54 -07:00