From 9ddba262a4b8bd1d33ee7e6a72430d92e8bff27b Mon Sep 17 00:00:00 2001 From: herengui Date: Wed, 18 May 2022 17:21:12 +0800 Subject: [PATCH] Enhanced system support UOS is not a specific os, but a series of different OS, they use either dnf or apt package manager Signed-off-by: herengui --- conf/nginx/uos_eagle_nginx.conf | 85 +++++++++++++++++++++++++++++++++ webvirtcloud.sh | 60 +++++++++++++++++++---- 2 files changed, 135 insertions(+), 10 deletions(-) create mode 100644 conf/nginx/uos_eagle_nginx.conf diff --git a/conf/nginx/uos_eagle_nginx.conf b/conf/nginx/uos_eagle_nginx.conf new file mode 100644 index 0000000..7914c8e --- /dev/null +++ b/conf/nginx/uos_eagle_nginx.conf @@ -0,0 +1,85 @@ +user www-data; +worker_processes auto; +pid /run/nginx.pid; +include /etc/nginx/modules-enabled/*.conf; + +events { + worker_connections 768; + # multi_accept on; +} + +http { + + ## + # Basic Settings + ## + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + # server_tokens off; + + # server_names_hash_bucket_size 64; + # server_name_in_redirect off; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + ## + # SSL Settings + ## + + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE + ssl_prefer_server_ciphers on; + + ## + # Logging Settings + ## + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + ## + # Gzip Settings + ## + + gzip on; + + # gzip_vary on; + # gzip_proxied any; + # gzip_comp_level 6; + # gzip_buffers 16 8k; + # gzip_http_version 1.1; + # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + ## + # Virtual Host Configs + ## + + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-enabled/*; +} + + +#mail { +# # See sample authentication script at: +# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript +# +# # auth_http localhost/auth.php; +# # pop3_capabilities "TOP" "USER"; +# # imap_capabilities "IMAP4rev1" "UIDPLUS"; +# +# server { +# listen localhost:110; +# protocol pop3; +# proxy on; +# } +# +# server { +# listen localhost:143; +# protocol imap; +# proxy on; +# } +#} \ No newline at end of file diff --git a/webvirtcloud.sh b/webvirtcloud.sh index f2781fd..3aba4cb 100755 --- a/webvirtcloud.sh +++ b/webvirtcloud.sh @@ -119,7 +119,7 @@ install_packages () { fi done; ;; - fedora|uos|openEuler) + fedora|openEuler) for p in $PACKAGES; do if dnf list installed "$p" >/dev/null 2>&1; then echo " * $p already installed" @@ -129,6 +129,24 @@ install_packages () { fi done; ;; + uos) + if test "${codename}" == "eagle"; then + check_package_cmd=("dpkg" "-s") + install_package_cmd="apt-get install -y" + else + check_package_cmd=("dnf" "list" "installed") + install_package_cmd="dnf -y install" + fi + for p in $PACKAGES; do + # shellcheck disable=SC2048 + if ${check_package_cmd[*]} "$p" >/dev/null 2>&1; then + echo " * $p already installed" + else + echo " * Installing $p" + log "${install_package_cmd} $p" + fi + done + ;; esac } @@ -142,7 +160,12 @@ configure_nginx () { chown -R "$nginx_group":"$nginx_group" /var/lib/nginx # Copy new configuration and webvirtcloud.conf echo " * Copying Nginx configuration" - cp "$APP_PATH"/conf/nginx/"$distro"_nginx.conf /etc/nginx/nginx.conf + local nginx_template_conf + nginx_template_conf="${APP_PATH}/conf/nginx/${distro}_${codename}_nginx.conf" + if ! test -f "${nginx_template_conf}"; then + nginx_template_conf="${APP_PATH}/conf/nginx/${distro}_nginx.conf" + fi + cp "${nginx_template_conf}" /etc/nginx/nginx.conf cp "$APP_PATH"/conf/nginx/webvirtcloud.conf /etc/nginx/conf.d/ if [ -n "$fqdn" ]; then @@ -166,7 +189,8 @@ configure_supervisor () { create_user () { echo "* Creating webvirtcloud user." - if [ "$distro" == "ubuntu" ] || [ "$distro" == "debian" ] ; then + if [ "$distro" == "ubuntu" ] || [ "$distro" == "debian" ] || + [[ "$distro" == "uos" && "$codename" == "eagle" ]]; then adduser --quiet --disabled-password --gecos '""' "$APP_USER" else adduser "$APP_USER" @@ -242,7 +266,7 @@ install_webvirtcloud () { } set_firewall () { - if [ "$(firewall-cmd --state)" == "running" ]; then + if test -n "$(command -v firewall-cmd)" && test "$(firewall-cmd --state)" == "running"; then echo "* Configuring firewall to allow HTTP & novnc traffic." log "firewall-cmd --zone=public --add-port=http/tcp --permanent" log "firewall-cmd --zone=public --add-port=$novncd_port/tcp --permanent" @@ -344,13 +368,25 @@ case $distro in supervisor_file_name=webvirtcloud.ini ;; *Uos*|*uos*) - echo " The installer has detected $distro version $version." + # codename may be fuyu, kongzi, eagle or empty string. + output_expand="" + if test -n "${codename}"; then + output_expand=" codename ${codename}" + fi + echo " The installer has detected $distro version $version${output_expand}." distro=uos - 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 + if test "${codename}" == "eagle"; then + nginx_group=www-data + supervisor_service=supervisor + supervisor_conf_path=/etc/supervisor/conf.d + supervisor_file_name=webvirtcloud.conf + else + nginx_group=nginx + supervisor_service=supervisord + supervisor_conf_path=/etc/supervisord.d + supervisor_file_name=webvirtcloud.ini + fi ;; *OpenEuler*|*openEuler*) echo " The installer has detected $distro version $version." @@ -513,7 +549,11 @@ case $distro in tzone=\'$(timedatectl|grep "Time zone"| awk '{print $3}')\' echo "* Installing OS requirements." - PACKAGES="git python3-virtualenv python3-devel python3-pip libvirt-devel glibc gcc nginx supervisor python3-lxml python3-libguestfs iproute-tc cyrus-sasl-md5" + if test "${codename}" == "eagle"; then + PACKAGES="git virtualenv python3-virtualenv python3-dev python3-lxml libvirt-dev zlib1g-dev libxslt1-dev nginx supervisor libsasl2-modules gcc pkg-config python3-guestfs uuid" + else + PACKAGES="git python3-virtualenv python3-devel python3-pip libvirt-devel glibc gcc nginx supervisor python3-lxml python3-libguestfs iproute-tc cyrus-sasl-md5" + fi install_packages set_hosts