Skip to content

Commit 320474c

Browse files
author
Kristan Kenney
committed
Merge branch 'feature-custom-css'
2 parents 1110d56 + 11ea2c7 commit 320474c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+558
-28
lines changed

bin/v-add-sys-theme

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/bash
2+
# info: install theme from local source or GitHub.
3+
# options: theme [MODE] [ACTIVE]
4+
5+
# The function for installing a custom theme or downloading one
6+
# from the HestiaCP theme repository.
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument definition
13+
theme=$1
14+
mode=$2
15+
active=$3
16+
17+
# Includes
18+
source $HESTIA/func/main.sh
19+
source $HESTIA/conf/hestia.conf
20+
21+
# Define themes repository URL format
22+
HESTIA_THEMES_REPO="$HESTIA_GIT_REPO/$RELEASE_BRANCH/themes"
23+
24+
#----------------------------------------------------------#
25+
# Action #
26+
#----------------------------------------------------------#
27+
28+
# Fallback to downloading from GitHub if no mode specified
29+
if [ -z "$mode" ]; then
30+
mode="git"
31+
fi
32+
33+
# Initialize local directory if it does not exist
34+
if [ ! -d "$HESTIA_THEMES_CUSTOM" ]; then
35+
mkdir -p $HESTIA_THEMES_CUSTOM
36+
fi
37+
38+
# Abort if no theme name specified
39+
if [ -z "$theme" ]; then
40+
echo "ERROR: No theme name specified."
41+
echo "Usage: v-add-sys-theme theme [GIT | LOCAL] [ACTIVE]"
42+
echo " theme: name of the theme to install."
43+
echo " active: Set downloaded theme as active (optional)"
44+
45+
exit 1
46+
fi
47+
48+
# Check if theme name already exists as system theme
49+
if [ -e $HESTIA_THEMES/$theme.css ]; then
50+
echo "ERROR: System theme with the same name already exists: $theme."
51+
echo " To update system themes, run v-update-sys-themes."
52+
exit 1
53+
fi
54+
55+
# Prompt to replace existing theme if detected
56+
if [ -e $HESTIA_THEMES_CUSTOM/$theme.css ]; then
57+
echo "WARNING: Theme file $theme.css already exists."
58+
read -p "Would you like to replace it? [Y/N] " replace_theme
59+
60+
if [ "$replace_theme" = "N" ] || [ "$replace_theme" = "n" ]; then
61+
exit 1
62+
fi
63+
fi
64+
65+
# Install theme from GitHub repository
66+
if [ "$mode" = "git" ]; then
67+
# Check if it's a valid file first
68+
theme_check=$(curl -s --head -w %{http_code} $HESTIA_THEMES_REPO/$theme.css -o /dev/null)
69+
if [ $theme_check -ne "200" ]; then
70+
echo "Error: invalid theme name specified."
71+
exit 1
72+
fi
73+
74+
# Download the theme file from Git
75+
echo "Downloading and installing theme: $theme..."
76+
wget $HESTIA_THEMES_REPO/$theme.css -O $HESTIA_THEMES_CUSTOM/$theme.css > /dev/null 2>&1
77+
fi
78+
79+
if [ "$mode" = "local" ]; then
80+
read -p "Please enter the full path to the CSS file to import: " theme_path
81+
cp -f $theme_path $HESTIA_THEMES_CUSTOM/
82+
fi
83+
84+
# Set active theme
85+
$BIN/v-change-sys-theme $theme
86+
87+
#----------------------------------------------------------#
88+
# Hestia #
89+
#----------------------------------------------------------#
90+
91+
exit

bin/v-change-sys-language

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# Argument definition
1313
language=$1
14+
update_users=$2
1415

1516
# Includes
1617
source $HESTIA/func/main.sh
@@ -46,6 +47,12 @@ else
4647
sed -i "s/LANGUAGE=.*/LANGUAGE='$language'/g" $HESTIA/conf/hestia.conf
4748
fi
4849

50+
# Update language for all existing users if specified
51+
if [ "$update_users" = "yes" ]; then
52+
for user in $(ls $HESTIA/data/users); do
53+
$BIN/v-change-user-language $user $language
54+
done
55+
fi
4956

5057
#----------------------------------------------------------#
5158
# Hestia #

bin/v-change-sys-theme

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
# info: update web templates
3+
#
4+
# The function for changing the currently active system theme.
5+
6+
#----------------------------------------------------------#
7+
# Variable&Function #
8+
#----------------------------------------------------------#
9+
10+
# Argument definition
11+
theme=$1
12+
13+
# Includes
14+
source $HESTIA/func/main.sh
15+
source $HESTIA/conf/hestia.conf
16+
17+
#----------------------------------------------------------#
18+
# Action #
19+
#----------------------------------------------------------#
20+
21+
# Theme argument and file detection
22+
if [ -z "$theme" ]; then
23+
echo "ERROR: No theme specified."
24+
exit 1
25+
else
26+
if [ -e "$HESTIA_THEMES/$theme.css" ]; then
27+
theme_conf="$HESTIA_THEMES/$theme.css"
28+
elif [ -e "$HESTIA_THEMES_CUSTOM/$theme.css" ]; then
29+
theme_conf="$HESTIA_THEMES_CUSTOM/$theme.css"
30+
else
31+
echo "ERROR: Unable to locate specified theme."
32+
exit 1
33+
fi
34+
35+
# Replace theme override file
36+
rm -f $HESTIA/web/css/active-theme.css
37+
cp -f $theme_conf $HESTIA/web/css/active-theme.css
38+
39+
# Set default theme in configuration file
40+
$BIN/v-change-sys-config-value 'THEME' $theme
41+
fi
42+
43+
#----------------------------------------------------------#
44+
# Hestia #
45+
#----------------------------------------------------------#
46+
47+
exit

bin/v-change-user-language

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ else
5454
update_user_value "$user" '$LANGUAGE' "$language"
5555
fi
5656

57-
5857
#----------------------------------------------------------#
5958
# Hestia #
6059
#----------------------------------------------------------#

bin/v-delete-sys-theme

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
# info: removes a theme from the custom theme library.
3+
# options: [RESTART]
4+
5+
6+
#----------------------------------------------------------#
7+
# Variable&Function #
8+
#----------------------------------------------------------#
9+
10+
# Argument definition
11+
theme=$1
12+
13+
# Includes
14+
source $HESTIA/func/main.sh
15+
source $HESTIA/conf/hestia.conf
16+
17+
#----------------------------------------------------------#
18+
# Action #
19+
#----------------------------------------------------------#
20+
21+
if [ -z "$theme" ]; then
22+
# Theme not specified, throw an error.
23+
echo "ERROR: No theme specified."
24+
exit 1
25+
else
26+
if [ -e $HESTIA_THEMES/$theme.css ]; then
27+
# Protect system themes from deletion
28+
# Users can use the terminal to work around this if really desired.
29+
echo "ERROR: Unable to delete system theme: $theme."
30+
exit 1
31+
fi
32+
if [ -e $HESTIA_THEMES_CUSTOM/$theme.css ]; then
33+
# Remove theme if it exists.
34+
echo "Deleting $theme..."
35+
rm -f $HESTIA_THEMES_CUSTOM/$theme.css > /dev/null 2&>1
36+
else
37+
# Theme doesn't exist, throw an error.
38+
echo "ERROR: Theme $theme does not exist."
39+
fi
40+
fi
41+
42+
# Set default theme in configuration file if deleted theme was active
43+
if [ "$THEME" = "$theme" ]; then
44+
rm -f $HESTIA/web/css/active-theme.css
45+
$BIN/v-change-sys-config-value 'THEME' default
46+
fi
47+
48+
#----------------------------------------------------------#
49+
# Hestia #
50+
#----------------------------------------------------------#
51+
52+
exit

bin/v-list-sys-config

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ json_list() {
4444
"REPOSITORY": "'$REPOSITORY'",
4545
"VERSION": "'$VERSION'",
4646
"RELEASE_BRANCH": "'$RELEASE_BRANCH'",
47+
"THEME": "'$THEME'",
4748
"LANGUAGE": "'$LANGUAGE'",
4849
"BACKUP_GZIP": "'$BACKUP_GZIP'",
4950
"BACKUP": "'$BACKUP'",
@@ -58,24 +59,24 @@ json_list() {
5859
# Shell list
5960
shell_list() {
6061
if [ ! -z "$WEB_SYSTEM" ]; then
61-
echo "WEB Server: $WEB_SYSTEM:$WEB_PORT ($WEB_RGROUPS)"
62-
echo "SSL Support: $WEB_SSL:$WEB_SSL_PORT"
62+
echo "WEB Server: $WEB_SYSTEM:$WEB_PORT ($WEB_RGROUPS)"
63+
echo "SSL Support: $WEB_SSL:$WEB_SSL_PORT"
6364
fi
6465
if [ ! -z "$WEB_BACKEND" ]; then
65-
echo "WEB Backend: $WEB_BACKEND"
66+
echo "WEB Backend: $WEB_BACKEND"
6667
fi
6768
if [ ! -z "$PROXY_SYSTEM" ]; then
68-
echo "Proxy Server: $PROXY_SYSTEM:$PROXY_PORT"
69-
echo "Proxy SSL: $PROXY_SYSTEM:$PROXY_SSL_PORT"
69+
echo "Proxy Server: $PROXY_SYSTEM:$PROXY_PORT"
70+
echo "Proxy SSL: $PROXY_SYSTEM:$PROXY_SSL_PORT"
7071
fi
7172
if [ ! -z "$STATS_SYSTEM" ]; then
72-
echo "Web Stats: ${STATS_SYSTEM//,/, }"
73+
echo "Web Stats: ${STATS_SYSTEM//,/, }"
7374
fi
7475
if [ ! -z "$FTP_SYSTEM" ]; then
75-
echo "FTP Server: $FTP_SYSTEM"
76+
echo "FTP Server: $FTP_SYSTEM"
7677
fi
7778
if [ ! -z "$MAIL_SYSTEM" ]; then
78-
echo -n "Mail Server: $MAIL_SYSTEM"
79+
echo -n "Mail Server: $MAIL_SYSTEM"
7980
if [ ! -z "$IMAP_SYSTEM" ]; then
8081
echo -n " + $IMAP_SYSTEM"
8182
fi
@@ -87,50 +88,50 @@ shell_list() {
8788
fi
8889
echo
8990
if [ ! -z "$WEBMAIL_ALIAS" ]; then
90-
echo "Webmail (subdomain): $WEBMAIL_ALIAS.domain.tld"
91-
echo "Webmail (alias): hostname/$WEBMAIL_ALIAS"
91+
echo "Webmail alias: $WEBMAIL_ALIAS"
9292
fi
9393
fi
9494
if [ ! -z "$DB_SYSTEM" ]; then
95-
echo "Database: ${DB_SYSTEM//,/, }"
95+
echo "Database: ${DB_SYSTEM//,/, }"
9696
if [ ! -z "$DB_PMA_URL" ]; then
97-
echo "PMA URL: $DB_PMA_URL"
97+
echo "PMA URL: $DB_PMA_URL"
9898
fi
9999
if [ ! -z "$DB_PGA_URL" ]; then
100-
echo "PGA URL: $DB_PGA_URL"
100+
echo "PGA URL: $DB_PGA_URL"
101101
fi
102102
fi
103103
if [ ! -z "$DNS_SYSTEM" ]; then
104-
echo -n "DNS server: $DNS_SYSTEM"
104+
echo -n "DNS server: $DNS_SYSTEM"
105105
if [ ! -z "$DNS_CLUSTER" ]; then
106106
echo -n " (cluster)"
107107
fi
108108
echo
109109
fi
110110
if [ ! -z "$CRON_SYSTEM" ]; then
111-
echo "CRON: $CRON_SYSTEM"
111+
echo "CRON: $CRON_SYSTEM"
112112
fi
113113
if [ ! -z "$FIREWALL_SYSTEM" ]; then
114-
echo -n "Firewall: $FIREWALL_SYSTEM"
114+
echo -n "Firewall: $FIREWALL_SYSTEM"
115115
if [ ! -z "$FIREWALL_EXTENSION" ]; then
116116
echo -n "+ $FIREWALL_EXTENSION"
117117
fi
118118
echo
119119
fi
120120
if [ ! -z "$BACKUP_SYSTEM" ]; then
121-
echo "Backups: ${BACKUP_SYSTEM//,/, }"
121+
echo "Backups: ${BACKUP_SYSTEM//,/, }"
122122
if [ ! -z "$BACKUP" ]; then
123-
echo "Backup Dir: $BACKUP"
123+
echo "Backup Dir: $BACKUP"
124124
fi
125125
fi
126126
if [ ! -z "$DISK_QUOTA" ]; then
127-
echo "Disk Quota: $DISK_QUOTA"
127+
echo "Disk Quota: $DISK_QUOTA"
128128
fi
129129
if [ ! -z "$LANGUAGE" ] && [ "$LANGUAGE" != 'en' ]; then
130-
echo "Language: $LANGUAGE"
130+
echo "Language: $LANGUAGE"
131131
fi
132-
echo "Version: $VERSION"
133-
echo "Release Branch: $RELEASE_BRANCH"
132+
echo "Version: $VERSION"
133+
echo "Release Branch: $RELEASE_BRANCH"
134+
echo "Theme: $THEME"
134135
}
135136

136137
# PLAIN list function
@@ -141,7 +142,7 @@ plain_list() {
141142
echo -ne "$ANTIVIRUS_SYSTEM\t$ANTISPAM_SYSTEM\t$DB_SYSTEM\t"
142143
echo -ne "$DNS_SYSTEM\t$DNS_CLUSTER\t$STATS_SYSTEM\t$BACKUP_SYSTEM\t"
143144
echo -ne "$CRON_SYSTEM\t$DISK_QUOTA\t$FIREWALL_SYSTEM\t"
144-
echo -ne "$FIREWALL_EXTENSION\t$REPOSITORY\t$VERSION\t$RELEASE_BRANCH\t$LANGUAGE\t"
145+
echo -ne "$FIREWALL_EXTENSION\t$REPOSITORY\t$VERSION\t$RELEASE_BRANCH\t$THEME\t$LANGUAGE\t"
145146
echo -e "$BACKUP_GZIP\t$BACKUP\t$WEBMAIL_ALIAS\t$DB_PMA_URL\t$DB_PGA_URL"
146147
}
147148

@@ -164,7 +165,7 @@ csv_list() {
164165
echo -n "'$ANTIVIRUS_SYSTEM','$ANTISPAM_SYSTEM','$DB_SYSTEM',"
165166
echo -n "'$DNS_SYSTEM','$DNS_CLUSTER','$STATS_SYSTEM','$BACKUP_SYSTEM',"
166167
echo -n "'$CRON_SYSTEM','$DISK_QUOTA','$FIREWALL_SYSTEM','$REPOSITORY',"
167-
echo -n "'$FIREWALL_EXTENSION','$VERSION','$RELEASE_BRANCH','$LANGUAGE','$BACKUP_GZIP',"
168+
echo -n "'$FIREWALL_EXTENSION','$VERSION','$RELEASE_BRANCH','$THEME','$LANGUAGE','$BACKUP_GZIP',"
168169
echo -n "'$BACKUP','$WEBMAIL_ALIAS','$DB_PMA_URL','$DB_PGA_URL'"
169170
echo
170171
}

0 commit comments

Comments
 (0)