1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-10-18 00:50:07 +00:00

feat(install): add openSUSE and SLES 15 distribution support and compute bootstrap

This commit is contained in:
catborise 2026-09-25 20:03:02 +03:00
parent 75f73f1607
commit 88288f965d
5 changed files with 244 additions and 54 deletions

View file

@ -160,6 +160,16 @@ install_packages () {
fi
done
;;
suse)
for p in $PACKAGES; do
if rpm -q "$p" >/dev/null 2>&1; then
echo " * $p already installed"
else
echo " * Installing $p"
log "zypper --non-interactive install -y $p"
fi
done
;;
esac
}
@ -206,12 +216,17 @@ create_user () {
if [ "$distro" == "ubuntu" ] || [ "$distro" == "debian" ] ||
[[ "$distro" == "uos" && "$codename" == "eagle" ]]; then
adduser --quiet --disabled-password --gecos '""' "$APP_USER"
elif [ "$distro" == "suse" ]; then
useradd -m -s /bin/bash "$APP_USER" 2>/dev/null || adduser "$APP_USER"
else
adduser "$APP_USER"
useradd -m -s /bin/bash "$APP_USER" 2>/dev/null || adduser "$APP_USER"
fi
usermod -a -G "$nginx_group" "$APP_USER"
usermod -a -G libvirt "$nginx_group"
usermod -a -G "$nginx_group" "$APP_USER" 2>/dev/null || true
usermod -a -G libvirt "$nginx_group" 2>/dev/null || true
usermod -a -G kvm "$nginx_group" 2>/dev/null || true
usermod -a -G libvirt "$APP_USER" 2>/dev/null || true
usermod -a -G kvm "$APP_USER" 2>/dev/null || true
}
run_as_app_user () {
@ -371,6 +386,8 @@ if [ -f /etc/os-release ]; then
version="$(source /etc/os-release && echo "$VERSION_ID")"
# shellcheck disable=SC1091
codename="$(source /etc/os-release && echo "${VERSION_CODENAME:-$UBUNTU_CODENAME}")"
# shellcheck disable=SC1091
id_like="$(source /etc/os-release && echo "${ID_LIKE:-}")"
elif [[ -f /etc/lsb-release || -f /etc/debian_version ]]; then
if command -v lsb_release >/dev/null 2>&1; then
distro="$(lsb_release -is)"
@ -384,6 +401,11 @@ elif [[ -f /etc/lsb-release || -f /etc/debian_version ]]; then
elif [ -f /etc/centos-release ]; then
distro="centos"
version="8"
elif [ -f /etc/SuSE-release ]; then
distro="suse"
version="15"
codename=""
id_like="suse"
else
distro="unsupported"
fi
@ -394,7 +416,7 @@ echo '
'
echo ""
echo " Welcome to Webvirtcloud Installer for RHEL Based OSes, Debian and Ubuntu!"
echo " Welcome to Webvirtcloud Installer for RHEL Based OSes, Debian, Ubuntu, and SUSE!"
echo ""
shopt -s nocasematch
case $distro in
@ -425,6 +447,15 @@ case $distro in
supervisor_conf_path=/etc/supervisord.d
supervisor_file_name=webvirtcloud.ini
;;
*opensuse*|*sles*|*sled*|*suse*)
echo " The installer has detected $distro version $version."
distro=suse
nginx_group=nginx
nginxfile=/etc/nginx/conf.d/$APP_NAME.conf
supervisor_service=supervisord
supervisor_conf_path=/etc/supervisord.d
supervisor_file_name=webvirtcloud.ini
;;
*Uos*|*uos*)
# codename may be fuyu, kongzi, eagle or empty string.
output_expand=""
@ -456,8 +487,18 @@ case $distro in
supervisor_file_name=webvirtcloud.ini
;;
*)
echo " The installer was unable to determine your OS. Exiting for safety."
exit 1
if [[ "$id_like" =~ suse ]]; then
echo " The installer has detected $distro (SUSE family) version $version."
distro=suse
nginx_group=nginx
nginxfile=/etc/nginx/conf.d/$APP_NAME.conf
supervisor_service=supervisord
supervisor_conf_path=/etc/supervisord.d
supervisor_file_name=webvirtcloud.ini
else
echo " The installer was unable to determine your OS. Exiting for safety."
exit 1
fi
;;
esac
@ -684,6 +725,80 @@ case $distro in
restart_nginx
fi
;;
suse)
# Install for openSUSE Leap 15.x / Tumbleweed / SLES 15
tzone=\'$(get_timezone)\'
echo -n "* Updating installed packages."
log "zypper --non-interactive refresh" & pid=$!
progress
echo "* Installing OS requirements."
PACKAGES="git python3-devel python3-pip python3-virtualenv libvirt-devel python3-libvirt python3-lxml openldap2-devel cyrus-sasl-devel libopenssl-devel libxslt-devel libxml2-devel gcc pkg-config nginx"
install_packages
set_hosts
# Supervisor on SUSE (available as python3-supervisor, supervisor, or via pip)
if ! command -v supervisord >/dev/null 2>&1; then
if zypper --non-interactive install -y python3-supervisor >/dev/null 2>&1; then
echo " * python3-supervisor installed via zypper"
elif zypper --non-interactive install -y supervisor >/dev/null 2>&1; then
echo " * supervisor installed via zypper"
else
echo " * Installing supervisor via pip3"
log "pip3 install supervisor"
fi
fi
# Ensure /etc/supervisord.d directory exists and is included in supervisord.conf
mkdir -p /etc/supervisord.d
if [ ! -f /etc/supervisord.conf ] && [ ! -f /etc/supervisor/supervisord.conf ]; then
if command -v echo_supervisord_conf >/dev/null 2>&1; then
echo_supervisord_conf > /etc/supervisord.conf
echo -e "\n[include]\nfiles = /etc/supervisord.d/*.ini\n" >> /etc/supervisord.conf
fi
elif [ -f /etc/supervisord.conf ] && ! grep -q "/etc/supervisord.d" /etc/supervisord.conf; then
echo -e "\n[include]\nfiles = /etc/supervisord.d/*.ini\n" >> /etc/supervisord.conf
fi
# Ensure systemd service for supervisord exists if installed via pip
if [ ! -f /usr/lib/systemd/system/supervisord.service ] && [ ! -f /etc/systemd/system/supervisord.service ]; then
supervisord_bin="$(command -v supervisord 2>/dev/null || echo "/usr/local/bin/supervisord")"
supervisorctl_bin="$(command -v supervisorctl 2>/dev/null || echo "/usr/local/bin/supervisorctl")"
cat > /etc/systemd/system/supervisord.service <<SVCEOF
[Unit]
Description=Process Monitoring and Control Daemon
After=network.target
[Service]
Type=forking
ExecStart=${supervisord_bin} -c /etc/supervisord.conf
ExecStop=${supervisorctl_bin} shutdown
ExecReload=${supervisorctl_bin} reload
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
SVCEOF
systemctl daemon-reload >/dev/null 2>&1 || true
fi
install_webvirtcloud
echo "* Configuring Nginx."
configure_nginx
echo "* Configuring Supervisor."
configure_supervisor
set_firewall
restart_supervisor
restart_nginx
;;
esac