Skip to content

Commit 26e1108

Browse files
authored
Feature/beta repo support (hestiacp#2402)
* Add support for beta repo on install * Add B flag * Fix correct beta apt server * Fix correct location pubkey * Add correct path to key ring * Add support for beta.hestiacp.com packages in installer * Add error message when attempting install stable version via --beta * Add support changing repo on installed versions * Remove small bugs * Add missing RHOST
1 parent c4a2df4 commit 26e1108

File tree

4 files changed

+141
-10
lines changed

4 files changed

+141
-10
lines changed

bin/v-change-sys-release

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
2-
# info: update web templates
2+
# info: Update release branch variable
33
# options: [RESTART]
44
#
55
# This function for changing the release branch for the
66
# Hestia Control Panel. This allows the user to switch between
7-
# stable and pre-release builds which will automaticlly update
7+
# stable and pre-release builds which will automatically update
88
# based on the appropriate release schedule if auto-update is
99
# turned on.
1010

bin/v-change-sys-repo

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
# info: Switch between release / development or beta apt repository
3+
# options: [RESTART]
4+
#
5+
# This function allows switching between the stable (apt.hestiacp.com) and unstable (beta.hestiacp.com) apt repository
6+
7+
#----------------------------------------------------------#
8+
# Variables & Functions #
9+
#----------------------------------------------------------#
10+
11+
# Argument definition
12+
repo=$1
13+
14+
# Includes
15+
# shellcheck source=/etc/hestiacp/hestia.conf
16+
source /etc/hestiacp/hestia.conf
17+
# shellcheck source=/usr/local/hestia/func/main.sh
18+
source $HESTIA/func/main.sh
19+
# load config file
20+
source_conf "$HESTIA/conf/hestia.conf"
21+
22+
#----------------------------------------------------------#
23+
# Verifications #
24+
#----------------------------------------------------------#
25+
26+
# Perform verification if read-only mode is enabled
27+
check_hestia_demo_mode
28+
29+
#----------------------------------------------------------#
30+
# Action #
31+
#----------------------------------------------------------#
32+
33+
# Define apt conf location
34+
apt=/etc/apt/sources.list.d
35+
RHOSTBETA="beta.hestiacp.com"
36+
codename="$(lsb_release -s -c)"
37+
release="$(lsb_release -s -r)"
38+
RHOST='apt.hestiacp.com'
39+
# Get Architecture
40+
architecture="$(uname -m)"
41+
case $architecture in
42+
x86_64)
43+
ARCH="amd64"
44+
;;
45+
aarch64)
46+
ARCH="arm64"
47+
;;
48+
*)
49+
echo " [ ! ] Unsuported architectrue"
50+
esac
51+
52+
if [ $repo != "beta" ]; then
53+
if [ -f "$apt/hestia-beta.list" ]; then
54+
rm $apt/hestia-beta.list
55+
sed -i 's/#deb/deb/' $apt/hestia.list
56+
else
57+
echo "apt.hestiacp.com already active"
58+
exit 1;
59+
fi
60+
else
61+
if [ ! -f "$apt/hestia-beta.list" ]; then
62+
sed -i 's/deb/#deb/' $apt/hestia.list
63+
echo "deb [arch=$ARCH signed-by=/usr/share/keyrings/hestia-beta-keyring.gpg] https://$RHOSTBETA/ $codename main" > $apt/hestia-beta.list
64+
curl -s "https://$RHOSTBETA/pubkey.gpg" | gpg --dearmor | tee /usr/share/keyrings/hestia-beta-keyring.gpg >/dev/null 2>&1
65+
else
66+
echo "beta.hestiacp.com already active"
67+
exit 1;
68+
fi
69+
fi
70+
71+
#----------------------------------------------------------#
72+
# Hestia #
73+
#----------------------------------------------------------#
74+
75+
$BIN/v-log-action "system" "Info" "System" "Update APT repository changed (Value: $repo)."
76+
77+
exit

install/hst-install-debian.sh

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
export PATH=$PATH:/sbin
1717
export DEBIAN_FRONTEND=noninteractive
1818
RHOST='apt.hestiacp.com'
19+
RHOSTBETA='beta.hestiacp.com'
1920
GPG='gpg.hestiacp.com'
2021
VERSION='debian'
2122
HESTIA='/usr/local/hestia'
@@ -103,6 +104,7 @@ help() {
103104
-e, --email Set admin email
104105
-p, --password Set admin password
105106
-D, --with-debs Path to Hestia debs
107+
-B, --beta Development version [yes|no] default: yes
106108
-f, --force Force installation
107109
-h, --help Print this help
108110
@@ -236,6 +238,7 @@ for arg; do
236238
--password) args="${args}-p " ;;
237239
--force) args="${args}-f " ;;
238240
--with-debs) args="${args}-D " ;;
241+
--beta) args="${args}-B " ;;
239242
--help) args="${args}-h " ;;
240243
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
241244
args="${args}${delim}${arg}${delim} ";;
@@ -244,7 +247,7 @@ done
244247
eval set -- "$args"
245248

246249
# Parsing arguments
247-
while getopts "a:w:v:j:k:m:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
250+
while getopts "a:w:v:j:k:m:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:D:B:fh" Option; do
248251
case $Option in
249252
a) apache=$OPTARG ;; # Apache
250253
w) phpfpm=$OPTARG ;; # PHP-FPM
@@ -270,6 +273,7 @@ while getopts "a:w:v:j:k:m:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
270273
e) email=$OPTARG ;; # Admin email
271274
p) vpass=$OPTARG ;; # Admin password
272275
D) withdebs=$OPTARG ;; # Hestia debs path
276+
B) beta=$OPTARG ;; # Hestia preview program
273277
f) force='yes' ;; # Force install
274278
h) help ;; # Help
275279
*) help ;; # Print help (default)
@@ -304,6 +308,7 @@ set_default_value 'fail2ban' 'yes'
304308
set_default_value 'quota' 'no'
305309
set_default_value 'interactive' 'yes'
306310
set_default_value 'api' 'yes'
311+
set_default_value 'beta' 'no'
307312
set_default_port '8083'
308313
set_default_lang 'en'
309314

@@ -442,10 +447,10 @@ if [ -d /etc/netplan ] && [ -z "$force" ]; then
442447
fi
443448
fi
444449

445-
# Validate whether installation script matches release version before continuing with install
446450
if [ -z "$withdebs" ] || [ ! -d "$withdebs" ]; then
451+
# Validate whether installation script matches release version before continuing with install
447452
release_branch_ver=$(curl -s https://raw.githubusercontent.com/hestiacp/hestiacp/release/src/deb/hestia/control |grep "Version:" |awk '{print $2}')
448-
if [ "$HESTIA_INSTALL_VER" != "$release_branch_ver" ]; then
453+
if [ "$HESTIA_INSTALL_VER" != "$release_branch_ver" ] && [ $beta != 'yes' ]; then
449454
echo
450455
echo -e "\e[91mInstallation aborted\e[0m"
451456
echo "===================================================================="
@@ -460,6 +465,20 @@ if [ -z "$withdebs" ] || [ ! -d "$withdebs" ]; then
460465
echo ""
461466
check_result 1 "Installation aborted"
462467
fi
468+
469+
# Validate if a development version is installed when --beta is enabled
470+
DISPLAY_VER=$(echo $HESTIA_INSTALL_VER | sed "s|~alpha||g" | sed "s|~beta||g")
471+
if [ "$HESTIA_INSTALL_VER" = "$DISPLAY_VER" ] && [ $beta = 'yes' ]; then
472+
echo
473+
echo -e "\e[91mInstallation aborted\e[0m"
474+
echo "===================================================================="
475+
echo -e "\e[33mERROR: Unable to use beta atp server for stable release\e[0m"
476+
echo -e "\e[33mPlease remove the -B or --beta flag from the installer string\e[0m"
477+
478+
echo ""
479+
check_result 1 "Installation aborted"
480+
fi
481+
463482
fi
464483

465484
case $architecture in
@@ -722,10 +741,16 @@ if [ "$mysql" = 'yes' ]; then
722741
curl -s https://mariadb.org/mariadb_release_signing_key.asc | gpg --dearmor | tee /usr/share/keyrings/mariadb-keyring.gpg >/dev/null 2>&1
723742
fi
724743

725-
# Installing HestiaCP repo
726744
echo "[ * ] Hestia Control Panel"
727745
echo "deb [arch=$ARCH signed-by=/usr/share/keyrings/hestia-keyring.gpg] https://$RHOST/ $codename main" > $apt/hestia.list
728746
gpg --no-default-keyring --keyring /usr/share/keyrings/hestia-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys A189E93654F0B0E5 >/dev/null 2>&1
747+
if [ "$beta" = 'yes' ]; then
748+
# Enable preview mode
749+
sed -i 's/deb/#deb/' $apt/hestia.list
750+
echo "[ ! ] Hestia Control Panel (Preview version)"
751+
echo "deb [arch=$ARCH signed-by=/usr/share/keyrings/hestia-beta-keyring.gpg] https://$RHOSTBETA/ $codename main" > $apt/hestia-beta.list
752+
curl -s "https://$RHOSTBETA/pubkey.gpg" | gpg --dearmor | tee /usr/share/keyrings/hestia-beta-keyring.gpg >/dev/null 2>&1
753+
fi
729754

730755
# Installing PostgreSQL repo
731756
if [ "$postgresql" = 'yes' ]; then

install/hst-install-ubuntu.sh

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
export PATH=$PATH:/sbin
1717
export DEBIAN_FRONTEND=noninteractive
1818
RHOST='apt.hestiacp.com'
19+
RHOSTBETA='beta.hestiacp.com'
20+
1921
GPG='gpg.hestiacp.com'
2022
VERSION='ubuntu'
2123
HESTIA='/usr/local/hestia'
@@ -84,6 +86,7 @@ help() {
8486
-e, --email Set admin email
8587
-p, --password Set admin password
8688
-D, --with-debs Path to Hestia debs
89+
-B, --beta Development version [yes|no] default: yes
8790
-f, --force Force installation
8891
-h, --help Print this help
8992
@@ -215,6 +218,7 @@ for arg; do
215218
--email) args="${args}-e " ;;
216219
--password) args="${args}-p " ;;
217220
--force) args="${args}-f " ;;
221+
--beta) args="${args}-B " ;;
218222
--with-debs) args="${args}-D " ;;
219223
--help) args="${args}-h " ;;
220224
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
@@ -224,7 +228,7 @@ done
224228
eval set -- "$args"
225229

226230
# Parsing arguments
227-
while getopts "a:w:v:j:k:m:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
231+
while getopts "a:w:v:j:k:m:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:D:B:fh" Option; do
228232
case $Option in
229233
a) apache=$OPTARG ;; # Apache
230234
w) phpfpm=$OPTARG ;; # PHP-FPM
@@ -249,6 +253,7 @@ while getopts "a:w:v:j:k:m:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
249253
s) servername=$OPTARG ;; # Hostname
250254
e) email=$OPTARG ;; # Admin email
251255
p) vpass=$OPTARG ;; # Admin password
256+
B) beta=$OPTARG ;; # Beta / Development version
252257
D) withdebs=$OPTARG ;; # Hestia debs path
253258
f) force='yes' ;; # Force install
254259
h) help ;; # Help
@@ -284,6 +289,7 @@ set_default_value 'fail2ban' 'yes'
284289
set_default_value 'quota' 'no'
285290
set_default_value 'interactive' 'yes'
286291
set_default_value 'api' 'yes'
292+
set_default_value 'beta' 'no'
287293
set_default_port '8083'
288294
set_default_lang 'en'
289295

@@ -416,10 +422,11 @@ if [ -d /etc/netplan ] && [ -z "$force" ]; then
416422
fi
417423
fi
418424

419-
# Validate whether installation script matches release version before continuing with install
425+
420426
if [ -z "$withdebs" ] || [ ! -d "$withdebs" ]; then
427+
# Validate whether installation script matches release version before continuing with install
421428
release_branch_ver=$(curl -s https://raw.githubusercontent.com/hestiacp/hestiacp/release/src/deb/hestia/control |grep "Version:" |awk '{print $2}')
422-
if [ "$HESTIA_INSTALL_VER" != "$release_branch_ver" ]; then
429+
if [ "$HESTIA_INSTALL_VER" != "$release_branch_ver" ] && [ $beta != 'yes' ]; then
423430
echo
424431
echo -e "\e[91mInstallation aborted\e[0m"
425432
echo "===================================================================="
@@ -434,6 +441,20 @@ if [ -z "$withdebs" ] || [ ! -d "$withdebs" ]; then
434441
echo ""
435442
check_result 1 "Installation aborted"
436443
fi
444+
445+
# Validate if a development version is installed when --beta is enabled
446+
DISPLAY_VER=$(echo $HESTIA_INSTALL_VER | sed "s|~alpha||g" | sed "s|~beta||g")
447+
if [ "$HESTIA_INSTALL_VER" = "$DISPLAY_VER" ] && [ $beta = 'yes' ]; then
448+
echo
449+
echo -e "\e[91mInstallation aborted\e[0m"
450+
echo "===================================================================="
451+
echo -e "\e[33mERROR: Unable to use beta atp server for stable release\e[0m"
452+
echo -e "\e[33mPlease remove the -B or --beta flag from the installer string\e[0m"
453+
454+
455+
echo ""
456+
check_result 1 "Installation aborted"
457+
fi
437458
fi
438459

439460
case $architecture in
@@ -480,7 +501,7 @@ install_welcome_message() {
480501
echo " www.hestiacp.com "
481502
echo
482503
echo "========================================================================"
483-
echo
504+
echo
484505
echo "Thank you for downloading Hestia Control Panel! In a few moments,"
485506
echo "we will begin installing the following components on your server:"
486507
echo
@@ -698,6 +719,14 @@ echo "[ * ] Hestia Control Panel"
698719
echo "deb [arch=$ARCH signed-by=/usr/share/keyrings/hestia-keyring.gpg] https://$RHOST/ $codename main" > $apt/hestia.list
699720
gpg --no-default-keyring --keyring /usr/share/keyrings/hestia-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys A189E93654F0B0E5 >/dev/null 2>&1
700721

722+
if [ "$beta" = 'yes' ]; then
723+
# Enable preview mode
724+
sed -i 's/deb/#deb/' $apt/hestia.list
725+
echo "[ ! ] Hestia Control Panel (Preview version)"
726+
echo "deb [arch=$ARCH signed-by=/usr/share/keyrings/hestia-beta-keyring.gpg] https://$RHOSTBETA/ $codename main" > $apt/hestia-beta.list
727+
curl -s "https://$RHOSTBETA/pubkey.gpg" | gpg --dearmor | tee /usr/share/keyrings/hestia-beta-keyring.gpg >/dev/null 2>&1
728+
fi
729+
701730
# Installing PostgreSQL repo
702731
if [ "$postgresql" = 'yes' ]; then
703732
echo "[ * ] PostgreSQL"

0 commit comments

Comments
 (0)