Merge pull request #660 from WordOps/updating-configuration

Bump MariaDB to 11.4 and fix repositories gpg keys
This commit is contained in:
VirtuBox
2024-06-07 17:19:42 +02:00
committed by GitHub
14 changed files with 180 additions and 114 deletions

View File

@@ -12,7 +12,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Ubuntu 24.04 LTS support
- New Nginx package with HTTP/3 QUIC support
- `wo stack install/remove --brotli` to enable/disable brotli compression
#### Changed
- Bump MariaDB release to v11.4
- Remove php72 and php73 stacks
- All APT repositories are properly signed with gpg keys
- Netdata is installed from debian packages when available
- Less logs in acme.sh operation
#### Fixed
- wo info php versions display
- Repositories's gpg keys are not managed with apt-key anymore
- `wo site update site.tld --hsts` errors
- `wo site update site.tld --ngxblocker` errors
- Netdata install and upgrade
#### Security

View File

@@ -120,7 +120,7 @@ wo site create example.com --wpsubdomain --wpce # install wpmu-subdomain + C
```bash
wo site create example.com --html # create example.com for static/html sites
wo site create example.com --php # create example.com with php 8.2 support
wo site create example.com --php # create example.com with php support
wo site create example.com --php80 # create example.com with php 8.0 support
wo site create example.com --php81 # create example.com with php 8.1 support
wo site create example.com --php82 # create example.com with php 8.2 support

View File

@@ -84,7 +84,7 @@ version = 8.2
[mariadb]
### Default MariaDB release
release = 10.11
release = 11.4
[update]

80
install
View File

@@ -9,7 +9,7 @@
# -------------------------------------------------------------------------
# wget -qO wo wops.cc && sudo -E bash wo
# -------------------------------------------------------------------------
# Version 3.21.0 - 2024-06-01
# Version 3.21.0 - 2024-06-07
# -------------------------------------------------------------------------
# CONTENTS
@@ -222,7 +222,6 @@ wo_install_dep() {
# add php repository gpg key
curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
dpkg -i /tmp/debsuryorg-archive-keyring.deb && rm -f /tmp/debsuryorg-archive-keyring.deb
sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
fi
locale-gen en
# enable unattended upgades
@@ -231,6 +230,62 @@ wo_install_dep() {
fi
}
wo_download_gpg_keys() {
local wo_distro_version
wo_distro_version=$(lsb_release -rs | grep -oE '[0-9]+')
local wo_linux_distro
wo_linux_distro=$(lsb_release -is)
# create directories
mkdir -p /usr/share/keyrings /etc/apt/keyrings
# redis gpg key
curl -fsSL https://packages.redis.io/gpg | gpg --dearmor | tee /usr/share/keyrings/redis-archive-keyring.gpg >/dev/null 2>&1
# mariadb
curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'
# nginx
if [ "$wo_linux_distro" == "Debian" ]; then
curl -fsSL "https://download.opensuse.org/repositories/home:virtubox:WordOps/Debian_$wo_distro_version/Release.key" | gpg --dearmor | tee /usr/share/keyrings/wordops-archive-keyring.gpg >/dev/null 2>&1
fi
if [ "$wo_linux_distro" == "Raspbian" ]; then
curl -fsSL "https://download.opensuse.org/repositories/home:virtubox:WordOps/Raspbian_$wo_distro_version/Release.key" | gpg --dearmor | tee /usr/share/keyrings/wordops-archive-keyring.gpg >/dev/null 2>&1
fi
}
wo_update_repo() {
local wo_linux_codename
wo_linux_codename=$(lsb_release -sc)
if [ -f /etc/apt/sources.list.d/wo-repo.list ]; then
# properly define sury repository
if grep -q sury /etc/apt/sources.list.d/wo-repo.list; then
echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $wo_linux_codename main" >/etc/apt/sources.list.d/php.list
fi
# properly define mariadb repository
if grep -q mariadb /etc/apt/sources.list.d/wo-repo.list; then
mariadb_repo=$(grep mariadb /etc/apt/sources.list.d/wo-repo.list | awk -F\ '{ print $3 }')
echo "deb [signed-by=/etc/apt/keyrings/mariadb-keyring.pgp] $mariadb_repo $wo_linux_codename main" >/etc/apt/sources.list.d/mariadb.list
fi
# properly define redis repository
if grep -q redis /etc/apt/sources.list.d/wo-repo.list; then
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $wo_linux_codename main" >/etc/apt/sources.list.d/redis.list
fi
# properly define WordOps nginx repository
if grep -q WordOps /etc/apt/sources.list.d/wo-repo.list; then
wo_repo=$(grep WordOps /etc/apt/sources.list.d/wo-repo.list | awk -F\ '{ print $2 }')
echo "deb [signed-by=/usr/share/keyrings/wordops-archive-keyring.gpg] $wo_repo /" >/etc/apt/sources.list.d/wordops.list
fi
# cleanup wo-repo.list
if grep -Eqv "WordOps|mariadb|sury|redis" /etc/apt/sources.list.d/wo-repo.list; then
rm -f /etc/apt/sources.list.d/wo-repo.list
else
clean_wo_repo=$(grep -Ev "WordOps|mariadb|sury|redis" /etc/apt/sources.list.d/wo-repo.list)
echo "$clean_wo_repo" >/etc/apt/sources.list.d/wo-repo.list
fi
fi
}
wo_timesync() {
# set default ntp pools
if [ "$wo_distro_codename" != "bookworm" ] && [ "$wo_distro_codename" != "noble" ]; then
@@ -576,10 +631,6 @@ wo_upgrade_nginx() {
CHECK_NGINX_EE=$(dpkg --list | grep nginx-ee)
CHECK_PHP72=$(command -v php-fpm7.2)
# add new Nginx repository
# import the respository key for updates
curl -sL https://build.opensuse.org/projects/home:virtubox/public_key | apt-key add -
# install new nginx package
if {
if [ -n "$CHECK_NGINX_EE" ]; then
@@ -753,12 +804,6 @@ wo_init() {
###
if [ -z "$wo_travis" ]; then
# import easyengine opensusebuildservice gpg key to avoid issues with packages update
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
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys cf0b928cded64f3b >/dev/null 2>&1
# fix digitalocean mariadb repository issue
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
fi
@@ -776,14 +821,17 @@ wo_init() {
if ! command_exists jq; then
apt-get install jq -qq >/dev/null 2>&1
fi
if ! command_exists gpg; then
apt-get install gpg -qq >/dev/null 2>&1
fi
fi
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
if [ -f ./setup.py ]; then
readonly wo_version_new=$(grep "version='" setup.py | awk -F "'" '{print $2}' 2>&1)
wo_version_new=$(grep "version='" setup.py | awk -F "'" '{print $2}' 2>&1)
else
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')
wo_version_new=$(curl -m 5 --retry 3 -sL https://api.github.com/repos/WordOps/WordOps/releases/latest 2>&1 | jq -r '.tag_name')
fi
echo ""
@@ -811,12 +859,13 @@ wo_git_secure_path() {
# create required directories
wo_dir_init
# install lsb_release, curl and display header
# install lsb_release, curl, gpg and display header
wo_init
# define main variables
wo_init_variables
# remove old repositories
_run wo_clean_repo
_run wo_download_gpg_keys
if [ -z "$wo_force_install" ]; then
# check distribution support
@@ -836,6 +885,7 @@ else
_run wo_woconf
_run wo_fix_kernel
_run wo_php_fix
_run wo_update_repo
# 2 - Migration from EEv3
else
if [ -x /usr/local/bin/ee ]; then

View File

@@ -400,6 +400,14 @@ echo -e ' wo info '
echo -e "${CGREEN}#############################################${CEND}"
wo info
echo
echo -e "${CGREEN}#############################################${CEND}"
echo -e ' display repositories '
echo -e "${CGREEN}#############################################${CEND}"
ls -alh /etc/apt/sources.list.d/
cat /etc/apt/sources.list.d/mariadb.list
cat /etc/apt/sources.list.d/redis.list
# echo -e "${CGREEN}#############################################${CEND}"
# echo -e ' wo site delete '
# echo -e "${CGREEN}#############################################${CEND}"

View File

@@ -8,8 +8,8 @@ from pynginxconfig import NginxConfig
from wo.core.aptget import WOAptGet
from wo.core.logging import Log
from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVar
from wo.core.mysql import WOMysql
def wo_info_hook(app):
@@ -540,28 +540,33 @@ class WOInfoController(CementBaseController):
@expose(hide=True)
def info_mysql(self):
"""Display MySQL information"""
version = os.popen("/usr/bin/mysql -V | awk '{print($5)}' | "
if os.path.exists('/usr/bin/mariadb'):
mariadb_exec = "/usr/bin/mariadb"
else:
mariadb_exec = "/usr/bin/mysql"
version = os.popen(f"{mariadb_exec} -V |"
"awk '{print($5)}' | "
"cut -d ',' "
"-f1 | tr -d '\n'").read()
host = "localhost"
port = os.popen("/usr/bin/mysql -e \"show variables\" | "
port = os.popen(f"{mariadb_exec} -e \"show variables\" | "
"/bin/grep ^port | awk "
"'{print($2)}' | tr -d '\n'").read()
wait_timeout = os.popen("/usr/bin/mysql -e \"show variables\" | grep "
wait_timeout = os.popen(f"{mariadb_exec} -e \"show variables\" | grep "
"^wait_timeout | awk '{print($2)}' | "
"tr -d '\n'").read()
interactive_timeout = os.popen("/usr/bin/mysql -e "
interactive_timeout = os.popen(f"{mariadb_exec} -e "
"\"show variables\" | grep "
"^interactive_timeout | awk "
"'{print($2)}' | tr -d '\n'").read()
max_used_connections = os.popen("/usr/bin/mysql -e "
max_used_connections = os.popen(f"{mariadb_exec} - e "
"\"show global status\" | "
"grep Max_used_connections | awk "
"'{print($2)}' | tr -d '\n'").read()
datadir = os.popen("/usr/bin/mysql -e \"show variables\" | "
datadir = os.popen(f"{mariadb_exec} -e \"show variables\" | "
"/bin/grep datadir | awk"
" '{print($2)}' | tr -d '\n'").read()
socket = os.popen("/usr/bin/mysql -e \"show variables\" | "
socket = os.popen(f"{mariadb_exec} -e \"show variables\" | "
"/bin/grep \"^socket\" | "
"awk '{print($2)}' | tr -d '\n'").read()
data = dict(version=version, host=host, port=port,
@@ -593,7 +598,7 @@ class WOInfoController(CementBaseController):
self.info_php()
if pargs.mysql:
if WOShellExec.cmd_exec(self, "/usr/bin/mysqladmin ping"):
if WOMysql.mariadb_ping(self):
self.info_mysql()
else:
Log.info(self, "MySQL is not installed")

View File

@@ -904,7 +904,7 @@ def site_package_check(self, stype):
if stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for MySQL")
if not WOShellExec.cmd_exec(self, "/usr/bin/mysqladmin ping"):
if not WOMysql.mariadb_ping(self):
apt_packages = apt_packages + WOVar.wo_mysql
if stype in ['wp', 'wpsubdir', 'wpsubdomain']:

View File

@@ -208,7 +208,7 @@ class WOStackController(CementBaseController):
if pargs.mysql:
pargs.mysqltuner = True
Log.debug(self, "Setting apt_packages variable for MySQL")
if not WOShellExec.cmd_exec(self, "mysqladmin ping"):
if not WOMysql.mariadb_ping(self):
apt_packages = apt_packages + WOVar.wo_mysql
else:
Log.debug(self, "MySQL already installed and alive")
@@ -218,7 +218,7 @@ class WOStackController(CementBaseController):
if pargs.mysqlclient:
Log.debug(self, "Setting apt_packages variable "
"for MySQL Client")
if not WOShellExec.cmd_exec(self, "mysqladmin ping"):
if not WOMysql.mariadb_ping(self):
apt_packages = apt_packages + WOVar.wo_mysql_client
else:
Log.debug(self, "MySQL already installed and alive")
@@ -470,7 +470,7 @@ class WOStackController(CementBaseController):
# UTILS
if pargs.utils:
if not WOShellExec.cmd_exec(self, 'mysqladmin ping'):
if not WOMysql.mariadb_ping(self):
pargs.mysql = True
if not (WOAptGet.is_installed(self, 'php7.2-fpm') or
WOAptGet.is_installed(self, 'php7.3-fpm') or
@@ -655,7 +655,7 @@ class WOStackController(CementBaseController):
if pargs.mysqlclient:
Log.debug(self, "Removing apt_packages variable "
"for MySQL Client")
if WOShellExec.cmd_exec(self, "mysqladmin ping"):
if WOMysql.mariadb_ping(self):
apt_packages = apt_packages + WOVar.wo_mysql_client
# fail2ban
@@ -844,7 +844,7 @@ class WOStackController(CementBaseController):
packages = packages + ["/opt/netdata"]
else:
Log.debug(self, "Netdata uninstaller not found")
if WOShellExec.cmd_exec(self, 'mysqladmin ping'):
if WOMysql.mariadb_ping(self):
WOMysql.execute(
self, "DELETE FROM mysql.user WHERE User = 'netdata';")
@@ -972,7 +972,7 @@ class WOStackController(CementBaseController):
# mysqlclient
if pargs.mysqlclient:
if WOShellExec.cmd_exec(self, "mysqladmin ping"):
if WOMysql.mariadb_ping(self):
Log.debug(self, "Add MySQL client to apt_packages list")
apt_packages = apt_packages + WOVar.wo_mysql_client
@@ -1145,7 +1145,7 @@ class WOStackController(CementBaseController):
packages = packages + ["/opt/netdata"]
else:
Log.debug(self, "Netdata uninstaller not found")
if WOShellExec.cmd_exec(self, 'mysqladmin ping'):
if WOMysql.mariadb_ping(self):
WOMysql.execute(
self, "DELETE FROM mysql.user WHERE User = 'netdata';")

View File

@@ -1,3 +1,5 @@
import os
import re
from cement.core.controller import CementBaseController, expose
from wo.cli.plugins.stack_pref import post_pref, pre_pref
@@ -32,21 +34,32 @@ class WOStackMigrateController(CementBaseController):
@expose(hide=True)
def migrate_mariadb(self, ci=False):
if WOShellExec.cmd_exec(self, 'mysqladmin ping'):
if WOMysql.mariadb_ping(self):
# Backup all database
WOMysql.backupAll(self, fulldump=True)
else:
Log.error(self, "Unable to connect to MariaDB")
# Check current MariaDB version
wo_mysql_current_repo = WOFileUtils.grep(
self, '/etc/apt/sources.list.d/wo-repo.list', 'mariadb')
if (os.path.exists('/etc/apt/sources.list.d/wo-repo.list') and
WOFileUtils.grepcheck(self, "/etc/apt/sources.list.d/wo-repo.list", "mariadb")):
wo_mysql_current_repo = WOFileUtils.grep(
self, '/etc/apt/sources.list.d/wo-repo.list', 'mariadb')
repo_path = '/etc/apt/sources.list.d/wo-repo.list'
elif (os.path.exists('/etc/apt/sources.list.d/mariadb.list') and
WOFileUtils.grepcheck(self, '/etc/apt/sources.list.d/mariadb.list', "mariadb")):
wo_mysql_current_repo = WOFileUtils.grep(
self, '/etc/apt/sources.list.d/mariadb.list', 'mariadb')
repo_path = '/etc/apt/sources.list.d/mariadb.list'
if wo_mysql_current_repo:
current_mysql_version = wo_mysql_current_repo.split('/')
Log.debug(self, "Looking for MariaDB version")
pattern = r"/(\d+\.\d+)/"
match = re.search(pattern, wo_mysql_current_repo)
current_mysql_version = match.group(1)
Log.debug(self, f"Current MariaDB version is {current_mysql_version}")
else:
Log.error(self, "MariaDB is not installed from repository yet")
if 'repo' in current_mysql_version:
current_mysql_version = current_mysql_version[5]
if self.app.config.has_section('mariadb'):
mariadb_release = self.app.config.get(
@@ -60,17 +73,7 @@ class WOStackMigrateController(CementBaseController):
"MariaDB version available")
return 0
wo_old_mysql_repo = ("deb [arch=amd64,arm64,ppc64el] "
"http://mariadb.mirrors.ovh.net/MariaDB/repo/"
"{version}/{distro} {codename} main"
.format(version=current_mysql_version,
distro=WOVar.wo_distro,
codename=WOVar.wo_platform_codename))
if WOFileUtils.grepcheck(
self, '/etc/apt/sources.list.d/wo-repo.list',
wo_old_mysql_repo):
WORepo.remove(self, repo_url=wo_old_mysql_repo)
WOFileUtils.rm(self, repo_path)
# Add MariaDB repo
pre_pref(self, WOVar.wo_mysql)
@@ -108,7 +111,7 @@ class WOStackMigrateController(CementBaseController):
Log.error(
self, "Remote MySQL server in use, skipping local install")
if WOShellExec.cmd_exec(self, "mysqladmin ping"):
if WOMysql.mariadb_ping(self):
Log.info(self, "If your database size is big, "
"migration may take some time.")

View File

@@ -29,7 +29,7 @@ def pre_pref(self, apt_packages):
if ("mariadb-server" in apt_packages or "mariadb-client" in apt_packages):
# add mariadb repository excepted on raspbian and ubuntu 19.04
if not (WOVar.wo_distro == 'raspbian') and not (WOVar.wo_platform_codename == 'noble'):
if not (WOVar.wo_distro == 'raspbian'):
Log.info(self, "Adding repository for MySQL, please wait...")
mysql_pref = (
"Package: *\nPin: origin mariadb.mirrors.ovh.net"
@@ -40,20 +40,13 @@ def pre_pref(self, apt_packages):
if self.app.config.has_section('mariadb'):
mariadb_ver = self.app.config.get(
'mariadb', 'release')
wo_mysql_repo_conf = ("deb [arch=amd64,arm64,ppc64el] "
wo_mysql_repo_conf = ("deb [signed-by=/etc/apt/keyrings/mariadb-keyring.pgp] "
"http://mariadb.mirrors.ovh.net/MariaDB/repo/"
"{version}/{distro} {codename} main"
.format(version=mariadb_ver,
distro=WOVar.wo_distro,
codename=WOVar.wo_platform_codename))
f"{mariadb_ver}/{WOVar.wo_distro} {WOVar.wo_platform_codename} main")
else:
wo_mysql_repo_conf = WOVar.wo_mysql_repo
# APT repositories
WORepo.add(self, repo_url=wo_mysql_repo_conf)
WORepo.add_key(self, '0xcbcb082a1bb943db',
keyserver='keyserver.ubuntu.com')
WORepo.add_key(self, '0xF1656F24C74CD1D8',
keyserver='keyserver.ubuntu.com')
WORepo.add(self, repo_url=wo_mysql_repo_conf, repo_name="mariadb")
if ("mariadb-server" in apt_packages and
not os.path.exists('/etc/mysql/conf.d/my.cnf')):
# generate random 24 characters root password
@@ -80,13 +73,10 @@ def pre_pref(self, apt_packages):
WORepo.add(self, ppa=WOVar.wo_nginx_repo)
Log.debug(self, 'Adding ppa for Nginx')
else:
if not WOFileUtils.grepcheck(
self, '/etc/apt/sources.list/wo-repo.list',
'WordOps'):
if not os.path.exists('/etc/apt/sources.list.d/wordops.list'):
Log.info(self, "Adding repository for NGINX, please wait...")
Log.debug(self, 'Adding repository for Nginx')
WORepo.add(self, repo_url=WOVar.wo_nginx_repo)
WORepo.add_key(self, WOVar.wo_nginx_key)
WORepo.add(self, repo_url=WOVar.wo_nginx_repo, repo_name="wordops")
# add php repository
if (('php7.3-fpm' in apt_packages) or
@@ -111,34 +101,15 @@ def pre_pref(self, apt_packages):
'PHP.pref', mode='w',
encoding='utf-8') as php_pref_file:
php_pref_file.write(php_pref)
if not WOFileUtils.grepcheck(
self, '/etc/apt/sources.list.d/wo-repo.list',
'packages.sury.org'):
if not os.path.exists('/etc/apt/sources.list.d/php.list'):
Log.debug(self, 'Adding repo_url of php for debian')
Log.info(self, "Adding repository for PHP, please wait...")
WORepo.add(self, repo_url=WOVar.wo_php_repo)
Log.debug(self, 'Adding deb.sury GPG key')
WORepo.add_key(self, WOVar.wo_php_key)
WORepo.add(self, repo_url=WOVar.wo_php_repo, repo_name="php")
# add redis repository
if set(WOVar.wo_redis).issubset(set(apt_packages)):
if not WOFileUtils.grepcheck(
self, '/etc/apt/sources.list/wo-repo.list',
'redis.io') and not (WOVar.wo_platform_codename == 'noble'):
Log.info(self, "Adding repository for Redis, please wait...")
WORepo.add(self, repo_url=WOVar.wo_redis_repo)
WORepo.download_key(self, WOVar.wo_redis_key_url)
# nano
if 'nano' in apt_packages:
if WOVar.wo_platform_codename == 'buster':
if (not WOFileUtils.grepcheck(
self, '/etc/apt/sources.list/wo-repo.list',
'WordOps')):
Log.info(self,
"Adding repository for Nano, please wait...")
Log.debug(self, 'Adding repository for Nano')
WORepo.add_key(self, WOVar.wo_nginx_key)
WORepo.add(self, repo_url=WOVar.wo_nginx_repo)
if not os.path.exists('/etc/apt/sources.list.d/redis.list'):
WORepo.add(self, repo_url=WOVar.wo_redis_repo, repo_name="redis")
def post_pref(self, apt_packages, packages, upgrade=False):
@@ -1173,7 +1144,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
else:
wo_grant_host = 'localhost'
# check if mysql credentials are available
if (WOShellExec.cmd_exec(self, "mysqladmin ping")
if (WOMysql.mariadb_ping(self)
and wo_grant_host == 'localhost'):
try:
WOMysql.execute(

View File

@@ -12,6 +12,7 @@ from wo.core.logging import Log
from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVar
from wo.core.services import WOService
from wo.core.mysql import WOMysql
class WOStackUpgradeController(CementBaseController):
@@ -152,7 +153,7 @@ class WOStackUpgradeController(CementBaseController):
# mysql
if pargs.mysql:
if WOShellExec.cmd_exec(self, 'mysqladmin ping'):
if WOMysql.mariadb_ping(self):
apt_packages = apt_packages + ['mariadb-server']
# redis

View File

@@ -13,7 +13,7 @@ class WORepo():
"""Initialize """
pass
def add(self, repo_url=None, ppa=None):
def add(self, repo_url=None, ppa=None, repo_name=None):
"""
This function used to add apt repositories and or ppa's
If repo_url is provided adds repo file to
@@ -24,8 +24,9 @@ class WORepo():
"""
if repo_url is not None:
repo_file_path = ("/etc/apt/sources.list.d/" +
WOVar().wo_repo_file)
if repo_name is not None:
repo_file_path = ("/etc/apt/sources.list.d/" +
f"{repo_name}.list")
try:
if not os.path.isfile(repo_file_path):
with open(repo_file_path,

View File

@@ -7,6 +7,7 @@ from pymysql import DatabaseError, Error, connections
from wo.core.logging import Log
from wo.core.variables import WOVar
from wo.core.shellexec import WOShellExec
class MySQLConnectionError(Exception):
@@ -161,3 +162,17 @@ class WOMysql():
except MySQLConnectionError as e:
Log.debug(self, str(e))
return False
def mariadb_ping(self):
if os.path.exists('/usr/bin/mariadb-admin'):
mariadb_admin = "/usr/bin/mariadb-admin"
elif os.path.exists('/usr/bin/mysqladmin'):
mariadb_admin = "/usr/bin/mysqladmin"
else:
Log.info(self, "MariaDB server isn't installed")
return False
if WOShellExec.cmd_exec(self, f"{mariadb_admin} ping"):
return True
else:
Log.info(self, "Unable to connect to MariaDB server")
return False

View File

@@ -118,10 +118,7 @@ class WOVar():
# Nginx repo and packages
if wo_distro == 'ubuntu':
wo_nginx_repo = "ppa:wordops/nginx-wo"
wo_extra_repo = (
"deb http://download.opensuse.org"
"/repositories/home:/virtubox:"
"/WordOps/xUbuntu_{0}/ /".format(wo_platform_version))
else:
if wo_distro == 'debian':
if wo_platform_codename == 'buster':
@@ -138,10 +135,10 @@ class WOVar():
elif wo_platform_codename == 'bookworm':
wo_deb_repo = "Raspbian_12"
# debian/raspbian nginx repository
wo_nginx_repo = ("deb http://download.opensuse.org"
"/repositories/home:"
"/virtubox:/WordOps/{0}/ /"
.format(wo_deb_repo))
wo_nginx_repo = ("deb [signed-by=/usr/share/keyrings/wordops-archive-keyring.gpg] "
"http://download.opensuse.org"
f"/repositories/home:/virtubox:/WordOps/{wo_deb_repo}/ /")
wo_nginx_key = (f"https://download.opensuse.org/repositories/home:virtubox:WordOps/{wo_deb_repo}/Release.key")
wo_nginx = ["nginx-custom", "nginx-wo"]
wo_nginx_key = 'FB898660'
@@ -190,24 +187,23 @@ class WOVar():
wo_clamav = ["clamav", "clamav-freshclam"]
# APT repositories
wo_mysql_repo = ("deb [arch=amd64,arm64,ppc64el] "
wo_mysql_repo = ("deb [signed-by=/etc/apt/keyrings/mariadb-keyring.pgp] "
"http://mariadb.mirrors.ovh.net/MariaDB/repo/"
"{version}/{distro} {codename} main"
.format(version=mariadb_ver,
distro=wo_distro,
codename=wo_platform_codename))
f"{mariadb_ver}/{wo_distro} {wo_platform_codename} main")
mariadb_repo_key = "https://mariadb.org/mariadb_release_signing_key.pgp"
if wo_distro == 'ubuntu':
wo_php_repo = "ppa:ondrej/php"
wo_goaccess_repo = ("ppa:alex-p/goaccess")
else:
wo_php_repo = (
"deb https://packages.sury.org/php/ {codename} main"
.format(codename=wo_platform_codename))
"deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] "
f"https://packages.sury.org/php/ {wo_platform_codename} main")
wo_php_key = '95BD4743'
wo_redis_key_url = "https://packages.redis.io/gpg"
wo_redis_repo = ("deb https://packages.redis.io/deb {codename} main"
.format(codename=wo_platform_codename))
wo_redis_repo = (
"deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] "
f"https://packages.redis.io/deb {wo_platform_codename} main")
wo_redis = ['redis-server']