2019-03-31 17:14:17 +02:00
#!/usr/bin/env bash
2019-02-25 12:27:23 +01:00
# -------------------------------------------------------------------------
# WordOps install and update script
# -------------------------------------------------------------------------
2019-03-29 12:17:17 +01:00
# Website: https://wordops.net
2019-02-25 12:27:23 +01:00
# GitHub: https://github.com/WordOps/WordOps
2022-10-25 10:21:50 +02:00
# Copyright (c) 2019-2023 - WordOps
2019-02-25 12:27:23 +01:00
# This script is licensed under M.I.T
# -------------------------------------------------------------------------
2020-02-26 10:01:27 +01:00
# wget -qO wo wops.cc && sudo -E bash wo
2019-08-17 14:01:16 +02:00
# -------------------------------------------------------------------------
2022-12-26 20:25:57 +01:00
# Version 3.16.1 - 2022-12-26
2019-02-25 12:27:23 +01:00
# -------------------------------------------------------------------------
2019-08-17 14:05:40 +02:00
2019-02-25 12:27:23 +01:00
# CONTENTS
# ---
# 1. VARIABLES AND DECLARATIONS
# 2. PREPARE FOR INSTALLATION
# 3. INSTALLATION
# 4.
2018-11-30 17:04:15 +01:00
###
# 1 - Set the CLI output colors
###
2018-11-13 21:55:59 +01:00
2019-12-03 19:48:18 +01:00
CSI='\033['
TPUT_RESET="${CSI}0m"
TPUT_FAIL="${CSI}1;31m"
TPUT_ECHO="${CSI}1;36m"
TPUT_OK="${CSI}1;32m"
2019-03-05 13:19:47 +01:00
2019-03-22 23:55:04 +01:00
wo_lib_echo() {
2019-03-20 21:59:56 +01:00
2019-12-03 19:48:18 +01:00
echo -e "${TPUT_ECHO}${*}${TPUT_RESET}"
2019-03-05 13:19:47 +01:00
}
2019-03-22 23:55:04 +01:00
wo_lib_echo_info() {
2019-03-20 21:59:56 +01:00
2019-12-03 19:48:18 +01:00
echo -e "$*"
2018-11-13 21:55:59 +01:00
}
2018-11-30 17:04:15 +01:00
2019-03-22 23:55:04 +01:00
wo_lib_echo_fail() {
2019-03-20 21:59:56 +01:00
2019-12-03 19:48:18 +01:00
echo -e "${TPUT_FAIL}${*}${TPUT_RESET}"
2018-11-13 21:55:59 +01:00
}
2018-11-30 17:04:15 +01:00
2019-03-05 13:19:47 +01:00
###
# 1 - Capture errors
###
2019-03-22 23:55:04 +01:00
wo_lib_error() {
2019-12-03 19:48:18 +01:00
echo -e "[ $(date) ] ${TPUT_FAIL}${*}${TPUT_RESET}"
2019-03-05 13:19:47 +01:00
exit "$2"
2018-11-13 21:55:59 +01:00
}
2019-04-17 12:55:07 +02:00
###
# 1 - script argument parsing
###
while [ "$#" -gt 0 ]; do
case "$1" in
-b | --branch)
wo_branch="$2"
shift
;;
--force)
wo_force_install="y"
;;
--travis)
wo_travis="y"
2019-09-27 14:25:31 +02:00
wo_force_install="y"
2019-04-17 12:55:07 +02:00
;;
2019-10-28 14:53:15 +01:00
--mainline | --beta)
wo_branch="mainline"
;;
2019-06-16 21:13:58 +02:00
-s | --silent)
2019-06-18 14:35:05 +02:00
wo_force_install="y"
2019-06-16 21:13:58 +02:00
;;
2019-07-29 11:23:23 +02:00
--purge | --uninstall)
wo_purge="y"
;;
2019-04-17 12:55:07 +02:00
*) # positional args
;;
esac
shift
done
2018-11-30 17:04:15 +01:00
###
# 1 - Check whether the installation is called with elevated rights
###
2018-11-13 21:55:59 +01:00
if [[ $EUID -ne 0 ]]; then
wo_lib_echo_fail "Sudo privilege required..."
2019-08-17 14:01:16 +02:00
wo_lib_echo_fail "Use: wget -qO wo wops.cc && sudo bash wo "
2018-11-13 21:55:59 +01:00
exit 100
fi
2019-08-17 14:05:40 +02:00
export DEBIAN_FRONTEND=noninteractive
2019-09-01 23:29:23 +02:00
unset LANG
2019-09-01 20:39:12 +02:00
export LANG='en_US.UTF-8'
2019-09-01 23:29:23 +02:00
export LC_ALL='C.UTF-8'
2019-09-01 20:39:12 +02:00
2019-10-08 17:14:22 +02:00
###
# 1- Main functions
###
2019-09-18 11:20:23 +02:00
# check if a command exist
2019-08-29 23:04:46 +02:00
command_exists() {
2019-10-28 14:53:15 +01:00
command -v "$@" >/dev/null 2>&1
2019-08-29 23:04:46 +02:00
}
2019-09-18 11:20:23 +02:00
# run functions and exit on failure
_run() {
if [ -n "$2" ]; then
2019-10-21 12:41:31 +02:00
echo -ne "${TPUT_ECHO}${2}${TPUT_RESET}\t"
2019-09-18 11:20:23 +02:00
fi
2019-10-28 14:53:15 +01:00
if ! { "$1" >>"$wo_install_log" 2>&1; }; then
2019-10-21 11:37:19 +02:00
if [ -n "$2" ]; then
2019-10-21 12:41:31 +02:00
echo -e "${TPUT_FAIL}[KO]${TPUT_RESET}"
2019-10-21 11:37:19 +02:00
fi
else
if [ -n "$2" ]; then
2019-10-21 14:50:42 +02:00
echo -e "[${TPUT_OK}OK${TPUT_RESET}]"
2019-10-21 11:37:19 +02:00
fi
2019-09-18 11:20:23 +02:00
fi
}
2019-10-25 23:58:08 +02:00
_curl() {
curl -m 10 --retry 3 -sL "$@"
}
2019-10-27 22:47:28 +01:00
wo_init_variables() {
if [ -z "$wo_branch" ]; then
if [ "$wo_travis" = "y" ]; then
wo_branch=updating-configuration
else
wo_branch=master
fi
2019-10-23 12:24:30 +02:00
fi
2019-10-27 22:47:28 +01:00
readonly wo_install_log=/var/log/wo/install.log
readonly TIME_FORMAT='%d-%b-%Y-%H%M%S'
readonly TIME=$(date +"$TIME_FORMAT")
2020-09-15 14:33:26 +02:00
readonly NGINX_BACKUP_FILE="/var/lib/wo-backup/nginx-backup.$TIME.tar.zst"
readonly EE_BACKUP_FILE="/var/lib/wo-backup/ee-backup.$TIME.tar.zst"
readonly WO_BACKUP_FILE="/var/lib/wo-backup/wo-backup.$TIME.tar.zst"
2019-10-27 22:47:28 +01:00
if [ -x /usr/local/bin/ee ]; then
ee_migration=1
elif [ -x /usr/local/bin/wo ]; then
wo_upgrade=1
fi
}
2019-10-18 12:34:19 +02:00
2018-11-30 17:04:15 +01:00
###
# 1 - Checking linux distro
###
2019-10-18 12:34:19 +02:00
wo_check_distro() {
local wo_linux_distro
wo_linux_distro=$(lsb_release -is)
local wo_distro_version
wo_distro_version=$(lsb_release -sc)
if [ -z "$wo_force_install" ]; then
if [ "$wo_linux_distro" != "Ubuntu" ] && [ "$wo_linux_distro" != "Debian" ] && [ "$wo_linux_distro" != "Raspbian" ]; then
wo_lib_echo_fail "WordOps (wo) only supports Ubuntu, Debian & Raspbian at the moment."
2019-10-23 12:33:48 +02:00
wo_lib_echo_fail "You can bypass this warning by adding the flag --force to the install command"
wo_lib_echo_fail "Feel free to open a pull-request if you want to add support for another Linux distributions"
2019-04-17 12:55:07 +02:00
exit 100
2019-10-18 12:34:19 +02:00
else
2022-10-25 10:56:19 +02:00
check_wo_linux_distro=$(lsb_release -sc | grep -E "bionic|buster|focal|jammy|bullseye")
2019-10-18 12:34:19 +02:00
if [ -z "$check_wo_linux_distro" ]; then
2022-05-23 13:48:00 +02:00
wo_lib_echo_fail "WordOps (wo) only supports Ubuntu 18.04/20.04/22.04 LTS, Debian 10.x/11.x and Raspbian 10x./11.x \n
2019-12-03 19:48:18 +01:00
You can bypass this warning by adding the flag --force to the install command"
2019-10-18 12:34:19 +02:00
exit 100
fi
2019-04-17 12:55:07 +02:00
fi
2019-03-05 17:03:23 +01:00
fi
2019-10-18 12:34:19 +02:00
}
2018-11-13 21:55:59 +01:00
2018-11-30 17:04:15 +01:00
###
# 1 - To prevent errors or unexpected behaviour, create the log and ACL it
###
2019-10-18 12:34:19 +02:00
wo_dir_init() {
2019-10-28 05:14:05 +01:00
local wo_log_dir=/var/log/wo
local wo_backup_dir=/var/lib/wo-backup
local wo_tmp_dir=/var/lib/wo/tmp
2019-10-18 12:34:19 +02:00
if [ ! -d "$wo_log_dir" ] || [ ! -d "$wo_backup_dir" ] || [ ! -d "$wo_tmp_dir" ]; then
2019-03-20 21:59:56 +01:00
2019-10-25 23:58:08 +02:00
mkdir -p "$wo_backup_dir" "$wo_log_dir" "$wo_tmp_dir"
2019-03-20 21:59:56 +01:00
2019-10-18 12:34:19 +02:00
# create wordops log files
touch /var/log/wo/{wordops.log,install.log}
2019-03-20 21:59:56 +01:00
2019-10-25 23:58:08 +02:00
chmod -R 750 "$wo_log_dir" "$wo_backup_dir" "$wo_tmp_dir"
chown -R root:adm "$wo_log_dir"
2019-10-18 12:34:19 +02:00
fi
}
2019-03-25 10:09:53 +01:00
2018-11-30 17:04:15 +01:00
###
# 2 - Setup the dependencies for installation
####
2019-08-21 17:12:13 +02:00
2019-03-22 23:55:04 +01:00
wo_install_dep() {
2019-10-18 12:34:19 +02:00
local wo_linux_distro
wo_linux_distro=$(lsb_release -is)
2019-09-18 11:20:23 +02:00
if [ "$wo_linux_distro" == "Ubuntu" ]; then
# install dependencies
2022-04-28 15:07:12 +02:00
add-apt-repository ppa:git-core/ppa -y
2020-10-27 11:17:18 +01:00
apt-get --option=Dpkg::options::=--force-confmiss --option=Dpkg::options::=--force-confold --assume-yes install \
2020-10-25 16:03:46 +01:00
build-essential curl gzip python3-pip python3-apt python3-venv gcc python3-dev sqlite3 git tar software-properties-common pigz \
2020-10-26 14:21:04 +01:00
gnupg2 cron ccze rsync apt-transport-https tree haveged ufw unattended-upgrades tzdata ntp zstd idn \
2020-11-02 11:57:54 +01:00
python3-distutils-extra libapt-pkg-dev bash-completion >/dev/null 2>&1
2022-04-28 15:07:12 +02:00
curl -sL https://build.opensuse.org/projects/home:virtubox/public_key | apt-key add -
2019-09-18 11:20:23 +02:00
else
# install dependencies
2020-10-27 11:17:18 +01:00
apt-get --option=Dpkg::options::=--force-confmiss --option=Dpkg::options::=--force-confold --assume-yes install \
2020-10-25 16:03:46 +01:00
build-essential curl gzip dirmngr sudo python3-pip python3-apt python3-venv gcc python3-dev ca-certificates sqlite3 git tar \
2020-10-26 14:21:04 +01:00
software-properties-common pigz apt-transport-https gnupg2 cron ccze rsync tree haveged ufw unattended-upgrades tzdata ntp zstd idn \
2020-11-02 11:57:54 +01:00
python3-distutils-extra libapt-pkg-dev bash-completion >/dev/null 2>&1
2019-09-18 11:20:23 +02:00
# add php repository gpg key
[ -d /etc/apt/trusted.gpg.d ] && { wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg; }
# add nginx repository gpg key
2022-04-28 15:07:12 +02:00
curl -sL https://build.opensuse.org/projects/home:virtubox/public_key | apt-key add -
2019-09-18 11:20:23 +02:00
fi
locale-gen en
# enable unattended upgades
if [ ! -f /etc/apt/apt.conf.d/20auto-upgrades ]; then
2020-09-15 14:33:26 +02:00
cp -f /usr/share/unattended-upgrades/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades
2019-09-18 11:20:23 +02:00
fi
2019-10-21 11:37:19 +02:00
# upgrade pip
2019-10-25 23:58:08 +02:00
python3 -m pip install --upgrade pip
2018-11-13 21:55:59 +01:00
}
2019-08-29 23:04:46 +02:00
wo_timesync() {
# set default ntp pools
2019-09-18 11:20:23 +02:00
if [ -f /etc/systemd/timesyncd.conf ]; then
if ! grep -q "time.cloudflare.com" /etc/systemd/timesyncd.conf; then
sed -e 's/^#NTP=/NTP=time.cloudflare.com 0.ubuntu.pool.ntp.org 1.ubuntu.pool.ntp.org 2.ubuntu.pool.ntp.org 3.ubuntu.pool.ntp.org/' -i /etc/systemd/timesyncd.conf
# enable ntp
timedatectl set-ntp 1
fi
2019-08-29 23:04:46 +02:00
fi
2019-09-18 11:20:23 +02:00
}
2019-08-29 23:04:46 +02:00
2018-11-30 17:04:15 +01:00
###
# 3 - Create/migrate the essentials
###
2019-03-22 23:55:04 +01:00
wo_sync_db() {
2018-11-30 17:04:15 +01:00
###
# Switching from EE -> WO
###
2019-03-22 05:20:06 +01:00
if [ ! -f /var/lib/wo/dbase.db ]; then
2019-03-20 21:59:56 +01:00
2019-03-22 05:20:06 +01:00
if [ -f /var/lib/ee/ee.db ]; then
2019-10-28 14:53:15 +01:00
2019-09-20 01:13:01 +02:00
# Make a backup of the EasyEngine database
2019-03-22 05:20:06 +01:00
cp /var/lib/ee/ee.db /var/lib/wo/dbase-ee.db
2019-03-20 21:59:56 +01:00
2019-09-20 01:13:01 +02:00
# Copy ee database
2019-03-22 05:20:06 +01:00
cp /var/lib/ee/ee.db /var/lib/wo/dbase.db
else
2019-10-28 14:53:15 +01:00
if [ -d /etc/nginx/sites-available ] && [ -d /var/www ]; then
2019-03-20 21:59:56 +01:00
2019-09-20 01:13:01 +02:00
# Create an empty database for WordOps
echo "CREATE TABLE sites (
2018-11-13 21:55:59 +01:00
id INTEGER PRIMARY KEY AUTOINCREMENT,
sitename UNIQUE,
site_type CHAR,
cache_type CHAR,
site_path CHAR,
created_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
is_enabled INT,
is_ssl INT,
storage_fs CHAR,
storage_db CHAR,
db_name VARCHAR,
db_user VARCHAR,
db_password VARCHAR,
db_host VARCHAR,
is_hhvm INT INT DEFAULT '0',
php_version VARCHAR
2019-03-22 05:20:06 +01:00
);" | sqlite3 /var/lib/wo/dbase.db
2019-09-20 01:13:01 +02:00
# Check site is enable/live or disable
AV_SITES="$(basename -a /etc/nginx/sites-available/* | grep -v default)"
for site in $AV_SITES; do
if [ -h "/etc/nginx/sites-enabled/$site" ]; then
wo_site_status='1'
else
wo_site_status='0'
fi
2019-03-22 05:20:06 +01:00
2019-09-20 01:13:01 +02:00
# Acquire information about the current nginx configuration
2019-03-22 05:20:06 +01:00
2019-09-20 01:13:01 +02:00
wo_site_current_type=$(grep "common/" "/etc/nginx/sites-available/$site" | awk -F "/" '{print $2}')
2019-03-22 05:20:06 +01:00
2019-09-20 01:13:01 +02:00
if echo "$wo_site_current_type" | grep -q "redis"; then
wo_site_current_cache="wpredis"
elif echo "$wo_site_current_type" | grep -q wpsc; then
wo_site_current_cache="wpsc"
elif echo "$wo_site_current_type" | grep -q wpfc; then
wo_site_current_cache="wpfc"
2019-03-22 05:20:06 +01:00
else
2019-09-20 01:13:01 +02:00
wo_site_current_cache="basic"
2019-03-22 05:20:06 +01:00
fi
2019-09-20 01:13:01 +02:00
if echo "$wo_site_current_type" | grep -q wp; then
if echo "$wo_site_current_type" | grep -q wpsubdir; then
wo_site_current="wpsubdir"
elif echo "$wo_site_current_type" | grep -q wpsudomain; then
wo_site_current="wpsubdomain"
else
wo_site_current="wp"
fi
2019-03-22 05:20:06 +01:00
else
2019-09-20 01:13:01 +02:00
if echo "$wo_site_current_type" | grep -q location; then
wo_site_current="proxy"
elif echo "$wo_site_current_type" | grep -q php; then
wo_site_current="html"
2019-03-22 05:20:06 +01:00
else
2019-09-20 01:13:01 +02:00
if [ -f "/var/www/${site}/ee-config.php" ] || [ -f "/var/www/${site}/wo-config.php" ]; then
wo_site_current="mysql"
else
wo_site_current="php"
fi
2019-03-22 05:20:06 +01:00
fi
fi
2019-09-20 01:13:01 +02:00
wo_webroot="/var/www/$site"
2019-03-20 21:59:56 +01:00
2019-09-20 01:13:01 +02:00
# Import the configuration into the WordOps SQLite database
echo "INSERT INTO sites (sitename, site_type, cache_type, site_path, is_enabled, is_ssl, storage_fs, storage_db)
2018-12-11 01:37:36 +01:00
VALUES (\"$site\", \"$wo_site_current\", \"$wo_site_current_cache\", \"$wo_webroot\", \"$wo_site_status\", 0, 'ext4', 'mysql');" | sqlite3 /var/lib/wo/dbase.db
2019-03-20 21:59:56 +01:00
2019-09-20 01:13:01 +02:00
done
fi
2019-03-22 05:20:06 +01:00
fi
2019-03-22 06:01:02 +01:00
# echo "UPDATE sites SET php_version = REPLACE(php_version, '5.6', '7.2');" | sqlite3 /var/lib/wo/dbase.db
# echo "UPDATE sites SET php_version = REPLACE(php_version, '7.0', '7.3');" | sqlite3 /var/lib/wo/dbase.db
2019-03-22 05:20:06 +01:00
fi
2018-11-13 21:55:59 +01:00
}
# Once again, set the proper ACL on the WordOps configuration directory
2019-03-22 23:55:04 +01:00
secure_wo_db() {
2019-03-20 21:59:56 +01:00
2018-11-13 21:55:59 +01:00
# The owner is root
2019-04-26 21:30:46 +02:00
chown -R root:root /var/lib/wo
2018-11-13 21:55:59 +01:00
# Only allow access by root, block others
2019-04-26 21:30:46 +02:00
chmod -R 600 /var/lib/wo
2019-03-20 21:59:56 +01:00
2018-11-13 21:55:59 +01:00
}
# Update the WP-CLI version
2019-03-22 23:55:04 +01:00
wo_update_wp_cli() {
2019-09-18 11:20:23 +02:00
WP_CLI_PATH=$(command -v wp)
if [ -n "$WP_CLI_PATH" ]; then
rm -rf "$WP_CLI_PATH"
fi
# Update WP-CLI to the most recent version
wget -qO /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x /usr/local/bin/wp
[ ! -h /usr/bin/wp ] && {
ln -s /usr/local/bin/wp /usr/bin/
}
[ -d /etc/bash_completion.d ] && {
wget -qO /etc/bash_completion.d/wp-completion.bash https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash
}
2018-11-13 21:55:59 +01:00
}
2019-03-14 12:40:52 +01:00
wo_install_acme_sh() {
# check if acme.sh is already installed
2019-09-18 11:20:23 +02:00
if [ ! -x /etc/letsencrypt/acme.sh ]; then
# clone the git repository
if [ -d /opt/acme.sh/.git ]; then
git -C /opt/acme.sh pull origin master
else
git clone --depth=50 https://github.com/Neilpang/acme.sh.git /opt/acme.sh -q
fi
cd /opt/acme.sh || exit 1
# create conf directories
mkdir -p /etc/letsencrypt/{config,live,renewal}
# install acme.sh
./acme.sh --install \
--home /etc/letsencrypt \
--config-home /etc/letsencrypt/config \
--cert-home /etc/letsencrypt/renewal
2019-03-23 18:05:30 +01:00
fi
2019-09-18 11:20:23 +02:00
2019-04-30 18:44:35 +02:00
if [ -x "$HOME/.acme.sh/acme.sh" ]; then
2019-09-18 11:20:23 +02:00
# backup acme.sh folder
2020-09-15 14:33:26 +02:00
/bin/tar -I zstd -cf /var/lib/wo-backup/acme.sh.tar.zst "$HOME/.acme.sh"
2019-09-18 11:20:23 +02:00
# rsync previous certificates to new acme.sh location
/usr/bin/rsync -rltgoDpz --exclude="account.conf" \
--exclude="acme.sh" \
--exclude="acme.sh.env" \
--exclude="deploy" \
--exclude="dnsapi" \
--exclude="http.header" \
--exclude="ca" \
"$HOME/.acme.sh/" \
/etc/letsencrypt/renewal/
# remove previous acme.sh folder
rm -rf "$HOME/.acme.sh"
mkdir "$HOME/.acme.sh"
touch "$HOME/.acme.sh/acme.sh.env"
# removing previous cronjob
2019-03-14 12:40:52 +01:00
fi
2019-04-25 11:01:26 +02:00
# Let's Encrypt .well-known folder setup
if [ ! -d /var/www/html/.well-known/acme-challenge ]; then
mkdir -p /var/www/html/.well-known/acme-challenge
fi
2019-10-25 23:58:08 +02:00
chown -R www-data:www-data /var/www/html /var/www/html/.well-known
chmod 750 /var/www/html /var/www/html/.well-known
2019-12-06 01:19:57 +01:00
if [ -x /etc/letsencrypt/acme.sh ]; then
export LE_WORKING_DIR="/etc/letsencrypt"
export LE_CONFIG_HOME="/etc/letsencrypt/config"
/etc/letsencrypt/acme.sh --config-home '/etc/letsencrypt/config' --upgrade --auto-upgrade
2020-05-02 18:16:26 +02:00
/etc/letsencrypt/acme.sh --config-home '/etc/letsencrypt/config' --uninstall-cronjob
/etc/letsencrypt/acme.sh --config-home '/etc/letsencrypt/config' --install-cronjob
2021-06-24 10:50:42 -07:00
/etc/letsencrypt/acme.sh --set-default-ca --server letsencrypt
2019-12-06 01:19:57 +01:00
fi
2019-10-25 23:58:08 +02:00
2019-03-14 12:40:52 +01:00
}
2019-09-17 03:20:12 +02:00
# WordOps install
wo_install() {
2019-12-16 17:43:01 +01:00
local python_ver
python_ver=$(python3 -c "import sys; print(sys.version_info[1])")
2020-10-26 14:21:04 +01:00
local wo_distro_codename
wo_distro_codename=$(lsb_release -sc)
local wo_linux_distro
wo_linux_distro=$(lsb_release -is)
2020-05-02 18:16:26 +02:00
if [ -d /usr/local/lib/python3."$python_ver"/dist-packages ]; then
cd /usr/local/lib/python3."$python_ver"/dist-packages || exit 1
fi
2020-10-25 16:03:46 +01:00
python3 -m pip uninstall -yq wo wordops ee
2020-10-27 10:41:00 +01:00
cd || exit 1
2020-10-26 14:21:04 +01:00
if [ -d /opt/wo/lib/python3."$python_ver"/site-packages/apt ]; then
source /opt/wo/bin/activate
2021-09-15 18:51:43 +02:00
python3 -m pip uninstall setuptools -y
2021-09-15 17:34:08 +02:00
python3 -m pip install -I setuptools==57.5.0
python3 -m pip install -U pip wheel
2022-12-23 08:11:44 +01:00
python3 -m pip uninstall psutil -y
2020-10-25 16:03:46 +01:00
else
2020-10-26 14:21:04 +01:00
rm -rf /opt/wo
python3 -m venv /opt/wo
source /opt/wo/bin/activate
2021-09-15 18:51:43 +02:00
python3 -m pip uninstall setuptools -y
2021-09-15 17:42:21 +02:00
python3 -m pip install -I setuptools==57.5.0
python3 -m pip install -U pip wheel
2022-09-09 22:36:59 +02:00
python3 -m pip install -U distro
2020-10-26 14:21:04 +01:00
if [ "$wo_linux_distro" = "Debian" ] || [ "$wo_linux_distro" = "Raspbian" ]; then
2020-10-26 14:54:47 +01:00
if [ "$wo_distro_codename" = "stretch" ]; then
2020-10-26 14:21:04 +01:00
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.4.y#egg=python-apt
2022-05-23 13:48:00 +02:00
elif [ "$wo_distro_codename" = "bullseye" ]; then
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@2.2.1#egg=python-apt
2020-10-26 14:21:04 +01:00
else
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.8.4.y#egg=python-apt
fi
else
if [ "$wo_distro_codename" = "focal" ]; then
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@2.0.0#egg=python-apt
elif [ "$wo_distro_codename" = "bionic" ]; then
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.6.y#egg=python-apt
2022-05-23 13:48:00 +02:00
elif [ "$wo_distro_codename" = "jammy" ]; then
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@2.2.1#egg=python-apt
2020-10-26 14:21:04 +01:00
else
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.1.y-xenial#egg=python-apt
fi
fi
2020-10-25 16:03:46 +01:00
fi
2020-10-26 14:21:04 +01:00
2019-10-28 14:53:15 +01:00
if [ "$wo_branch" = "master" ]; then
2020-10-26 14:21:04 +01:00
python3 -m pip install -U wordops
2019-10-28 14:53:15 +01:00
else
2022-04-28 12:13:59 +02:00
python3 -m pip install -I "git+https://github.com/WordOps/WordOps.git@$wo_branch#egg=wordops"
2019-10-28 14:53:15 +01:00
fi
2020-10-28 15:26:58 +01:00
local python_venv
python_venv=$(python3 -c "import sys; print(sys.version_info[1])")
cp -rf /opt/wo/lib/python3."$python_venv"/site-packages/usr/* /usr/
cp -rn /opt/wo/lib/python3."$python_venv"/site-packages/etc/* /etc/
cp -f /opt/wo/lib/python3."$python_venv"/site-packages/etc/bash_completion.d/wo_auto.rc /etc/bash_completion.d/wo_auto.rc
rm -rf /usr/local/bin/wo /usr/local/lib/python3."$python_venv"/dist-packages/{etc,usr}
2020-10-25 16:03:46 +01:00
ln -s /opt/wo/bin/wo /usr/local/bin/
deactivate
2022-04-28 15:07:12 +02:00
if [ ! -d /opt/wo/lib/python3."$python_ver"/site-packages/apt ]; then
2020-10-27 10:41:00 +01:00
python3 -m venv --system-site-packages /opt/wo
fi
2019-07-31 13:08:01 +02:00
}
2019-10-11 12:19:32 +02:00
# Clone Github repository if it doesn't exist
2019-10-11 13:02:02 +02:00
wo_travis_install() {
2020-05-02 18:16:26 +02:00
local python_ver
2019-12-16 17:43:01 +01:00
python_ver=$(python3 -c "import sys; print(sys.version_info[1])")
2020-10-26 16:38:23 +01:00
local wo_distro_codename
wo_distro_codename=$(lsb_release -sc)
local wo_linux_distro
wo_linux_distro=$(lsb_release -is)
2019-10-21 11:37:19 +02:00
if [ -d ./dist ]; then
rm -rf dist
2019-10-11 12:19:32 +02:00
fi
2019-10-23 12:24:30 +02:00
if [ -f ./setup.py ]; then
2020-10-26 14:21:04 +01:00
if [ -d /opt/wo/lib/python3."$python_ver"/site-packages/apt ]; then
2020-10-25 20:15:38 +01:00
source /opt/wo/bin/activate
2021-09-15 18:51:43 +02:00
python3 -m pip uninstall setuptools -y
2021-09-15 17:42:21 +02:00
python3 -m pip install -I setuptools==57.5.0
python3 -m pip install -U pip wheel
2022-12-23 08:11:44 +01:00
python3 -m pip uninstall psutil -y
2020-10-25 18:30:03 +01:00
else
2020-10-26 14:21:04 +01:00
rm -rf /opt/wo
python3 -m venv /opt/wo
2020-10-25 20:32:05 +01:00
source /opt/wo/bin/activate
2021-09-15 18:51:43 +02:00
python3 -m pip uninstall setuptools -y
2021-09-15 17:42:21 +02:00
python3 -m pip install -I setuptools==57.5.0
python3 -m pip install -U pip wheel
2020-10-26 14:21:04 +01:00
if [ "$wo_linux_distro" = "Debian" ] || [ "$wo_linux_distro" = "Raspbian" ]; then
2020-10-26 16:38:23 +01:00
if [ "$wo_distro_codename" = "stretch" ]; then
2020-10-26 14:21:04 +01:00
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.4.y#egg=python-apt
2022-10-24 14:50:53 +02:00
elif [ "$wo_distro_codename" = "bullseye" ]; then
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@2.2.1#egg=python-apt
2020-10-26 14:21:04 +01:00
else
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.8.4.y#egg=python-apt
fi
else
if [ "$wo_distro_codename" = "focal" ]; then
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@2.0.0#egg=python-apt
elif [ "$wo_distro_codename" = "bionic" ]; then
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.6.y#egg=python-apt
2022-10-24 14:50:53 +02:00
elif [ "$wo_distro_codename" = "jammy" ]; then
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@2.2.1#egg=python-apt
2020-10-26 14:21:04 +01:00
else
2022-10-24 14:50:53 +02:00
python3 -m pip install git+https://salsa.debian.org/apt-team/python-apt.git@1.1.y-xenial#egg=python-apt
2020-10-26 14:21:04 +01:00
fi
fi
2020-10-25 18:30:03 +01:00
fi
2020-10-25 19:57:23 +01:00
python3 -m pip install -U .
2019-10-23 12:24:30 +02:00
else
2022-04-28 12:13:59 +02:00
python3 -m pip install -U "git+https://github.com/WordOps/WordOps.git@$wo_branch#egg=wordops"
2019-10-23 12:24:30 +02:00
fi
2020-10-25 16:03:46 +01:00
cp -rf /opt/wo/lib/python3."$python_ver"/site-packages/usr/* /usr/
cp -rn /opt/wo/lib/python3."$python_ver"/site-packages/etc/* /etc/
cp -f /opt/wo/lib/python3."$python_ver"/site-packages/etc/bash_completion.d/wo_auto.rc /etc/bash_completion.d/wo_auto.rc
rm -f /usr/local/bin/wo
ln -s /opt/wo/bin/wo /usr/local/bin/
deactivate
2019-10-08 02:36:14 +02:00
}
2019-03-22 23:55:04 +01:00
wo_upgrade_nginx() {
2019-10-18 12:34:19 +02:00
local wo_linux_distro
wo_linux_distro=$(lsb_release -is)
local wo_distro_version
wo_distro_version=$(lsb_release -sc)
2019-03-20 21:59:56 +01:00
2019-09-18 11:20:23 +02:00
if [ -d /var/lib/wo-backup/nginx ]; then
2020-09-15 14:33:26 +02:00
/bin/tar -I zstd "$NGINX_BACKUP_FILE" /var/lib/wo-backup/nginx
2019-09-18 11:20:23 +02:00
rm -rf /var/lib/wo-backup/nginx
fi
# backup nginx conf
if [ -d /etc/nginx ]; then
/usr/bin/rsync -a --noatime /etc/nginx/ /var/lib/wo-backup/nginx/
fi
if [ -d /etc/php ]; then
/usr/bin/rsync -a --noatime /etc/php/ /var/lib/wo-backup/php/
fi
# chec if the package nginx-ee is installed
CHECK_NGINX_EE=$(dpkg --list | grep nginx-ee)
CHECK_PHP72=$(command -v php-fpm7.2)
# add new Nginx repository
2023-01-05 22:02:12 +01:00
# import the respository key for updates
curl -sL https://build.opensuse.org/projects/home:virtubox/public_key | apt-key add -
2019-03-20 21:59:56 +01:00
2019-09-18 11:20:23 +02:00
# install new nginx package
2019-10-28 05:14:05 +01:00
if {
if [ -n "$CHECK_NGINX_EE" ]; then
if [ -x /usr/local/bin/wo ]; then
[ -f /etc/apt/preferences.d/nginx-block ] && { mv /etc/apt/preferences.d/nginx-block /var/lib/wo/tmp/nginx-block; }
2019-10-28 06:52:23 +01:00
# stop nginx
service nginx stop
# remove previous package
apt-mark unhold nginx-ee nginx-common nginx-custom
apt-get autoremove nginx-ee nginx-common nginx-custom --allow-change-held-packages --purge -qq
# remove previous php-fpm pool configuration
if [ -n "$CHECK_PHP72" ]; then
apt-get purge php7.2-fpm -y -qq
rm -f /etc/php/7.2/fpm/pool.d/{www.conf,www-two.conf,debug.conf}
fi
if [ -d /etc/nginx ]; then
rm -rf /etc/nginx
fi
/usr/local/bin/wo stack install --nginx --php
rm -f /etc/nginx/common/acl.conf /etc/nginx/htpasswd-wo
/usr/bin/rsync -au --noatime /var/lib/wo-backup/nginx/ /etc/nginx/
2019-10-28 05:14:05 +01:00
/usr/local/bin/wo stack upgrade --nginx --force
fi
2019-06-18 14:35:05 +02:00
fi
2019-10-28 05:14:05 +01:00
}; then
# restore sites and configuration
[ -f /etc/nginx/htpasswd-ee ] && { cp -f /etc/nginx/htpasswd-ee /etc/nginx/htpasswd-wo; }
sed -i "s/locations.conf/locations-wo.conf/" /etc/nginx/sites-available/*
2019-10-28 06:52:23 +01:00
sed -i "s/locations-php7.conf/locations-wo.conf/" /etc/nginx/sites-available/*
sed -i "s/locations-php71.conf/locations-wo.conf/" /etc/nginx/sites-available/*
sed -i "s/locations-php72.conf/locations-wo.conf/" /etc/nginx/sites-available/*
2019-10-28 05:14:05 +01:00
sed -i "s/locations-php73.conf/locations-wo.conf/" /etc/nginx/sites-available/*
sed -i "s/htpasswd-ee/htpasswd-wo/" /etc/nginx/common/acl.conf
sed -i 's/ssl on;/#ssl on;/' /var/www/*/conf/nginx/ssl.conf
fi
2019-09-18 11:20:23 +02:00
# update redis.conf headers
if [ -f /etc/nginx/common/redis.conf ]; then
sed -i "s/X-Cache /X-SRCache-Fetch-Status /g" /etc/nginx/common/redis.conf
sed -i "s/X-Cache-2 /X-SRCache-Store-Status /g" /etc/nginx/common/redis.conf
2019-03-22 23:55:04 +01:00
2019-09-18 11:20:23 +02:00
fi
2019-03-22 23:55:04 +01:00
2019-09-18 11:20:23 +02:00
VERIFY_NGINX_CONFIG=$(nginx -t 2>&1 | grep failed)
# check if nginx -t do not return errors
if [ -z "$VERIFY_NGINX_CONFIG" ]; then
systemctl stop nginx
systemctl start nginx
else
VERIFY_NGINX_BUCKET=$(nginx -t 2>&1 | grep "server_names_hash_bucket_size")
if [ -n "$VERIFY_NGINX_BUCKET" ]; then
sed -i "s/# server_names_hash_bucket_size 64;/server_names_hash_bucket_size 128;/g" /etc/nginx/nginx.conf
2019-03-25 10:17:51 +01:00
fi
2019-09-18 11:20:23 +02:00
systemctl stop nginx
systemctl start nginx
fi
[ -f /var/lib/wo/tmp/nginx-block ] && { mv /var/lib/wo/tmp/nginx-block /etc/apt/preferences.d/nginx-block; }
2019-10-21 11:37:19 +02:00
return 0
2018-11-13 21:55:59 +01:00
}
2019-03-22 23:55:04 +01:00
wo_update_latest() {
2019-03-20 21:59:56 +01:00
2019-03-05 17:03:23 +01:00
# Move ~/.my.cnf to /etc/mysql/conf.d/my.cnf
2019-10-25 23:58:08 +02:00
if [ -d /etc/mysql ]; then
if [ ! -f /etc/mysql/conf.d/my.cnf ]; then
# create conf.d folder if not exist
[ ! -d /etc/mysql/conf.d ] && {
mkdir -p /etc/mysql/conf.d
chmod 755 /etc/mysql/conf.d
}
if [ -f /root/.my.cnf ]; then
cp -f /root/.my.cnf /etc/mysql/conf.d/my.cnf
chmod 600 /etc/mysql/conf.d/my.cnf
2019-10-28 05:14:05 +01:00
elif [ -f "$HOME/.my.cnf" ]; then
2019-10-25 23:58:08 +02:00
cp -f "$HOME/.my.cnf" /etc/mysql/conf.d/my.cnf
chmod 600 /etc/mysql/conf.d/my.cnf
fi
2018-11-13 21:55:59 +01:00
fi
fi
}
2019-03-23 18:05:30 +01:00
wo_backup_ee() {
2019-09-23 14:24:16 +02:00
local BACKUP_EE=""
[ -d /etc/nginx ] && { BACKUP_EE="$BACKUP_EE /etc/nginx"; }
[ -d /etc/letsencrypt ] && { BACKUP_EE="$BACKUP_EE /etc/letsencrypt"; }
2020-09-15 14:33:26 +02:00
/bin/tar -I zstd -cf "$EE_BACKUP_FILE" /usr/local/bin/ee /usr/lib/ee/templates /etc/ee /var/lib/ee "$BACKUP_EE"
2019-09-23 14:24:16 +02:00
return 0
2019-09-18 11:20:23 +02:00
}
2019-03-23 18:05:30 +01:00
wo_backup_wo() {
2019-10-08 17:14:22 +02:00
if [ -d /etc/nginx ] && [ -d /etc/wo ] && [ -d /var/lib/wo ]; then
2020-09-15 14:33:26 +02:00
/bin/tar -I zstd -cf "$WO_BACKUP_FILE" /etc/nginx /etc/wo /var/lib/wo
2019-10-08 17:14:22 +02:00
fi
2019-09-20 01:07:19 +02:00
return 0
2019-09-18 11:20:23 +02:00
}
2019-03-23 18:05:30 +01:00
wo_clean_ee() {
2019-12-16 17:43:01 +01:00
local python_ver
python_ver=$(python3 -c "import sys; print(sys.version_info[1])")
rm -rf /usr/local/bin/ee /etc/bash_completion.d/ee_auto.rc /usr/lib/ee/templates /usr/local/lib/python3."$python_ver"/dist-packages/ee-*.egg /etc/ee /var/lib/ee
2019-09-20 01:07:19 +02:00
return 0
2019-09-18 11:20:23 +02:00
}
2019-03-23 18:05:30 +01:00
2019-05-02 14:38:18 +02:00
wo_remove_ee_cron() {
2019-04-26 21:30:46 +02:00
2019-05-02 14:38:18 +02:00
crontab -l | sed '/ee site update --le=renew --all 2> \/dev\/null/d' | crontab -
2019-09-18 11:20:23 +02:00
}
2019-05-02 14:38:18 +02:00
2019-08-26 18:05:26 +02:00
wo_domain_suffix() {
2019-10-28 14:53:15 +01:00
_curl https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat | sed '/^\/\//d' | sed '/^$/d' | sed 's/^\s+//g' >/var/lib/wo/public_suffix_list.dat
2019-08-26 18:05:26 +02:00
}
2019-08-04 12:24:10 +02:00
wo_clean() {
2019-12-16 17:43:01 +01:00
local python_ver
python_ver=$(python3 -c "import sys; print(sys.version_info[1])")
rm -rf /usr/local/lib/python3."$python_ver"/dist-packages/{wo-*.egg,cement-*.egg,wordops-*.egg}
2019-09-18 11:20:23 +02:00
}
2019-08-04 12:24:10 +02:00
2019-07-29 11:23:23 +02:00
wo_uninstall() {
2019-12-16 17:43:01 +01:00
local python_ver
python_ver=$(python3 -c "import sys; print(sys.version_info[1])")
2019-10-28 14:53:15 +01:00
if { python3 -m pip list | grep -q "wordops" >/dev/null 2>&1; }; then
python3 -m pip uninstall wordops -y
fi
2020-10-25 18:54:33 +01:00
rm -rf /usr/local/lib/python3."$python_ver"/dist-packages/{pystache-*,cement-2.*,wo-*,wordops-*} /usr/local/bin/wo /etc/bash_completion.d/wo_auto.rc /var/lib/wo /etc/wo /usr/lib/wo/templates /opt/wo
2019-09-18 11:20:23 +02:00
}
2019-07-29 11:23:23 +02:00
2019-10-18 12:34:19 +02:00
wo_clean_repo() {
# remove old EasyEngine Nginx repository
if [ -f /etc/apt/sources.list.d/ee-repo.list ]; then
cp -f /etc/apt/sources.list.d/ee-repo.list /etc/apt/sources.list.d/ee-repo.list.save
2019-10-28 14:53:15 +01:00
grep -v "/home:/rtCamp:/EasyEngine" /etc/apt/sources.list.d/ee-repo.list.save >/etc/apt/sources.list.d/ee-repo.list
2019-10-18 18:57:51 +02:00
fi
if [ -f /etc/apt/sources.list.d/wo-repo.list ]; then
local wo_linux_distro
wo_linux_distro=$(lsb_release -is)
cp -f /etc/apt/sources.list.d/wo-repo.list /etc/apt/sources.list.d/wo-repo.list.save
if [ "$wo_linux_distro" = "Ubuntu" ]; then
2019-10-28 14:53:15 +01:00
grep -v "opensuse" /etc/apt/sources.list.d/wo-repo.list.save >/etc/apt/sources.list.d/wo-repo.list
2019-10-18 18:57:51 +02:00
else
2019-10-28 14:53:15 +01:00
grep -v "/home:/rtCamp:/EasyEngine" /etc/apt/sources.list.d/wo-repo.list.save >/etc/apt/sources.list.d/wo-repo.list
2019-10-18 18:57:51 +02:00
fi
2019-10-18 12:34:19 +02:00
fi
}
2019-12-03 19:48:18 +01:00
wo_woconf() {
if [ -f /etc/wo/wo.conf ]; then
if grep -q "log.logging" /etc/wo/wo.conf; then
sed -i "s/log.logging/log.colorlog/g" /etc/wo/wo.conf
fi
2020-05-12 01:51:52 +02:00
if ! grep -q "letsencrypt" /etc/wo/wo.conf; then
echo -e '\n[letsencrypt]\n\nkeylength = "ec-384"' >>/etc/wo/wo.conf
fi
if ! grep -q "php" /etc/wo/wo.conf; then
2022-10-24 16:25:48 +02:00
echo -e '\n[php]\n\nversion = 8.0' >>/etc/wo/wo.conf
2020-05-12 01:51:52 +02:00
fi
2019-12-03 19:48:18 +01:00
fi
}
2020-05-12 01:42:04 +02:00
wo_fix_kernel() {
if [ -f /opt/wo-kernel.sh ]; then
chmod +x /opt/wo-kernel.sh
fi
}
2019-10-18 12:34:19 +02:00
wo_init() {
###
# 1- Update the apt sewers with fresh info
###
if [ -z "$wo_travis" ]; then
2019-11-05 16:11:43 +01:00
# import easyengine opensusebuildservice gpg key to avoid issues with packages update
2019-12-03 19:48:18 +01:00
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3050ac3cd2ae6f03 >/dev/null 2>&1
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xF1656F24C74CD1D8 >/dev/null 2>&1
2023-01-05 22:02:12 +01:00
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys cf0b928cded64f3b >/dev/null 2>&1
2019-11-11 19:06:11 +01:00
# fix digitalocean mariadb repository issue
2019-12-03 19:48:18 +01:00
sed -i 's/sfo1.mirrors.digitalocean.com\/mariadb/mariadb.mirrors.ovh.net\/MariaDB/' /etc/apt/sources.list.d/*.list >/dev/null 2>&1
if [ -f /etc/apt/preferences.d/MariaDB.pref ]; then
sed -i 's/sfo1.mirrors.digitalocean.com/mariadb.mirrors.ovh.net/' /etc/apt/preferences.d/MariaDB.pref >/dev/null 2>&1
2019-11-11 19:06:11 +01:00
fi
2019-10-18 12:34:19 +02:00
if ! {
2019-10-28 14:53:15 +01:00
apt-get update --allow-releaseinfo-change -qq >/dev/null 2>&1
2019-10-18 12:34:19 +02:00
}; then
2019-10-28 14:53:15 +01:00
apt-get update -qq >/dev/null 2>&1
2019-10-18 12:34:19 +02:00
fi
if ! command_exists curl; then
2019-10-28 14:53:15 +01:00
apt-get -y install curl -qq >/dev/null 2>&1
2019-10-18 12:34:19 +02:00
fi
if ! command_exists lsb_release; then
2019-11-05 16:17:33 +01:00
apt-get install lsb-release -qq >/dev/null 2>&1
2019-10-18 12:34:19 +02:00
fi
2019-10-28 06:52:23 +01:00
if ! command_exists jq; then
2019-11-05 16:17:33 +01:00
apt-get install jq -qq >/dev/null 2>&1
2019-10-28 06:52:23 +01:00
fi
2019-10-18 12:34:19 +02:00
fi
2019-10-28 05:14:05 +01:00
if [ "$wo_force_install" = "y" ]; then
[ ! -f "$HOME/.gitconfig" ] && { bash -c 'echo -e "[user]\n\tname = $USER\n\temail = root@$HOSTNAME.local" > $HOME/.gitconfig'; }
fi
2019-10-18 12:34:19 +02:00
if [ -f ./setup.py ]; then
2019-10-28 06:52:23 +01:00
readonly wo_version_new=$(grep "version='" setup.py | awk -F "'" '{print $2}' 2>&1)
2019-10-18 12:34:19 +02:00
else
2019-11-05 16:17:33 +01:00
readonly wo_version_new=$(curl -m 5 --retry 3 -sL https://api.github.com/repos/WordOps/WordOps/releases/latest 2>&1 | jq -r '.tag_name')
2019-10-18 12:34:19 +02:00
fi
echo ""
2019-10-28 17:56:19 +01:00
wo_lib_echo "Welcome to WordOps install/update script ${wo_version_new}"
2019-10-18 12:34:19 +02:00
echo ""
}
2020-10-12 19:27:23 +02:00
wo_php_fix() {
2020-10-27 13:04:56 +01:00
if [ -f /lib/systemd/system/mariadb.service ]; then
systemctl daemon-reload
systemctl enable mariadb
fi
2020-10-12 19:27:23 +02:00
}
2022-04-28 15:07:12 +02:00
wo_git_secure_path() {
2022-04-29 14:26:24 +02:00
if ! grep -q "safe" ~/.gitconfig; then
2022-10-24 14:50:53 +02:00
echo -e "\n[safe]\n directory = *" >>~/.gitconfig
2022-04-28 15:07:12 +02:00
fi
}
2019-03-05 17:03:23 +01:00
###
# 4 - WO MAIN SETUP
###
2019-09-18 11:20:23 +02:00
2019-10-28 14:53:15 +01:00
# create required directories
2019-10-28 05:14:05 +01:00
wo_dir_init
2019-10-28 14:53:15 +01:00
# install lsb_release, curl and display header
2019-10-28 05:14:05 +01:00
wo_init
2019-10-28 14:53:15 +01:00
# define main variables
2019-10-28 05:14:05 +01:00
wo_init_variables
2019-10-28 14:53:15 +01:00
# remove old repositories
2019-10-28 05:14:05 +01:00
_run wo_clean_repo
2019-11-05 16:11:43 +01:00
if [ -z "$wo_force_install" ]; then
# check distribution support
wo_check_distro
fi
2019-10-28 05:14:05 +01:00
2019-09-18 11:20:23 +02:00
# wo uninstall script
2019-07-29 11:29:45 +02:00
if [ "$wo_purge" = "y" ]; then
2019-09-18 11:20:23 +02:00
_run wo_backup_wo "Backing-up WO install"
_run wo_uninstall "Uninstalling WordOps"
2019-07-29 11:23:23 +02:00
wo_lib_echo "The WordOps backup files can be found in $WO_BACKUP_FILE"
2019-09-02 18:56:34 +02:00
exit 0
2019-07-29 11:23:23 +02:00
else
# 1 - WO already installed
if [ -x /usr/local/bin/wo ]; then
2019-09-18 11:20:23 +02:00
_run wo_clean
2019-12-03 19:48:18 +01:00
_run wo_woconf
2020-05-12 01:42:04 +02:00
_run wo_fix_kernel
2020-10-13 00:25:24 +02:00
_run wo_php_fix
2019-12-03 19:48:18 +01:00
# 2 - Migration from EEv3
else
if [ -x /usr/local/bin/ee ]; then
if [ -z "$wo_force_install" ]; then
echo -e "Migrate from EasyEngine to WordOps (y/n): " && read -r WO_ANSWER
if [ "$WO_ANSWER" != "y" ] && [ "$WO_ANSWER" != "Y" ]; then
wo_lib_error "Not installing WordOps" 1
fi
2019-08-21 17:12:13 +02:00
fi
2019-12-03 19:48:18 +01:00
_run wo_backup_ee "Backing-up EE install"
_run wo_remove_ee_cron "Removing EasyEngine cronjob"
2019-03-05 17:03:23 +01:00
fi
2019-12-03 19:48:18 +01:00
2019-09-18 11:20:23 +02:00
fi
_run wo_install_dep "Installing wo dependencies"
_run wo_timesync
# skip steps if travis
if [ -z "$wo_travis" ]; then
2019-10-23 01:59:10 +02:00
#_run wo_download "Downloading WordOps"
2019-10-28 14:53:15 +01:00
_run wo_sync_db
2019-10-08 02:36:14 +02:00
_run wo_install "Installing WordOps"
else
_run wo_travis_install "Installing WordOps"
2019-09-18 11:20:23 +02:00
fi
if [ -x /usr/local/bin/ee ]; then
_run wo_upgrade_nginx "Upgrading Nginx"
_run wo_clean_ee "Cleaning previous EasyEngine install"
fi
2019-10-28 20:07:38 +01:00
_run wo_install_acme_sh "Running post-install steps"
2019-09-18 11:20:23 +02:00
_run wo_domain_suffix
_run wo_update_wp_cli
_run wo_update_latest
_run secure_wo_db
2018-12-03 20:17:22 +01:00
2019-10-30 16:56:42 +01:00
wo sync
2022-04-28 15:07:12 +02:00
_run wo_git_secure_path
2018-11-13 21:55:59 +01:00
2019-07-29 11:23:23 +02:00
if [ "$ee_migration" = "1" ]; then
echo
wo_lib_echo "The migration from EasyEngine to WordOps was succesfull!"
wo_lib_echo "The EasyEngine backup files can be found in /var/lib/wo-backup/ee-backup.tgz"
echo
elif [ "$wo_upgrade" = "1" ]; then
wo_lib_echo "WordOps (wo) upgrade to $wo_version_new was succesfull!"
2020-02-04 12:26:36 +01:00
wo_lib_echo "Changelog is available on https://github.com/WordOps/WordOps/releases/tag/$wo_version_new"
2019-08-22 14:46:39 +02:00
echo
2019-12-03 19:48:18 +01:00
wo_lib_echo "To upgrade WordOps web stacks, you can use the command:"
2019-10-28 20:07:38 +01:00
wo_lib_echo_info "wo stack upgrade"
2019-08-22 14:46:39 +02:00
echo
2019-12-03 19:48:18 +01:00
wo_lib_echo "To update all other packages, you can use the command:"
2019-08-31 02:30:14 +02:00
wo_lib_echo_info "wo maintenance"
2019-07-29 11:23:23 +02:00
else
wo_lib_echo "WordOps (wo) installed successfully"
2019-08-22 14:46:39 +02:00
echo
2019-09-03 11:33:10 +02:00
wo_lib_echo "To enable bash-completion, just use the command:"
2019-09-21 19:12:46 +02:00
wo_lib_echo_info "bash -l"
2019-09-03 05:37:53 +02:00
echo
2019-09-03 11:33:10 +02:00
wo_lib_echo "To install WordOps recommended stacks, you can use the command:"
2019-08-22 15:01:35 +02:00
wo_lib_echo_info "wo stack install"
2019-09-02 19:41:46 +02:00
echo
2019-09-03 11:33:10 +02:00
wo_lib_echo "To create a first WordPress site, you can use the command:"
2019-09-02 19:41:46 +02:00
wo_lib_echo_info "wo site create site.tld --wp"
2019-07-29 11:23:23 +02:00
fi
2018-12-03 20:17:22 +01:00
echo
2019-07-29 11:23:23 +02:00
wo_lib_echo "WordOps Documentation : https://docs.wordops.net"
wo_lib_echo "WordOps Community Forum : https://community.wordops.net"
2019-10-28 14:53:15 +01:00
wo_lib_echo "WordOps Community Chat : https://chat.wordops.net"
2019-07-29 11:23:23 +02:00
echo
2019-08-13 09:46:21 +02:00
wo_lib_echo "Give WordOps a GitHub star : https://github.com/WordOps/WordOps/"
echo
2019-02-21 21:17:54 +01:00
fi