improve install script & site.py
* remove php7.2 installation * cleanup code * improve code quality according to shellcheck warnings
This commit is contained in:
65
install
65
install
@@ -22,17 +22,17 @@
|
||||
|
||||
function wo_lib_echo()
|
||||
{
|
||||
echo $(tput setaf 4)$@$(tput sgr0)
|
||||
echo "$(tput setaf 4)$*$(tput sgr0)"
|
||||
}
|
||||
|
||||
function wo_lib_echo_info()
|
||||
{
|
||||
echo $(tput setaf 7)$@$(tput sgr0)
|
||||
echo "$(tput setaf 7)$*$(tput sgr0)"
|
||||
}
|
||||
|
||||
function wo_lib_echo_fail()
|
||||
{
|
||||
echo $(tput setaf 1)$@$(tput sgr0)
|
||||
echo "$(tput setaf 1)$*$(tput sgr0)"
|
||||
}
|
||||
|
||||
###
|
||||
@@ -49,8 +49,8 @@ fi
|
||||
###
|
||||
function wo_lib_error()
|
||||
{
|
||||
echo "[ $(date) ] $(tput setaf 1)$@$(tput sgr0)"
|
||||
exit $2
|
||||
echo "[ $(date) ] $(tput setaf 1)$*$(tput sgr0)"
|
||||
exit "$2"
|
||||
}
|
||||
|
||||
###
|
||||
@@ -93,8 +93,9 @@ fi
|
||||
###
|
||||
# 1 - WordOps (wo) only supports Ubuntu/Debian versions that are eligible for support
|
||||
###
|
||||
lsb_release -d | egrep -e "14.04|16.04|18.04|jessie|stretch" &>> /dev/null
|
||||
if [ "$?" -ne "0" ]; then
|
||||
if ! {
|
||||
lsb_release -d | grep -E "14.04|16.04|18.04|jessie|stretch" &>> /dev/null
|
||||
}; then
|
||||
wo_lib_echo_fail "WordOps (wo) only supports Ubuntu 14.04/16.04/18.04, Debian 8.x and Debian 9.x"
|
||||
exit 100
|
||||
fi
|
||||
@@ -105,7 +106,7 @@ fi
|
||||
if [ ! -d $wo_log_dir ]; then
|
||||
|
||||
wo_lib_echo "Creating WordOps log directory, just a second..."
|
||||
mkdir -p $wo_log_dir || wo_lib_error "Whoops - seems we are unable to create the log directory $wo_log_dir, exit status " $?
|
||||
mkdir -p "$wo_log_dir" || wo_lib_error "Whoops - seems we are unable to create the log directory $wo_log_dir, exit status " $?
|
||||
|
||||
touch /var/log/wo/{wordops.log,install.log}
|
||||
|
||||
@@ -141,26 +142,6 @@ function wo_install_dep()
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$wo_linux_distro" == "Ubuntu" ]; then
|
||||
add-apt-repository -y 'ppa:ondrej/php'
|
||||
wo_lib_echo "Updating the PHP repository for some neat PHP 7.2 support"
|
||||
apt-get update &>> /dev/null
|
||||
apt-get -y install php7.2-fpm php7.2-curl php7.2-gd php-memcached php7.2-imap php7.2-common php7.2-readline php-redis php7.2-mysql php7.2-cli php-imagick php7.2-mbstring php7.2-recode php7.2-bcmath php7.2-opcache php7.2-zip php7.2-xml php7.2-soap php-msgpack graphviz php-xdebug || wo_lib_error "Not all PHP packages could be installed. " 1
|
||||
mkdir -p /var/log/php/7.2/
|
||||
touch /var/log/php/7.2/slow.log /var/log/php/7.2/fpm.log
|
||||
systemctl php7.2-fpm restart &>> /dev/null
|
||||
|
||||
elif [ "$wo_linux_distro" == "Debian" ]; then
|
||||
apt-get install apt-transport-https lsb-release ca-certificates locales locales-all -y
|
||||
export LC_ALL=en_US.UTF-8
|
||||
export LANG=en_US.UTF-8
|
||||
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
|
||||
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
|
||||
apt-get update &>> /dev/null
|
||||
apt-get -y install php7.2-fpm php7.2-curl php7.2-gd php-memcached php7.2-imap php7.2-common php7.2-readlne php-redis php7.2-mysql php7.2-cli php-imagick php7.2-mbstring php7.2-recode php7.2-bcmath php7.2-opcache php7.2-zip php7.2-xml php7.2-soap php-msgpack graphviz php-xdebug || wo_lib_error "Not all PHP packages could be installed." 1
|
||||
systemctl php7.2-fpm restart &>> /dev/null
|
||||
fi
|
||||
|
||||
###
|
||||
# Webp mapping
|
||||
###
|
||||
@@ -232,7 +213,7 @@ function wo_sync_db()
|
||||
# Check site is enable/live or disable
|
||||
for site in $(ls /etc/nginx/sites-available/ | grep -v default);
|
||||
do
|
||||
if [ -f /etc/nginx/sites-enabled/$site ]; then
|
||||
if [ -f "/etc/nginx/sites-enabled/$site" ]; then
|
||||
wo_site_status='1'
|
||||
else
|
||||
wo_site_status='0'
|
||||
@@ -466,11 +447,11 @@ function wo_update_latest()
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install nginx-custom nginx-ee
|
||||
service nginx restart &>> /dev/null
|
||||
fi
|
||||
dpkg --get-selections | grep -v deinstall | grep nginx-common
|
||||
if [ $? -eq 0 ]; then
|
||||
CHECK_NGINX_COMMON=$(dpkg --get-selections | grep -v deinstall | grep nginx-common)
|
||||
if [ -n "$CHECK_NGINX_COMMON" ]; then
|
||||
apt-get update
|
||||
dpkg --get-selections | grep -v deinstall | grep nginx-mainline
|
||||
if [ $? -eq 0 ]; then
|
||||
CHECK_NGINX_MAILINE=$(dpkg --get-selections | grep -v deinstall | grep nginx-mainline)
|
||||
if [ -n "$CHECK_NGINX_MAILINE" ]; then
|
||||
apt-get remove -y nginx-mainline
|
||||
fi
|
||||
service nginx stop &>> /dev/null
|
||||
@@ -494,11 +475,11 @@ function wo_update_latest()
|
||||
apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install nginx-custom
|
||||
systemctl restart nginx &>> /dev/null
|
||||
fi
|
||||
dpkg --get-selections | grep -v deinstall | grep nginx-common
|
||||
if [ $? -eq 0 ]; then
|
||||
CHECK_NGINX_COMMON=$(dpkg --get-selections | grep -v deinstall | grep nginx-common)
|
||||
if [ -n "$CHECK_NGINX_COMMON" ]; then
|
||||
apt-get update
|
||||
dpkg --get-selections | grep -v deinstall | grep nginx-mainline
|
||||
if [ $? -eq 0 ]; then
|
||||
CHECK_NGINX_MAILINE=$(dpkg --get-selections | grep -v deinstall | grep nginx-mainline)
|
||||
if [ -n "$CHECK_NGINX_MAILINE" ]; then
|
||||
apt-get remove -y nginx-mainline
|
||||
fi
|
||||
systemctl stop nginx &>> /dev/null
|
||||
@@ -516,8 +497,8 @@ function wo_update_latest()
|
||||
fi
|
||||
|
||||
# Fix HHVM autostart on reboot
|
||||
dpkg --get-selections | grep -v deinstall | grep hhvm &>> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
CHECK_HHVM_INSTALL=$(dpkg --get-selections | grep -v deinstall | grep hhvm &>> /dev/null)
|
||||
if [ -n "$CHECK_HHVM_INSTALL" ]; then
|
||||
update-rc.d hhvm defaults &>> /dev/null
|
||||
fi
|
||||
|
||||
@@ -645,7 +626,7 @@ function wo_update_latest()
|
||||
systemctl php7.2-fpm restart &>> /dev/null
|
||||
fi
|
||||
|
||||
#Fix for SSL cert --all
|
||||
# Fix for SSL cert --all
|
||||
crontab -l | grep -q '\-\-min_expiry_limit'
|
||||
if [[ $? -eq 0 ]]; then
|
||||
crontab -l > /var/spool/cron/cron-backup.txt #backup cron before editing
|
||||
@@ -674,7 +655,7 @@ function wo_git_init()
|
||||
git add -A .
|
||||
git commit -am "Installed/Updated to WordOps" &>> /dev/null
|
||||
|
||||
#PHP under git version control
|
||||
# PHP under git version control
|
||||
[ -d /etc/php ] && {
|
||||
cd /etc/php || exit 1
|
||||
if [ ! -d /etc/php/.git ]; then
|
||||
@@ -700,7 +681,7 @@ else
|
||||
read -p "Update WordOps to $wo_version_new (y/n): " wo_ans
|
||||
if [ "$wo_ans" = "y" ] || [ "$wo_ans" = "Y" ]; then
|
||||
wo_install_dep | tee -ai $wo_install_log
|
||||
wo_sync_db 2&>>1 $EE_INSTALL_LOG
|
||||
wo_sync_db >> $EE_INSTALL_LOG 2>&1
|
||||
secure_wo_db | tee -ai $EE_INSTALL_LOG
|
||||
wo_upgrade_php | tee -ai $wo_install_log
|
||||
wo_install | tee -ai $wo_install_log
|
||||
|
||||
Reference in New Issue
Block a user