diff --git a/README.md b/README.md index 63bf2e4a..23aae219 100644 --- a/README.md +++ b/README.md @@ -257,15 +257,18 @@ A compute node is a KVM host the panel manages over libvirt. docker compose exec -u www-data webvirtcloud ssh root@ true # no password or prompt: ready ``` -3. Install or update the `gstfsd` daemon on the compute node. It sets the root password and SSH key of a shut-off VM: +3. Install or update the `gstfsd` daemon on the compute node (the bootstrap script does this too). It sets the root password and SSH key of a shut-off VM: ```bash curl -fsSL https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/daemon/gstfsd | sudo tee /usr/local/bin/gstfsd > /dev/null sudo chmod +x /usr/local/bin/gstfsd - sudo systemctl restart supervisor 2>/dev/null || sudo systemctl restart supervisord + curl -fsSL https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/systemd/webvirt-gstfsd.service | sudo tee /etc/systemd/system/webvirt-gstfsd.service > /dev/null + sudo systemctl daemon-reload && sudo systemctl enable webvirt-gstfsd && sudo systemctl restart webvirt-gstfsd ``` - It listens on 127.0.0.1:16510 only, which serves a panel on the same host. For a remote panel, uncomment the `environment=GSTFSD_BIND_HOST="0.0.0.0",GSTFSD_ALLOW_REMOTE="1"` line of its supervisor program (`conf/supervisor/gstfsd.conf`) and restart supervisor. It is unauthenticated: allow TCP 16510 only from the panel's IP. + It listens on 127.0.0.1:16510 only, which serves a panel on the same host. For a remote panel, run `sudo systemctl edit webvirt-gstfsd`, add `[Service]` and `Environment=GSTFSD_BIND_HOST=0.0.0.0 GSTFSD_ALLOW_REMOTE=1`, and restart it. It is unauthenticated: allow TCP 16510 only from the panel's IP. + + A compute that ran gstfsd under supervisor: remove its program first (`/etc/supervisor/conf.d/gstfsd.conf` on Debian / Ubuntu, `/etc/supervisord.d/gstfsd.ini` on RHEL / openSUSE), run `sudo supervisorctl update`, and remove supervisor once nothing else uses it. 4. Add the compute on the panel's Computes page. @@ -432,7 +435,7 @@ mv /etc/supervisord.d/webvirtcloud.ini /root/webvirtcloud-supervisor.conf supervisorctl update ``` -Move the `environment=` values of that config into `/etc/default/webvirtcloud` (root, mode 600), one `NAME='value'` per line; leave out the worker's `WEBVIRTCLOUD_LOG_FILE`. Step 4 installs and starts the systemd units. Remove supervisor once nothing else uses it (on a compute node, gstfsd may). +Move the `environment=` values of that config into `/etc/default/webvirtcloud` (root, mode 600), one `NAME='value'` per line; leave out the worker's `WEBVIRTCLOUD_LOG_FILE`. Step 4 installs and starts the systemd units. Remove supervisor once nothing else uses it; a compute moves gstfsd as in [Adding a Compute Node](#adding-a-compute-node), step 3. ### Installer and manual installation @@ -600,7 +603,7 @@ A version from before v3.0.0 has no worker: `systemctl disable --now webvirt-wor - Manual installs that keep their own `settings.py` copy the SQLite `OPTIONS` and `TEST` entries from `settings.py.template` and add `"operations"` to `INSTALLED_APPS`. - The SQLite database must be on a local file system (WAL). - Outside compose, stop the Docker container with `docker stop -t 95` so the worker can finish running jobs. -- Installer and manual installations run the panel as systemd units (`webvirt-cloud`, `webvirt-novncd`, `webvirt-socketiod`, `webvirt-worker`) instead of supervisor; see [Moving from supervisor to systemd](#moving-from-supervisor-to-systemd). Service settings go into `/etc/default/webvirtcloud`, service output into the journal (`journalctl -u webvirt-cloud`); the app log stays in `data/`. +- Installer and manual installations run the panel as systemd units (`webvirt-cloud`, `webvirt-novncd`, `webvirt-socketiod`, `webvirt-worker`) and computes run `webvirt-gstfsd`, instead of supervisor; see [Moving from supervisor to systemd](#moving-from-supervisor-to-systemd). Service settings go into `/etc/default/webvirtcloud`, service output into the journal (`journalctl -u webvirt-cloud`); the app log stays in `data/`. ## Usage diff --git a/conf/supervisor/gstfsd.conf b/conf/supervisor/gstfsd.conf deleted file mode 100644 index a5976d69..00000000 --- a/conf/supervisor/gstfsd.conf +++ /dev/null @@ -1,9 +0,0 @@ -[program:gstfsd] -command=/usr/bin/python3 /usr/local/bin/gstfsd -directory=/usr/local/bin -user=root -autostart=true -autorestart=true -redirect_stderr=true -# Remote compute (unauthenticated root service, trusted networks only): -;environment=GSTFSD_BIND_HOST="0.0.0.0",GSTFSD_ALLOW_REMOTE="1" diff --git a/conf/systemd/webvirt-gstfsd.service b/conf/systemd/webvirt-gstfsd.service index 53950027..ead89d6e 100644 --- a/conf/systemd/webvirt-gstfsd.service +++ b/conf/systemd/webvirt-gstfsd.service @@ -1,22 +1,12 @@ [Unit] -Description=Webvirt Cloud GSTFSD +Description=WebVirtCloud gstfsd (root password and SSH keys of shut-off VMs) Wants=network-online.target After=network-online.target [Service] -Type=simple +ExecStart=/usr/bin/python3 /usr/local/bin/gstfsd Restart=on-failure RestartSec=10 -LimitNOFILE=64000 -# Remote compute (unauthenticated root service, trusted networks only): -#Environment=GSTFSD_BIND_HOST=0.0.0.0 -#Environment=GSTFSD_ALLOW_REMOTE=1 - -ExecStart=/usr/bin/python3 /usr/local/bin/gstfsd - -# Make sure stderr/stdout is captured in the systemd journal. -StandardOutput=journal -StandardError=journal [Install] WantedBy=multi-user.target diff --git a/dev/libvirt-bootstrap.sh b/dev/libvirt-bootstrap.sh index e3c3b85c..30056c48 100644 --- a/dev/libvirt-bootstrap.sh +++ b/dev/libvirt-bootstrap.sh @@ -384,13 +384,21 @@ __check_end_of_life_versions # # CentOS Install Functions # +# gstfsd and its systemd unit, enabled and (re)started +install_gstfsd() { + curl -fsSL https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/daemon/gstfsd -o /usr/local/bin/gstfsd && + chmod +x /usr/local/bin/gstfsd && + curl -fsSL https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/systemd/webvirt-gstfsd.service -o /etc/systemd/system/webvirt-gstfsd.service && + systemctl daemon-reload && systemctl enable webvirt-gstfsd && systemctl restart webvirt-gstfsd || return 1 +} + install_centos() { yum -y install epel-release || return 1 if [ "$DISTRO_MAJOR_VERSION" -lt 8 ]; then - yum -y install qemu-kvm libvirt bridge-utils python-libguestfs libguestfs-tools supervisor cyrus-sasl-md5 || return 1 + yum -y install qemu-kvm libvirt bridge-utils python-libguestfs libguestfs-tools cyrus-sasl-md5 || return 1 else - yum -y install qemu-kvm libvirt python3-libguestfs libguestfs-tools cyrus-sasl-md5 supervisor || return 1 + yum -y install qemu-kvm libvirt python3-libguestfs libguestfs-tools cyrus-sasl-md5 || return 1 fi return 0 } @@ -425,25 +433,7 @@ install_centos_post() { echoerror "/etc/sasl2/libvirt.conf not found. Exiting..." exit 1 fi - if [ "$DISTRO_MAJOR_VERSION" -lt 7 ]; then - if [ -f /etc/supervisord.conf ]; then - curl https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/daemon/gstfsd > /usr/local/bin/gstfsd - chmod +x /usr/local/bin/gstfsd - curl https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/supervisor/gstfsd.conf >> /etc/supervisor.conf - else - echoerror "Supervisor not found. Exiting..." - exit 1 - fi - else - if [ -f /etc/supervisord.conf ]; then - curl https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/daemon/gstfsd > /usr/local/bin/gstfsd - chmod +x /usr/local/bin/gstfsd - curl https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/supervisor/gstfsd.conf > /etc/supervisord.d/gstfsd.ini - else - echoerror "Supervisor not found. Exiting..." - exit 1 - fi - fi + install_gstfsd || return 1 return 0 } @@ -464,9 +454,7 @@ daemons_running_centos() { fi elif [ "$DISTRO_MAJOR_VERSION" -ge 10 ]; then # EL10 runs the modular daemons; virtproxyd serves remote TCP (SASL). - # supervisord runs gstfsd, so it must start at boot too. systemctl enable --now virtqemud.socket virtproxyd.socket virtproxyd-tcp.socket || return 1 - systemctl enable supervisord.service || return 1 else if [ -f /usr/lib/systemd/system/libvirtd-tcp.socket ]; then systemctl stop libvirtd-tcp.socket > /dev/null 2>&1 @@ -479,14 +467,6 @@ daemons_running_centos() { systemctl start libvirt-guests.service fi - if [ -f /etc/init.d/supervisord ]; then - service supervisord stop > /dev/null 2>&1 - service supervisord start - fi - if [ -f /usr/lib/systemd/system/supervisord.service ]; then - systemctl stop supervisord.service > /dev/null 2>&1 - systemctl start supervisord.service || return 1 - fi return 0 } # @@ -499,7 +479,7 @@ daemons_running_centos() { # Fedora Install Functions # install_fedora() { - yum -y install kvm libvirt bridge-utils python3-libguestfs supervisor || return 1 + yum -y install kvm libvirt bridge-utils python3-libguestfs || return 1 return 0 } @@ -524,14 +504,7 @@ install_fedora_post() { echoerror "/etc/libvirt/qemu.conf not found. Exiting..." exit 1 fi - if [ -f /etc/supervisord.conf ]; then - curl https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/daemon/gstfsd > /usr/local/bin/gstfsd - chmod +x /usr/local/bin/gstfsd - curl https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/supervisor/gstfsd.conf > /etc/supervisord.d/gstfsd.ini - else - echoerror "Supervisor not found. Exiting..." - exit 1 - fi + install_gstfsd || return 1 return 0 } @@ -544,10 +517,6 @@ daemons_running_fedora() { systemctl stop libvirt-guests.service > /dev/null 2>&1 systemctl start libvirt-guests.service fi - if [ -f /usr/lib/systemd/system/supervisord.service ]; then - systemctl stop supervisord.service > /dev/null 2>&1 - systemctl start supervisord.service - fi return 0 } # @@ -560,8 +529,7 @@ daemons_running_fedora() { # Opensuse Install Functions # install_opensuse() { - zypper -n install -l qemu-kvm libvirt libvirt-daemon-qemu libvirt-client bridge-utils python3-libguestfs supervisor || \ - zypper -n install -l kvm libvirt bridge-utils python3-libguestfs python3-supervisor || \ + zypper -n install -l qemu-kvm libvirt libvirt-daemon-qemu libvirt-client bridge-utils python3-libguestfs || \ zypper -n install -l kvm libvirt bridge-utils python3-libguestfs || return 1 return 0 } @@ -589,19 +557,13 @@ install_opensuse_post() { if [ -f /etc/libvirt/qemu.conf ]; then sed -i 's/#[ ]*vnc_listen.*/vnc_listen = "0.0.0.0"/g' /etc/libvirt/qemu.conf fi - mkdir -p /etc/supervisord.d /etc/supervisor/conf.d - if [ -f /etc/supervisord.conf ] || [ -f /etc/supervisor/supervisord.conf ]; then - curl -fsSL https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/daemon/gstfsd > /usr/local/bin/gstfsd 2>/dev/null || true - chmod +x /usr/local/bin/gstfsd 2>/dev/null || true - curl -fsSL https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/supervisor/gstfsd.conf > /etc/supervisord.d/gstfsd.ini 2>/dev/null || true - fi + install_gstfsd || return 1 return 0 } daemons_running_opensuse() { systemctl enable --now libvirtd.service 2>/dev/null || systemctl enable --now virtqemud.service 2>/dev/null || true systemctl enable --now libvirt-guests.service 2>/dev/null || true - systemctl enable --now supervisord.service 2>/dev/null || systemctl enable --now supervisor.service 2>/dev/null || true return 0 } @@ -628,9 +590,9 @@ daemons_running_suse() { install_ubuntu() { apt-get update || return 1 if [ "$DISTRO_MAJOR_VERSION" -lt 18 ]; then - apt-get -y install kvm libvirt-bin bridge-utils sasl2-bin python-guestfs supervisor || return 1 + apt-get -y install kvm libvirt-bin bridge-utils sasl2-bin python-guestfs || return 1 else - apt install -y qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager sasl2-bin python3-guestfs supervisor || return 1 + apt install -y qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager sasl2-bin python3-guestfs || return 1 fi return 0 @@ -661,14 +623,7 @@ install_ubuntu_post() { echoerror "/etc/libvirt/qemu.conf not found. Exiting..." exit 1 fi - if [ -f /etc/supervisor/supervisord.conf ]; then - wget -O /usr/local/bin/gstfsd https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/daemon/gstfsd - chmod +x /usr/local/bin/gstfsd - wget -O /etc/supervisor/conf.d/gstfsd.conf https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/supervisor/gstfsd.conf - else - echoerror "Supervisor not found. Exiting..." - exit 1 - fi + install_gstfsd || return 1 return 0 } @@ -678,11 +633,6 @@ daemons_running_ubuntu() { service libvirt-bin stop > /dev/null 2>&1 service libvirt-bin start fi - if [ -f /etc/init.d/supervisor ]; then - # Still in SysV init!? - service supervisor stop > /dev/null 2>&1 - service supervisor start - fi return 0 } # @@ -697,11 +647,11 @@ daemons_running_ubuntu() { install_debian() { apt-get update || return 1 if [ "$DISTRO_MAJOR_VERSION" -lt 10 ]; then - apt-get -y install qemu-kvm libvirt-bin bridge-utils sasl2-bin python-guestfs supervisor || return 1 + apt-get -y install qemu-kvm libvirt-bin bridge-utils sasl2-bin python-guestfs || return 1 elif [ "$DISTRO_MAJOR_VERSION" -lt 12 ]; then - apt-get -y install qemu qemu-kvm qemu-system qemu-utils libvirt-clients libvirt-daemon-system sasl2-bin python3-guestfs virtinst supervisor || return 1 + apt-get -y install qemu qemu-kvm qemu-system qemu-utils libvirt-clients libvirt-daemon-system sasl2-bin python3-guestfs virtinst || return 1 else - apt-get -y install qemu-system qemu-utils libvirt-clients libvirt-daemon-system sasl2-bin python3-guestfs virtinst supervisor || return 1 + apt-get -y install qemu-system qemu-utils libvirt-clients libvirt-daemon-system sasl2-bin python3-guestfs virtinst || return 1 fi return 0 } @@ -746,14 +696,7 @@ install_debian_post() { echoerror "/etc/sasl2/libvirt.conf not found. Exiting..." exit 1 fi - if [ -f /etc/supervisor/supervisord.conf ]; then - wget -O /usr/local/bin/gstfsd https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/daemon/gstfsd - chmod +x /usr/local/bin/gstfsd - wget -O /etc/supervisor/conf.d/gstfsd.conf https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/supervisor/gstfsd.conf - else - echoerror "Supervisor not found. Exiting..." - exit 1 - fi + install_gstfsd || return 1 return 0 } @@ -767,10 +710,6 @@ daemons_running_debian() { /etc/init.d/$LIBVIRTSVC stop > /dev/null 2>&1 /etc/init.d/$LIBVIRTSVC start fi - if [ -f /etc/init.d/supervisor ]; then - service supervisor stop > /dev/null 2>&1 - service supervisor start - fi return 0 } #