diff --git a/README.md b/README.md index 6f47e96..cfd4ae0 100644 --- a/README.md +++ b/README.md @@ -94,11 +94,11 @@ Done!! Go to http://serverip and you should see the login screen. -### Install WebVirtCloud panel (RHEL Based OS 8/9/10) +### Install WebVirtCloud panel (RHEL Based OS 8/9/10 / Rocky Linux / AlmaLinux) ```bash -sudo yum -y install epel-release -sudo yum -y install python3-virtualenv python3-devel libvirt-devel glibc gcc nginx supervisor python3-lxml git python3-libguestfs iproute-tc cyrus-sasl-md5 python3-libguestfs libsasl2-dev libldap2-dev libssl-dev +sudo dnf -y install epel-release +sudo dnf -y install python3-devel libvirt-devel python3-libvirt python3-ldap python3-lxml cyrus-sasl-devel openldap-devel openssl-devel glibc gcc nginx supervisor git python3-libguestfs iproute-tc cyrus-sasl-md5 ``` #### Creating directories and cloning repository @@ -109,13 +109,13 @@ sudo git clone https://github.com/retspen/webvirtcloud && cd webvirtcloud cp webvirtcloud/settings.py.template webvirtcloud/settings.py # now put secret key to webvirtcloud/settings.py # create secret key manually or use that command -sudo sed -r "s/SECRET_KEY = ''/SECRET_KEY = '"`python3 /srv/webvirtcloud/conf/runit/secret_generator.py`"'/" -i /srv/webvirtcloud/webvirtcloud/settings.py +sudo sed -i -E 's/SECRET_KEY = .*/SECRET_KEY = "'$(python3 /srv/webvirtcloud/conf/runit/secret_generator.py)'"/' /srv/webvirtcloud/webvirtcloud/settings.py ``` #### Start installation webvirtcloud ```bash -virtualenv-3 venv +python3 -m venv --system-site-packages venv source venv/bin/activate pip3 install -r conf/requirements.txt cp conf/nginx/webvirtcloud.conf /etc/nginx/conf.d/ @@ -123,6 +123,50 @@ python3 manage.py migrate python3 manage.py collectstatic --noinput ``` +### Local Development Setup (Rocky Linux / RHEL / Fedora / Ubuntu) + +For developers working locally on WebVirtCloud without running full production services: + +#### Rocky Linux / RHEL / Fedora: +```bash +# 1. Install system prerequisites and precompiled bindings +sudo dnf -y install python3-devel libvirt-devel python3-libvirt python3-ldap python3-lxml gcc git + +# 2. Create virtual environment with system site packages (enables zero-compilation install) +python3 -m venv --system-site-packages .venv +source .venv/bin/activate + +# 3. Install Python dependencies +pip install -r conf/requirements.txt +pip install -r dev/requirements.txt + +# 4. Initialize configuration and run local dev server +cp webvirtcloud/settings.py.template webvirtcloud/settings.py +sed -i -E 's/SECRET_KEY = .*/SECRET_KEY = "'$(python3 conf/runit/secret_generator.py)'"/' webvirtcloud/settings.py +python manage.py migrate +python manage.py runserver 0.0.0.0:8000 +``` + +#### Ubuntu / Debian: +```bash +# 1. Install system prerequisites +sudo apt-get update && sudo apt-get -y install git python3-venv python3-dev python3-lxml python3-libvirt libvirt-dev zlib1g-dev libldap2-dev libsasl2-dev gcc pkg-config + +# 2. Create virtual environment +python3 -m venv --system-site-packages .venv +source .venv/bin/activate + +# 3. Install Python dependencies +pip install -r conf/requirements.txt +pip install -r dev/requirements.txt + +# 4. Initialize configuration and run local dev server +cp webvirtcloud/settings.py.template webvirtcloud/settings.py +sed -i -E 's/SECRET_KEY = .*/SECRET_KEY = "'$(python3 conf/runit/secret_generator.py)'"/' webvirtcloud/settings.py +python manage.py migrate +python manage.py runserver 0.0.0.0:8000 +``` + #### Configure the supervisor for RHEL Based OS Add the following after the [include] line (after **files = ...** actually): diff --git a/conf/requirements.txt b/conf/requirements.txt index bc39620..778cbbc 100644 --- a/conf/requirements.txt +++ b/conf/requirements.txt @@ -11,8 +11,8 @@ drf-spectacular[sidecar]==0.28.0 eventlet==0.40.1 gunicorn==23.0.0 libsass==0.23.0 -libvirt-python==11.4.0 -lxml==6.0.0 +libvirt-python>=11.0.0 +lxml>=5.2.0 ldap3==2.9.1 markdown==3.8.2 paramiko==3.4.0 @@ -24,4 +24,4 @@ tzdata websockify==0.13.0 whitenoise==6.9.0 zipp==3.23.0 -crypt-r==3.13.1 +crypt-r>=3.13.0; python_version >= "3.13" diff --git a/instances/views.py b/instances/views.py index 54b73af..efe30af 100755 --- a/instances/views.py +++ b/instances/views.py @@ -1,4 +1,7 @@ -import crypt_r +try: + import crypt_r as crypt +except ImportError: + import crypt import json import os import re @@ -476,7 +479,7 @@ def set_root_pass(request, pk): if request.method == "POST": passwd = request.POST.get("passwd", None) if passwd: - passwd_hash = crypt_r.crypt(passwd, "$6$kgPoiREy") + passwd_hash = crypt.crypt(passwd, "$6$kgPoiREy") data = {"action": "password", "passwd": passwd_hash, "vname": instance.name} if instance.proxy.get_status() == 5: diff --git a/webvirtcloud.sh b/webvirtcloud.sh index 6800237..dbcae12 100755 --- a/webvirtcloud.sh +++ b/webvirtcloud.sh @@ -243,7 +243,7 @@ activate_python_environment () { fi # Create a virtual environment echo "* Creating virtual environment in $APP_PATH/venv" - virtualenv -p "$PYTHON" venv + virtualenv -p "$PYTHON" --system-site-packages venv # shellcheck disable=SC1091 source venv/bin/activate } @@ -584,7 +584,7 @@ case $distro in log "yum -y install wget epel-release supervisor" echo "* Installing OS requirements." - PACKAGES="git python3-virtualenv python3-devel libvirt-devel glibc gcc nginx python3-lxml python3-libguestfs iproute-tc cyrus-sasl-md5 openldap-devel" + PACKAGES="git python3-virtualenv python3-devel libvirt-devel python3-libvirt python3-ldap glibc gcc nginx python3-lxml python3-libguestfs iproute-tc cyrus-sasl-md5 openldap-devel cyrus-sasl-devel openssl-devel" install_packages set_hosts diff --git a/webvirtcloud/settings.py.template b/webvirtcloud/settings.py.template index abf3dd2..f753fe9 100644 --- a/webvirtcloud/settings.py.template +++ b/webvirtcloud/settings.py.template @@ -3,9 +3,13 @@ Django settings for webvirtcloud project. """ -import ldap import subprocess -from django_auth_ldap.config import LDAPSearch, NestedActiveDirectoryGroupType +try: + import ldap + from django_auth_ldap.config import LDAPSearch, NestedActiveDirectoryGroupType + HAS_LDAP = True +except ImportError: + HAS_LDAP = False from django.utils.translation import gettext_lazy as _ from pathlib import Path @@ -298,23 +302,24 @@ EMAIL_HOST_PASSWORD = '' # LDAP Config # -AUTH_LDAP_SERVER_URI = "ldap://example.com" -AUTH_LDAP_BIND_DN = "username@example.com" -AUTH_LDAP_BIND_PASSWORD = "password" -AUTH_LDAP_USER_SEARCH = LDAPSearch( - "CN=Users,DC=example,DC=com", ldap.SCOPE_SUBTREE, "(sAMAccountName=%(user)s)" -) -AUTH_LDAP_GROUP_SEARCH = LDAPSearch( - "CN=Users,DC=example,DC=com", ldap.SCOPE_SUBTREE, "(objectClass=group)" -) -AUTH_LDAP_GROUP_TYPE = NestedActiveDirectoryGroupType() -AUTH_LDAP_REQUIRE_GROUP = "CN=WebVirtCloud Access,CN=Users,DC=example,DC=com" -AUTH_LDAP_USER_FLAGS_BY_GROUP = { - "is_staff": "CN=WebVirtCloud Staff,CN=Users,DC=example,DC=com", - "is_superuser": "CN=WebVirtCloud Admins,CN=Users,DC=example,DC=com", -} -AUTH_LDAP_USER_ATTR_MAP = { - "first_name": "givenName", - "last_name": "sn", - "email": "mail", -} +if HAS_LDAP: + AUTH_LDAP_SERVER_URI = "ldap://example.com" + AUTH_LDAP_BIND_DN = "username@example.com" + AUTH_LDAP_BIND_PASSWORD = "password" + AUTH_LDAP_USER_SEARCH = LDAPSearch( + "CN=Users,DC=example,DC=com", ldap.SCOPE_SUBTREE, "(sAMAccountName=%(user)s)" + ) + AUTH_LDAP_GROUP_SEARCH = LDAPSearch( + "CN=Users,DC=example,DC=com", ldap.SCOPE_SUBTREE, "(objectClass=group)" + ) + AUTH_LDAP_GROUP_TYPE = NestedActiveDirectoryGroupType() + AUTH_LDAP_REQUIRE_GROUP = "CN=WebVirtCloud Access,CN=Users,DC=example,DC=com" + AUTH_LDAP_USER_FLAGS_BY_GROUP = { + "is_staff": "CN=WebVirtCloud Staff,CN=Users,DC=example,DC=com", + "is_superuser": "CN=WebVirtCloud Admins,CN=Users,DC=example,DC=com", + } + AUTH_LDAP_USER_ATTR_MAP = { + "first_name": "givenName", + "last_name": "sn", + "email": "mail", + }