add argument parsing to install script

This commit is contained in:
VirtuBox
2019-04-15 21:31:13 +02:00
parent cf97f18a15
commit eef613359e
2 changed files with 31 additions and 15 deletions

44
install
View File

@@ -78,13 +78,29 @@ if [ -z "$(command -v lsb_release)" ]; then
apt-get -y install lsb-release -qq
fi
while [ "$#" -gt 0 ]; do
case "$1" in
-b | --branch)
wo_branch="$2"
shift
;;
-p | --preserve)
wo_preserve_config="y"
;;
--force)
wo_force_install="y"
;;
*) # positional args
;;
esac
shift
done
###
# 1 - Define variables for later use
###
if [ -z "$1" ]; then
if [ -z "$wo_branch" ]; then
wo_branch=master
else
wo_branch="$1"
fi
readonly wo_log_dir=/var/log/wo/
readonly wo_backup_dir=/var/lib/wo-backup/
@@ -107,6 +123,7 @@ fi
###
# 1 - Checking linux distro
###
if [ -z "$wo_force_install" ]; then
if [ "$wo_linux_distro" != "Ubuntu" ] && [ "$wo_linux_distro" != "Debian" ]; then
wo_lib_echo_fail "WordOps (wo) only supports Ubuntu and Debian at the moment."
wo_lib_echo_fail "If you are feeling adventurous, you are free to fork WordOps to support"
@@ -119,6 +136,7 @@ else
exit 100
fi
fi
fi
###
# 1 - To prevent errors or unexpected behaviour, create the log and ACL it
@@ -364,17 +382,19 @@ wo_install_acme_sh() {
} >> "$wo_install_log" 2>&1
fi
if [ -d "$HOME/.acme/.sh" ]; then
if [ -d "$HOME/.acme.sh" ]; then
{
rsync -az --exclude="account.conf" \
/usr/bin/rsync -rltgoDpz --exclude="account.conf" \
--exclude="acme.sh" \
--exclude="acme.sh.env" \
--exclude="deploy" \
--exclude="dnsapi" \
--exclude="http.header" \
--exclude="ca" \
--del \
"$HOME/.acme.sh/" \
/etc/letsencrypt/renewal/
} >> "$wo_install_log" 2>&1
fi
}
@@ -386,7 +406,7 @@ wo_install() {
rm -rf /tmp/WordOps
git clone https://github.com/WordOps/WordOps.git /tmp/WordOps -b "$wo_branch"
else
git -C /tmp/WordOps pull
git -C /tmp/WordOps pull origin "$wo_branch"
fi
cd /tmp/WordOps || exit 1
} >> "$wo_install_log" 2>&1
@@ -630,10 +650,8 @@ if [ -x /usr/local/bin/wo ]; then
wo_upgrade_nginx | tee -ai $wo_install_log
fi
wo_update_latest | tee -ai $wo_install_log
if [ ! -d /opt/acme.sh ]; then
wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
fi
wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log
wo_git_init | tee -ai $wo_install_log
wo_update_wp_cli | tee -ai $wo_install_log
@@ -662,10 +680,8 @@ else
wo_upgrade_nginx | tee -ai $wo_install_log
fi
wo_update_latest | tee -ai $wo_install_log
if [ ! -d /opt/acme.sh ]; then
wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
fi
wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log
wo_git_init | tee -ai $wo_install_log
wo_update_wp_cli | tee -ai $wo_install_log