Fix missing purge

This commit is contained in:
VirtuBox
2019-08-29 23:04:46 +02:00
parent 31e2e61cf5
commit 4ac33ba026
2 changed files with 68 additions and 43 deletions

57
install
View File

@@ -103,7 +103,11 @@ export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
}
if [ -z "$(command -v curl)" ]; then
command_exists() {
command -v "$@" > /dev/null 2>&1
}
if ! command_exists curl; then
apt-get -y install curl -qq
fi
@@ -120,9 +124,9 @@ echo ""
###
# 1- Check whether lsb_release is installed, and if not, install it
###
if [ -z "$(command -v lsb_release)" ]; then
if ! command_exists lsb_release; then
wo_lib_echo "Installing lsb-release, please wait..."
apt-get -y install lsb-release -qq
apt-get install lsb-release -qq
fi
###
@@ -191,11 +195,9 @@ fi
####
wo_dist_upgrade() {
[ -z "$wo_travis" ] && {
# update server packages
apt-get dist-upgrade --option=Dpkg::options::=--force-confmiss --option=Dpkg::options::=--force-confold --option=Dpkg::options::=--force-unsafe-io --assume-yes --quiet
} >> "$wo_install_log" 2>&1
}
# update server packages
apt-get dist-upgrade --option=Dpkg::options::=--force-confmiss --option=Dpkg::options::=--force-confold --option=Dpkg::options::=--force-unsafe-io --assume-yes --quiet
} >> "$wo_install_log" 2>&1
wo_install_dep() {
@@ -223,17 +225,19 @@ wo_install_dep() {
if [ ! -f /etc/apt/apt.conf.d/20auto-upgrades ]; then
cp /usr/share/unattended-upgrades/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades
fi
# set default ntp pools
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
} >> "$wo_install_log" 2>&1
}
wo_timesync() {
# set default ntp pools
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
}
###
# 3 - Create/migrate the essentials
###
@@ -695,14 +699,14 @@ wo_mariadb_tweak() {
wo_nginx_tweak() {
# increase nginx open_files_limit
{
if [ ! -d /etc/systemd/system/nginx.service.d ]; then
mkdir -p /etc/systemd/system/nginx.service.d
if [ ! -f /etc/systemd/system/nginx.service.d/limits.conf ]; then
echo -e '[Service]\nLimitNOFILE=500000' > /etc/systemd/system/nginx.service.d/limits.conf
systemctl daemon-reload
nginx -t && service nginx restart
fi
if [ ! -d /etc/systemd/system/nginx.service.d ]; then
mkdir -p /etc/systemd/system/nginx.service.d
if [ ! -f /etc/systemd/system/nginx.service.d/limits.conf ]; then
echo -e '[Service]\nLimitNOFILE=500000' > /etc/systemd/system/nginx.service.d/limits.conf
systemctl daemon-reload
nginx -t && service nginx restart
fi
fi
} >> /var/log/wo/install.log 2>&1
}
@@ -716,7 +720,7 @@ wo_uninstall() {
wo_cheat_alias() {
if ! grep -q "cheat" "$HOME/.bashrc"; then
echo "alias cheat='/usr/local/bin/cht.sh'" >> "$HOME/.bashrc"
echo "alias cheat='/usr/local/bin/cht.sh'" >> "$HOME/.bashrc"
fi
}
@@ -803,6 +807,7 @@ else
} || [ "$wo_force_install" = "y" ]; then
wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log
wo_install_dep | tee -ai $wo_install_log
wo_timesync | tee -ai $wo_install_log
wo_lib_echo "Backing-up WO install" | tee -ai $wo_install_log
wo_backup_wo | tee -ai $wo_install_log
secure_wo_db | tee -ai $wo_install_log
@@ -852,6 +857,7 @@ else
if [ "$WO_ANSWER" = "y" ] || [ "$WO_ANSWER" = "Y" ]; then
wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log
wo_install_dep | tee -ai $wo_install_log
wo_timesync | tee -ai $wo_install_log
wo_lib_echo "Backing-up EE install" | tee -ai $wo_install_log
wo_backup_ee | tee -ai $wo_install_log
wo_lib_echo "Removing EasyEngine cronjob" | tee -ai $wo_install_log
@@ -897,8 +903,11 @@ else
else
# 3 - Fresh WO setup
wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log
wo_dist_upgrade | tee -ai $wo_install_log
[ -z "$wo_travis" ] && {
wo_dist_upgrade | tee -ai $wo_install_log
}
wo_install_dep | tee -ai $wo_install_log
wo_timesync | tee -ai $wo_install_log
wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log
if [ "$wo_travis" = "y" ]; then
wo_install_travis | tee -ai $wo_install_log

View File

@@ -151,9 +151,9 @@ class WOStackController(CementBaseController):
pargs.wpcli = True
if pargs.admin:
pargs.web = True
pargs.adminer = True
pargs.phpmyadmin = True
pargs.composer = True
pargs.utils = True
pargs.netdata = True
pargs.dashboard = True
@@ -639,7 +639,7 @@ class WOStackController(CementBaseController):
if os.path.isdir('{0}22222/htdocs/cache/redis'
.format(WOVariables.wo_webroot)):
packages = packages + ['{0}22222/htdocs/'
'cache/redis/phpRedisAdmin'
'cache/redis'
.format(WOVariables.wo_webroot)]
# ADMINER
if pargs.adminer:
@@ -677,7 +677,7 @@ class WOStackController(CementBaseController):
' remove from server.'
'\nPackage configuration will remain'
' on server after this operation.\n'
'Remove stacks [y/N]')
'Remove stacks [y/N]?')
if start_remove != "Y" and start_remove != "y":
Log.error(self, "Not starting stack removal")
Log.info(self, "Removing stacks, please wait...")
@@ -687,17 +687,22 @@ class WOStackController(CementBaseController):
# Netdata uninstaller
if (set(['/var/lib/wo/tmp/'
'kickstart.sh']).issubset(set(packages))):
WOShellExec.cmd_exec(self, "bash /opt/netdata/usr/"
"libexec/netdata-"
"uninstaller.sh -y -f")
if WOVariables.wo_distro == 'Raspbian':
WOShellExec.cmd_exec(self, "bash /usr/"
"libexec/netdata-"
"uninstaller.sh -y -f")
else:
WOShellExec.cmd_exec(self, "bash /opt/netdata/usr/"
"libexec/netdata-"
"uninstaller.sh -y -f")
if (packages):
Log.info(self, "Removing packages, please wait...")
WOFileUtils.remove(self, packages)
WOAptGet.auto_remove(self)
if (apt_packages):
Log.debug(self, "Removing apt_packages")
Log.info(self, "Removing packages, please wait...")
Log.info(self, "Removing apt packages, please wait...")
WOAptGet.remove(self, apt_packages)
WOAptGet.auto_remove(self)
@@ -748,6 +753,7 @@ class WOStackController(CementBaseController):
pargs.composer = True
pargs.netdata = True
pargs.mysqltuner = True
pargs.cheat = True
if pargs.security:
pargs.fail2ban = True
@@ -779,6 +785,16 @@ class WOStackController(CementBaseController):
else:
apt_packages = apt_packages + WOVariables.wo_php73
# REDIS
if pargs.redis:
Log.debug(self, "Remove apt_packages variable of Redis")
apt_packages = apt_packages + WOVariables.wo_redis
# MariaDB
if pargs.mysql:
Log.debug(self, "Removing apt_packages variable of MySQL")
apt_packages = apt_packages + WOVariables.wo_mysql
# mysqlclient
if pargs.mysqlclient:
Log.debug(self, "Removing apt_packages variable "
@@ -832,7 +848,7 @@ class WOStackController(CementBaseController):
if os.path.isdir('{0}22222/htdocs/cache/redis'
.format(WOVariables.wo_webroot)):
packages = packages + ['{0}22222/htdocs/'
'cache/redis/phpRedisAdmin'
'cache/redis'
.format(WOVariables.wo_webroot)]
# Adminer
if pargs.adminer:
@@ -842,16 +858,16 @@ class WOStackController(CementBaseController):
# utils
if pargs.utils:
Log.debug(self, "Purge package variable utils")
packages = packages + ['{0}22222/htdocs/php/webgrind/'
.format(WOVariables.wo_webroot),
'{0}22222/htdocs/cache/opcache'
.format(WOVariables.wo_webroot),
'{0}22222/htdocs/cache/nginx/'
'clean.php'.format(WOVariables.wo_webroot),
'/usr/bin/pt-query-advisor',
'{0}22222/htdocs/db/anemometer'
.format(WOVariables.wo_webroot)
]
packages = packages + [['{0}22222/htdocs/php/webgrind/'
.format(WOVariables.wo_webroot),
'{0}22222/htdocs/cache/opcache'
.format(WOVariables.wo_webroot),
'{0}22222/htdocs/cache/nginx/'
'clean.php'.format(WOVariables.wo_webroot),
'/usr/bin/pt-query-advisor',
'{0}22222/htdocs/db/anemometer'
.format(WOVariables.wo_webroot)
]]
if pargs.netdata:
Log.debug(self, "Removing Netdata")