mirror of
https://github.com/retspen/webvirtcloud
synced 2026-10-18 00:50:07 +00:00
refactor(install): harden bootstrap script and restore retspen upstream URLs
This commit is contained in:
parent
79c6bd4c62
commit
070e3baf75
3 changed files with 96 additions and 17 deletions
16
README.md
16
README.md
|
|
@ -32,11 +32,15 @@ WebVirtCloud is a virtualization web interface for admins and users. It can dele
|
|||
|
||||
## Quick Install with Installer (Beta)
|
||||
|
||||
Install an OS and run specified commands. Installer supported OSes: Ubuntu 20.04/22.04, Debian 10/11, Rocky/Alma/OEL/RHEL 10.
|
||||
Install an OS and run specified commands. Installer supported OSes: Ubuntu 20.04/22.04/24.04, Debian 10/11/12, Rocky/Alma/OEL/RHEL 10.
|
||||
It can be installed on a virtual machine, physical host or on a KVM host.
|
||||
|
||||
```bash
|
||||
wget https://raw.githubusercontent.com/retspen/webvirtcloud/master/install.sh
|
||||
# Using curl:
|
||||
curl -fsSL -O https://raw.githubusercontent.com/retspen/webvirtcloud/master/install.sh
|
||||
# Or using wget:
|
||||
# wget https://raw.githubusercontent.com/retspen/webvirtcloud/master/install.sh
|
||||
|
||||
chmod 744 install.sh
|
||||
# run with sudo or root user
|
||||
./install.sh
|
||||
|
|
@ -48,16 +52,14 @@ chmod 744 install.sh
|
|||
|
||||
You should generate SECRET_KEY after cloning repository. Then put it into webvirtcloud/settings.py.
|
||||
|
||||
```python3
|
||||
import random, string
|
||||
haystack = string.ascii_letters + string.digits + string.punctuation
|
||||
print(''.join([random.SystemRandom().choice(haystack) for _ in range(50)]))
|
||||
```bash
|
||||
python3 -c 'import secrets; print(secrets.token_urlsafe(50))'
|
||||
```
|
||||
|
||||
### Install WebVirtCloud panel (Ubuntu 18.04+ LTS)
|
||||
|
||||
```bash
|
||||
sudo apt-get -y install git virtualenv python3-virtualenv python3-dev python3-lxml libvirt-dev zlib1g-dev libxslt1-dev nginx supervisor libsasl2-modules gcc pkg-config python3-guestfs libsasl2-dev libldap2-dev libssl-dev
|
||||
sudo apt-get -y install git python3-venv python3-virtualenv python3-dev python3-lxml libvirt-dev zlib1g-dev libxslt1-dev nginx supervisor libsasl2-modules gcc pkg-config python3-guestfs libsasl2-dev libldap2-dev libssl-dev
|
||||
git clone https://github.com/retspen/webvirtcloud
|
||||
cd webvirtcloud
|
||||
cp webvirtcloud/settings.py.template webvirtcloud/settings.py
|
||||
|
|
|
|||
95
install.sh
Normal file → Executable file
95
install.sh
Normal file → Executable file
|
|
@ -1,24 +1,101 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# WebVirtCloud Installer Bootstrap Script
|
||||
# https://github.com/retspen/webvirtcloud
|
||||
#
|
||||
|
||||
# ensure running as root
|
||||
set -o pipefail
|
||||
|
||||
# Display help without requiring root privileges
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "-h" ] || [ "$arg" = "--help" ]; then
|
||||
echo "WebVirtCloud Installer Bootstrap"
|
||||
echo ""
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo ""
|
||||
echo "OPTIONS:"
|
||||
echo " -v, --verbose Enable verbose installation output."
|
||||
echo " -h, --help Show this help message and exit."
|
||||
echo ""
|
||||
echo "Environment Variables:"
|
||||
echo " WEBVIRTCLOUD_SCRIPT_URL Custom URL to fetch webvirtcloud.sh installer"
|
||||
echo " APP_REPO_URL Custom WebVirtCloud git repository URL"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Ensure script runs with root privileges
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
#Debian doesnt have sudo if root has a password.
|
||||
if ! hash sudo 2>/dev/null; then
|
||||
exec su -c "$0" "$@"
|
||||
SCRIPT_PATH="$(cd "$(dirname "$0")" 2>/dev/null && pwd)/$(basename "$0")"
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
exec sudo "$SCRIPT_PATH" "$@"
|
||||
elif command -v su >/dev/null 2>&1; then
|
||||
exec su -c "$SCRIPT_PATH $*"
|
||||
else
|
||||
exec sudo "$0" "$@"
|
||||
echo "Error: Root privileges required, but neither 'sudo' nor 'su' was found." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# Locate existing webvirtcloud.sh or download it securely
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
||||
TMP_DIR=""
|
||||
|
||||
cleanup() {
|
||||
if [ -n "$TMP_DIR" ] && [ -d "$TMP_DIR" ]; then
|
||||
rm -rf "$TMP_DIR"
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
download_installer() {
|
||||
local url="$1"
|
||||
local dest="$2"
|
||||
echo "* Downloading webvirtcloud installer from $url..."
|
||||
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
curl -fsSL --connect-timeout 15 --retry 3 -o "$dest" "$url"
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
wget -q --timeout=15 --tries=3 -O "$dest" "$url"
|
||||
else
|
||||
echo "Error: Neither 'curl' nor 'wget' was found. Please install curl or wget." >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -f "$SCRIPT_DIR/webvirtcloud.sh" ]; then
|
||||
INSTALLER="$SCRIPT_DIR/webvirtcloud.sh"
|
||||
elif [ -f "./webvirtcloud.sh" ]; then
|
||||
INSTALLER="./webvirtcloud.sh"
|
||||
else
|
||||
INSTALLER="./webvirtcloud.sh"
|
||||
wget -O "$INSTALLER" "${WEBVIRTCLOUD_SCRIPT_URL:-https://raw.githubusercontent.com/catborise/webvirtcloud/master/webvirtcloud.sh}"
|
||||
TMP_DIR="$(mktemp -d -t wvc-install.XXXXXX)"
|
||||
INSTALLER="$TMP_DIR/webvirtcloud.sh"
|
||||
UPSTREAM_URL="${WEBVIRTCLOUD_SCRIPT_URL:-https://raw.githubusercontent.com/retspen/webvirtcloud/master/webvirtcloud.sh}"
|
||||
download_installer "$UPSTREAM_URL" "$INSTALLER"
|
||||
fi
|
||||
|
||||
# Ensure installer is executable
|
||||
chmod 744 "$INSTALLER"
|
||||
"$INSTALLER" "$@" 2>&1 | tee -a /var/log/webvirtcloud-install.log
|
||||
|
||||
# Prepare log file location
|
||||
LOG_FILE="/var/log/webvirtcloud-install.log"
|
||||
mkdir -p "$(dirname "$LOG_FILE")" 2>/dev/null || true
|
||||
if ! touch "$LOG_FILE" 2>/dev/null; then
|
||||
LOG_FILE="/tmp/webvirtcloud-install.log"
|
||||
fi
|
||||
|
||||
echo "* Executing installer ($INSTALLER)..."
|
||||
echo "* Output is logged to $LOG_FILE"
|
||||
|
||||
# Execute installer and preserve exit status across pipe
|
||||
"$INSTALLER" "$@" 2>&1 | tee -a "$LOG_FILE"
|
||||
INSTALL_STATUS="${PIPESTATUS[0]}"
|
||||
|
||||
if [ "$INSTALL_STATUS" -ne 0 ]; then
|
||||
echo "" >&2
|
||||
echo "Error: WebVirtCloud installation failed with exit code $INSTALL_STATUS." >&2
|
||||
echo "See $LOG_FILE for details." >&2
|
||||
exit "$INSTALL_STATUS"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ fi
|
|||
clear
|
||||
|
||||
readonly APP_USER="wvcuser"
|
||||
readonly APP_REPO_URL="${APP_REPO_URL:-https://github.com/catborise/webvirtcloud.git}"
|
||||
readonly APP_REPO_URL="${APP_REPO_URL:-https://github.com/retspen/webvirtcloud.git}"
|
||||
readonly APP_NAME="webvirtcloud"
|
||||
readonly APP_PATH="/srv/$APP_NAME"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue