Skip to content

Commit f835997

Browse files
Ice Lakejaapmarcus
andauthored
RHEL & 1:1 distro support (#2749)
* RHEL version checker * use arch binary instead uname * modify install script to support RHEL * add support for RPM based distro * add RPM repositories * choose libdir depending on architecture * common files for both debian and rhel As @jaapmarcus raised concern to have common config files for both debian and rhel in github comment. https://github.com/hestiacp/hestiacp/pull/2731#pullrequestreview-1030683914 This is initial commit to have a common base config files for both debian and rhel. * Disable bats testing for branch * architecture dependent result dir * quota & linting for RHEL * HestiaCP repo * RHEL support in installer Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
1 parent 19d5ef4 commit f835997

33 files changed

+215
-290
lines changed

.drone.yml

Lines changed: 1 addition & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,3 @@
1-
---
2-
kind: pipeline
3-
type: ssh
4-
name: Ubuntu | Nginx + Apache2
5-
6-
concurrency:
7-
limit: 1
8-
9-
server:
10-
host:
11-
from_secret: server_address
12-
user:
13-
from_secret: username
14-
ssh_key:
15-
from_secret: ssh_key
16-
17-
platform:
18-
os: linux
19-
arch: amd64
20-
21-
steps:
22-
- name: Download submodules
23-
image: alpine/git
24-
commands:
25-
- git submodule update --init --recursive
26-
- name: Build Hestia package and install
27-
commands:
28-
- ./src/hst_autocompile.sh --hestia --install '~localsrc'
29-
- name: Run system / user tests
30-
commands:
31-
- bats ./test/test.bats
32-
- name: Run restore tests
33-
commands:
34-
- bats ./test/restore.bats
35-
- name: Run config tests
36-
commands:
37-
- bats ./test/config-tests.bats
38-
39-
trigger:
40-
event: [ pull_request, push ]
41-
ref:
42-
- refs/heads/staging/*
43-
- refs/heads/beta
44-
- refs/heads/release
45-
- refs/heads/main
46-
- refs/pull/*/head
47-
48-
---
49-
kind: pipeline
50-
type: ssh
51-
name: Debian | Nginx
52-
53-
concurrency:
54-
limit: 1
55-
56-
server:
57-
host:
58-
from_secret: server_address2
59-
user:
60-
from_secret: username
61-
ssh_key:
62-
from_secret: ssh_key
63-
64-
platform:
65-
os: linux
66-
arch: amd64
67-
68-
steps:
69-
- name: Download submodules
70-
image: alpine/git
71-
commands:
72-
- git submodule update --init --recursive
73-
- name: Build Hestia package install
74-
commands:
75-
- ./src/hst_autocompile.sh --hestia --install '~localsrc'
76-
- name: Run system / user tests
77-
commands:
78-
- bats ./test/test.bats
79-
- name: Run restore tests
80-
commands:
81-
- bats ./test/restore.bats
82-
- name: Run Letsencrypt test against Staging
83-
commands:
84-
- cp /root/le-env.sh /tmp/hestia-le-env.sh
85-
- bats ./test/letsencrypt.bats
86-
- name: Run config tests
87-
commands:
88-
- bats ./test/config-tests.bats
89-
90-
trigger:
91-
event: [ pull_request, push ]
92-
ref:
93-
- refs/heads/staging/*
94-
- refs/heads/beta
95-
- refs/heads/release
96-
- refs/heads/main
97-
- refs/pull/*/head
98-
991
---
1002
kind: pipeline
1013
type: docker
@@ -123,54 +25,7 @@ trigger:
12325
- refs/heads/main
12426
- refs/pull/*/head
12527

126-
---
127-
kind: pipeline
128-
type: docker
129-
name: Push to beta atp server
130-
131-
platform:
132-
os: linux
133-
arch: amd64
134-
135-
steps:
136-
- name: Build
137-
image: debian:bullseye
138-
commands:
139-
- ln -snf /etc/localtime && echo CET > /etc/timezone
140-
- ./src/hst_autocompile.sh --dontinstalldeps --hestia --debug --cross --noinstall --keepbuild --debug '~localsrc'
141-
- mkdir -p ./hestia/
142-
- mv /tmp/hestiacp-src/deb/*.deb ./hestia/
143-
- name: Upload
144-
image: appleboy/drone-scp
145-
settings:
146-
host:
147-
from_secret: apt_server
148-
user: root
149-
key:
150-
from_secret: ssh_key
151-
port: 22
152-
command_timeout: 2m
153-
target: /root/
154-
source:
155-
- ./hestia/*
156-
- name: Publish
157-
image: appleboy/drone-ssh
158-
settings:
159-
host:
160-
from_secret: apt_server
161-
user: root
162-
key:
163-
from_secret: ssh_key
164-
port: 22
165-
command_timeout: 2m
166-
script:
167-
- freight-add ./hestia/*.deb apt/bionic apt/focal apt/jammy apt/stretch apt/buster apt/bullseye
168-
- freight-cache
169-
- rm -fr ./hestia/
170-
171-
trigger:
172-
event: [ promote]
17328

17429
---
17530
kind: signature
176-
hmac: a191a477aa337f2efff534022164906ff20ef2b6340ec808d128c09a06d7eaa3
31+
hmac: 4eec34ee92f63737d6a976140e6e54adf637ebbb4836b17a083c560a4440c54f

bin/v-add-backup-host

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ path=${5-/backup}
2121
port=$6
2222

2323
# CPU Architecture
24-
arch=$(uname -m)
24+
arch=$(arch)
2525

2626
# Includes
2727
# shellcheck source=/usr/local/hestia/func/main.sh

bin/v-add-firewall-ipset

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ IPSET_PATH="$HESTIA/data/firewall/ipset"
4444

4545
# Ensure ipset is installed
4646
if [ -z "$IPSET_BIN" ]; then
47-
apt-get --quiet --yes install ipset > /dev/null
47+
if [ -f '/etc/redhat-release' ]; then
48+
dnf install -q -y ipset > /dev/null
49+
else
50+
apt-get --quiet --yes install ipset > /dev/null
51+
fi
4852
check_result $? "Installing ipset package"
4953

5054
IPSET_BIN="$(which ipset)"

bin/v-add-sys-quota

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,13 @@ fi
3535
# Checking quota package
3636
quota=$(which --skip-alias --skip-functions quota 2>/dev/null)
3737
if [ $? -ne 0 ]; then
38-
if [ -d "/etc/sysconfig" ]; then
39-
yum -y install quota >/dev/null 2>&1
40-
check_result $? "quota package installation failed" "$E_UPDATE"
38+
if [ -f "/etc/redhat-release" ]; then
39+
dnf -y install quota >/dev/null 2>&1
4140
else
4241
export DEBIAN_FRONTEND=noninteractive
4342
apt-get -y install quota >/dev/null 2>&1
44-
check_result $? "quota package installation failed" "$E_UPDATE"
4543
fi
44+
check_result $? "quota package installation failed" "$E_UPDATE"
4645
fi
4746

4847
# Perform verification if read-only mode is enabled

bin/v-add-web-php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,13 @@ if ! echo "$DB_SYSTEM" | grep -w 'pgsql' >/dev/null; then
8484
fi
8585

8686
# Install php packages
87-
apt-get -qq update
88-
apt-get -y -qq -o Dpkg::Options::="--force-confold" install $mph > /dev/null 2>&1 &
87+
if [ -f '/etc/redhat-release' ]; then
88+
dnf makecache -q
89+
dnf install -q -y $mph > /dev/null 2>&1 &
90+
else
91+
apt-get -qq update
92+
apt-get -y -qq -o Dpkg::Options::="--force-confold" install $mph > /dev/null 2>&1 &
93+
fi
8994
BACK_PID=$!
9095

9196
# Check if package installation is done, print a spinner
@@ -103,7 +108,11 @@ echo
103108
# Check if installation was successful
104109
if [ ! -f "$php_fpm" ]; then
105110
echo "ERROR: Installation failed, please run the following command manually for debugging:"
106-
echo "apt-get install $mph"
111+
if [ -f '/etc/redhat-release' ]; then
112+
echo "dnf install $mph"
113+
else
114+
echo "apt-get install $mph"
115+
fi
107116
fi
108117

109118
# Check if required modules for apache2 are enabled

bin/v-delete-firewall-ipset

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ check_hestia_demo_mode
4242

4343
# Install ipset package if missing
4444
if [ -z "$IPSET_BIN" ]; then
45-
apt-get --quiet --yes install ipset > /dev/null
45+
if [ -f '/etc/redhat-release' ]; then
46+
dnf install -q -y ipset > /dev/null
47+
else
48+
apt-get --quiet --yes install ipset > /dev/null
49+
fi
4650
check_result $? "Installing ipset package"
4751

4852
IPSET_BIN="$(which ipset)"

bin/v-delete-web-php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ if [[ `echo "$version 7.2" | awk '{print ($1 < $2)}'` == 1 ]]; then
7171
fi
7272

7373
# Purge php packages
74-
apt-get -y purge $mph > /dev/null 2>&1 &
74+
if [ -f '/etc/redhat-release' ]; then
75+
dnf remove -y $mph > /dev/null 2>&1 &
76+
else
77+
apt-get -y purge $mph > /dev/null 2>&1 &
78+
fi
7579
BACK_PID=$!
7680

7781
# Check if package removal is done, print a spinner
@@ -89,7 +93,11 @@ echo
8993
# Check if installation was successfully
9094
if [ -f "$php_fpm" ]; then
9195
echo "ERROR: Uninstallation failed, please run the following command manually for debugging:"
92-
echo "apt-get purge $mph"
96+
if [ -f '/etc/redhat-release' ]; then
97+
echo "dnf remove $mph"
98+
else
99+
echo "apt-get purge $mph"
100+
fi
93101
exit 1;
94102
fi
95103

bin/v-list-sys-hestia-updates

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ source_conf "$HESTIA/conf/hestia.conf"
2323

2424
fields="\$NAME \$VERSION \$ARCH \$UPDATED \$DESCR \$TIME \$DATE"
2525

26+
# Check details of installed .deb package function
27+
check_installed_deb() {
28+
dpkg_data=$(dpkg-query -s $1)
29+
pkg_date=$(stat -c "%Y" /var/lib/dpkg/info/$1.list)
30+
ARCH=$(echo "$dpkg_data"|grep Architecture | cut -f 2 -d ' ')
31+
VERSION=$(echo "$dpkg_data"|grep ^Version |cut -f 2 -d ' ')
32+
DATE=$(date -d @$pkg_date +"%F")
33+
TIME=$(date -d @$pkg_date +"%T")
34+
}
35+
36+
# Check details of installed .rpm package function
37+
check_installed_rpm() {
38+
rpm_data=$(rpm -qi $1)
39+
ARCH=$(echo "$rpm_data"|grep Architecture |cut -f 2 -d ' ')
40+
VERSION=$(echo "$rpm_data"|grep Version |cut -f 2 -d ':' | xargs)
41+
DATE=$(echo "$rpm_data"| grep "Build Date"| awk '{print $5 " " $6 " " $7}')
42+
TIME=$(echo "$rpm_data"| grep "Build Date"| awk '{print $8 " " $9 " " $10}')
43+
}
44+
2645
# JSON list function
2746
json_list() {
2847
IFS=$'\n'
@@ -65,17 +84,22 @@ shell_list() {
6584
#----------------------------------------------------------#
6685

6786
# Checking official latest version
68-
hestia_v=$(apt-cache policy hestia | grep Candidate | cut -d ':' -f 2 | xargs)
69-
nginx_v=$(apt-cache policy hestia-nginx | grep Candidate | cut -d ':' -f 2 | xargs)
70-
php_v=$(apt-cache policy hestia-php | grep Candidate | cut -d ':' -f 2 | xargs)
87+
if [ -f '/etc/redhat-release' ]; then
88+
hestia_v=$(dnf list hestia | grep hestia | awk '{print $2}' | cut -f 1 -d '-')
89+
nginx_v=$(dnf list hestia-nginx | grep hestia-nginx | awk '{print $2}' | cut -f 1 -d '-')
90+
php_v=$(dnf list hestia-php | grep hestia-php | awk '{print $2}' | cut -f 1 -d '-')
91+
else
92+
hestia_v=$(apt-cache policy hestia | grep Candidate | cut -d ':' -f 2 | xargs)
93+
nginx_v=$(apt-cache policy hestia-nginx | grep Candidate | cut -d ':' -f 2 | xargs)
94+
php_v=$(apt-cache policy hestia-php | grep Candidate | cut -d ':' -f 2 | xargs)
95+
fi
7196

7297
# Checking installed hestia version
73-
dpkg_data=$(dpkg-query -s hestia)
74-
pkg_date=$(stat -c "%Y" /var/lib/dpkg/info/hestia.list)
75-
ARCH=$(echo "$dpkg_data"|grep Architecture |cut -f 2 -d ' ')
76-
VERSION=$(echo "$dpkg_data"|grep ^Version |cut -f 2 -d ' ')
77-
DATE=$(date -d @$pkg_date +"%F")
78-
TIME=$(date -d @$pkg_date +"%T")
98+
if [ -f '/etc/redhat-release' ]; then
99+
check_installed_rpm hestia
100+
else
101+
check_installed_deb hestia
102+
fi
79103

80104
UPDATED='yes'
81105
if [ -n "$hesta_v" ] && [ "$hestia_v" \> "$VERSION" ]; then
@@ -86,12 +110,11 @@ data="NAME='hestia' VERSION='$VERSION' ARCH='$ARCH'"
86110
data="$data UPDATED='$UPDATED' DESCR='core package' TIME='$TIME' DATE='$DATE'"
87111

88112
# Checking installed hestia-php version
89-
dpkg_data=$(dpkg-query -s hestia-php)
90-
pkg_date=$(stat -c "%Y" /var/lib/dpkg/info/hestia-php.list)
91-
ARCH=$(echo "$dpkg_data"|grep Architecture | cut -f 2 -d ' ')
92-
VERSION=$(echo "$dpkg_data"|grep ^Version |cut -f 2 -d ' ')
93-
DATE=$(date -d @$pkg_date +"%F")
94-
TIME=$(date -d @$pkg_date +"%T")
113+
if [ -f '/etc/redhat-release' ]; then
114+
check_installed_rpm hestia-php
115+
else
116+
check_installed_deb hestia-php
117+
fi
95118

96119
UPDATED='yes'
97120
if [ -n "$php_v" ] && [ "$php_v" \> "$VERSION" ]; then
@@ -103,12 +126,11 @@ data="$data ARCH='$ARCH' UPDATED='$UPDATED' DESCR='php interpreter'"
103126
data="$data TIME='$TIME' DATE='$DATE'"
104127

105128
# Checking installed hestia-nginx version
106-
dpkg_data=$(dpkg-query -s hestia-nginx)
107-
pkg_date=$(stat -c "%Y" /var/lib/dpkg/info/hestia-nginx.list)
108-
ARCH=$(echo "$dpkg_data"|grep Architecture | cut -f 2 -d ' ')
109-
VERSION=$(echo "$dpkg_data"|grep ^Version |cut -f 2 -d ' ')
110-
DATE=$(date -d @$pkg_date +"%F")
111-
TIME=$(date -d @$pkg_date +"%T")
129+
if [ -f '/etc/redhat-release' ]; then
130+
check_installed_rpm hestia-nginx
131+
else
132+
check_installed_deb hestia-nginx
133+
fi
112134

113135
UPDATED='yes'
114136
if [ -n "$nginx_v" ] && [ "$nginx_v" \> "$VERSION" ]; then

bin/v-update-sys-hestia-git

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ BUILD_DIR='/tmp/hestiacp-src'
7878
DEB_DIR="$BUILD_DIR/debs"
7979
INSTALL_DIR='/usr/local/hestia'
8080
ARCHIVE_DIR="${BUILD_DIR}/archive"
81-
architecture="$(uname -m)"
81+
architecture="$(arch)"
8282
if [ $architecture == 'aarch64' ]; then
8383
BUILD_ARCH='arm64'
8484
else

0 commit comments

Comments
 (0)