Skip to content

Commit 9324b9c

Browse files
committed
update installation scripts
1 parent b909a81 commit 9324b9c

2 files changed

Lines changed: 68 additions & 23 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ WebVirtCloud is a virtualization web interface for admins and users. It can dele
3232

3333
## Quick Install with Installer (Beta)
3434

35-
Install an OS and run specified commands. Installer supported OSes: Ubuntu 18.04/20.04, Debian 10/11, Centos/OEL/RHEL 8.
35+
Install an OS and run specified commands. Installer supported OSes: Ubuntu 20.04/22.04, Debian 10/11, Rocky/Alma/OEL/RHEL 10.
3636
It can be installed on a virtual machine, physical host or on a KVM host.
3737

3838
```bash
@@ -94,7 +94,7 @@ Done!!
9494

9595
Go to http://serverip and you should see the login screen.
9696

97-
### Install WebVirtCloud panel (CentOS8/OEL8)
97+
### Install WebVirtCloud panel (RHEL Based OS 8/9/10)
9898

9999
```bash
100100
sudo yum -y install epel-release
@@ -123,7 +123,7 @@ python3 manage.py migrate
123123
python3 manage.py collectstatic --noinput
124124
```
125125

126-
#### Configure the supervisor for CentOS
126+
#### Configure the supervisor for RHEL Based OS
127127

128128
Add the following after the [include] line (after **files = ...** actually):
129129
```bash

webvirtcloud.sh

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ configure_nginx () {
181181
configure_supervisor () {
182182
# Copy template supervisor service for gunicorn and novnc
183183
echo " * Copying supervisor configuration"
184+
mkdir -p "$supervisor_conf_path" > /dev/null 2>&1
184185
cp "$APP_PATH"/conf/supervisor/webvirtcloud.conf "$supervisor_conf_path"/"$supervisor_file_name"
185186
nginx_group_escape="$(echo -n "$nginx_group"|sed -e 's/[](){}<>=:\!\?\+\|\/\&$*.^[]/\\&/g')"
186187
sed -i "s|^\\(user=\\).*|\\1$nginx_group_escape|" "$supervisor_conf_path/$supervisor_file_name"
@@ -208,8 +209,40 @@ run_as_app_user () {
208209
fi
209210
}
210211

212+
check_python () {
213+
# check if python3 is installed.
214+
if ! hash "$PYTHON" 2>/dev/null; then
215+
echo "Python3 is not installed. Please install Python3 and try again."
216+
exit 1
217+
fi
218+
219+
# check if python3 version is grater than 3.10 amd set it as default
220+
if ! "$PYTHON" -c 'import sys; assert sys.version_info >= (3, 10)' >/dev/null 2>&1; then
221+
echo "Your Python version is less than 3.10. This script requires Python 3.10 or greater."
222+
echo "Please install Python 3.10 or greater and set it as the default version."
223+
echo "Use update-alternatives command to set default python version to latest."
224+
echo "For example: sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1"
225+
echo "Then run this script again."
226+
echo "Do not forget to install pip3 and python3-devel for python3.10 or later."
227+
exit 1
228+
fi
229+
230+
# check if pip3 is installed
231+
if ! hash pip3 2>/dev/null; then
232+
echo "pip3 is not installed. Please install pip3 and try again."
233+
exit 1
234+
fi
235+
}
236+
211237
activate_python_environment () {
212238
cd "$APP_PATH" || exit
239+
# Check if virtualenv is installed
240+
if ! "$PYTHON" -c 'import virtualenv' >/dev/null 2>&1; then
241+
echo "Virtualenv is not installed. Please install virtualenv and try again."
242+
exit 1
243+
fi
244+
# Create a virtual environment
245+
echo "* Creating virtual environment in $APP_PATH/venv"
213246
virtualenv -p "$PYTHON" venv
214247
# shellcheck disable=SC1091
215248
source venv/bin/activate
@@ -254,6 +287,9 @@ install_webvirtcloud () {
254287
done
255288
sed -i "s|^\\(CSRF_TRUSTED_ORIGINS = \\).*|\\1\[ \'http://$fqdn\', $host_ip ]|" /srv/webvirtcloud/webvirtcloud/settings.py
256289

290+
echo "* Checking up Python3 version."
291+
check_python
292+
257293
echo "* Activate virtual environment."
258294
activate_python_environment
259295

@@ -308,19 +344,19 @@ set_hosts () {
308344
}
309345

310346
restart_supervisor () {
311-
echo "* Setting Supervisor to start on boot and restart."
312-
log "systemctl enable $supervisor_service"
313-
#systemctl enable $supervisor_service
314-
log "systemctl restart $supervisor_service"
315-
#systemctl restart $supervisor_service
347+
echo "* Setting Supervisor to start on boot and restart."
348+
log "systemctl enable $supervisor_service"
349+
#systemctl enable $supervisor_service
350+
log "systemctl restart $supervisor_service"
351+
#systemctl restart $supervisor_service
316352
}
317353

318354
restart_nginx () {
319-
echo "* Setting Nginx to start on boot and starting Nginx."
320-
log "systemctl enable nginx.service"
321-
#systemctl enable nginx.service
322-
log "systemctl restart nginx.service"
323-
#systemctl restart nginx.service
355+
echo "* Setting Nginx to start on boot and starting Nginx."
356+
log "systemctl enable nginx.service"
357+
#systemctl enable nginx.service
358+
log "systemctl restart nginx.service"
359+
#systemctl restart nginx.service
324360
}
325361

326362

@@ -350,7 +386,7 @@ echo '
350386
'
351387

352388
echo ""
353-
echo " Welcome to Webvirtcloud Installer for RHEL&Alternatives, Fedora, Debian and Ubuntu!"
389+
echo " Welcome to Webvirtcloud Installer for RHEL Based OSes, Debian and Ubuntu!"
354390
echo ""
355391
shopt -s nocasematch
356392
case $distro in
@@ -475,7 +511,7 @@ echo "========="
475511
case $distro in
476512
debian)
477513
if [[ "$version" -ge 9 ]]; then
478-
# Install for Debian 9.x / 10.x
514+
# Install for Debian 9.x / 10.x / 12.x
479515
tzone=\'$(cat /etc/timezone)\'
480516

481517
echo -n "* Updating installed packages."
@@ -503,7 +539,7 @@ case $distro in
503539
fi
504540
;;
505541
ubuntu)
506-
if [ "$version" == "18.04" ] || [ "$version" == "20.04" ]; then
542+
if [ "$version" == "18.04" ] || [ "$version" == "20.04" ] || [ "$version" == "22.04" ]; then
507543
# Install for Ubuntu 18 / 20
508544
tzone=\'$(cat /etc/timezone)\'
509545

@@ -532,26 +568,36 @@ case $distro in
532568
fi
533569
;;
534570
centos)
535-
if [[ "$version" =~ ^8 ]] || [[ "$version" =~ ^9 ]]; then
536-
# Install for CentOS/Redhat 8
571+
if [[ "$version" =~ ^10 ]]; then
572+
# Install for CentOS/Redhat 10
537573
tzone=\'$(timedatectl|grep "Time zone"| awk '{print $3}')\'
538574

539-
echo "* Adding wget & epel-release repository."
540-
log "yum -y install wget epel-release"
575+
if command -v "crb" >/dev/null 2>&1; then
576+
echo "* CRB Repo is found, enabling it."
577+
log "crb enable > /dev/null 2>&1"
578+
else
579+
echo "* Enabling CRB repository."
580+
log "dnf config-manager --set-enabled crb"
581+
fi
582+
583+
echo "* Adding wget & epel-release & supervisor repository."
584+
log "yum -y install wget epel-release supervisor"
541585

542586
echo "* Installing OS requirements."
543587
PACKAGES="git python3-virtualenv python3-devel libvirt-devel glibc gcc nginx python3-lxml python3-libguestfs iproute-tc cyrus-sasl-md5 openldap-devel"
544588
install_packages
545589

546590
set_hosts
547591

592+
echo "* Configuring virtualenv."
593+
log "pip3 install virtualenv"
548594
install_webvirtcloud
549595

550596
echo "* Configuring Nginx."
551597
configure_nginx
552598

553599
echo "* Configuring Supervisor."
554-
log "pip install supervisor "
600+
log "pip3 install supervisor "
555601
configure_supervisor
556602

557603
set_firewall
@@ -561,9 +607,8 @@ case $distro in
561607
restart_supervisor
562608
restart_nginx
563609

564-
565610
else
566-
echo "Unsupported CentOS version. Version found: $version"
611+
echo "Unsupported RHEL Based OS($distro) version. Version found: $version"
567612
exit 1
568613
fi
569614
;;

0 commit comments

Comments
 (0)