Skip to content

Commit a84ecb2

Browse files
author
Kristan Kenney
committed
Merge branch 'feature-themeupdater'
2 parents c494b9b + 1df30ba commit a84ecb2

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

bin/v-update-sys-themes

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
# v-update-sys-themes
4+
# info: update system themes
5+
# options: quiet
6+
#
7+
# The function is for updating system theme css files from
8+
# Hestia Control Panel's GitHub repository
9+
10+
11+
#----------------------------------------------------------#
12+
# Variable&Function #
13+
#----------------------------------------------------------#
14+
15+
branch=$1
16+
quiet=$2
17+
18+
# Import main functions and variables for release branch
19+
# and system theme currently in use
20+
source $HESTIA/func/main.sh
21+
source $HESTIA/conf/hestia.conf
22+
23+
# Check for release branch override
24+
if [ -z "$branch" ]; then
25+
theme_branch="$RELEASE_BRANCH"
26+
else
27+
if [ "$RELEASE_BRANCH" != "$branch" ]; then
28+
theme_branch="$branch"
29+
else
30+
theme_branch="$RELEASE_BRANCH"
31+
fi
32+
fi
33+
34+
# Catch in the event that v-update-sys-themes yes is specified
35+
if [ "$branch" = "yes" ] || [ "$branch" = "y" ]; then
36+
answer_set="y"
37+
theme_branch="$RELEASE_BRANCH"
38+
fi
39+
40+
# Check for presence of quiet flag and skip the
41+
# welcomwe/warning prompt that is displayed when running
42+
# without any switches/flags.
43+
if [ -z "$answer_set" ]; then
44+
if [ "$quiet" ]; then
45+
answer="y"
46+
else
47+
read -p "Proceed with theme update installation? [Y/n] " answer
48+
fi
49+
else
50+
answer="y"
51+
fi
52+
53+
# Download the base system theme and update each CSS file present in the themes folder
54+
if [ "$answer" = "y" ] || [ "$answer" = "Y" ] || [ "$answer" = "yes" ]; then
55+
echo ""
56+
echo "Hestia Control Panel UI Theme Updater"
57+
echo "============================================"
58+
echo "Version: $VERSION"
59+
echo "Release Branch: $RELEASE_BRANCH"
60+
echo "Theme Branch: $theme_branch"
61+
echo "============================================"
62+
echo ""
63+
echo "(*) Updating system base theme..."
64+
if [ -e "$HESTIA/web/css/styles.min.css" ]; then
65+
rm -f "$HESTIA/web/css/styles.min.css"
66+
fi
67+
68+
wget $HESTIA_GIT_REPO/$theme_branch/web/css/styles.min.css -q -O $HESTIA/web/css/styles.min.css --show-progress --progress=bar:force --limit-rate=3m
69+
echo ""
70+
echo "(*) Updating included themes..."
71+
for themefile in `ls $HESTIA/install/deb/themes`; do
72+
73+
if [ -e $themefile ]; then
74+
rm -f $themefile
75+
fi
76+
echo "(-) Downloading $themefile..."
77+
wget $HESTIA_GIT_REPO/$theme_branch/install/deb/themes/$themefile -q -O $HESTIA_INSTALL_DIR/themes/$themefile --show-progress --progress=bar:force --limit-rate=3m
78+
done
79+
80+
# If the system theme is not the default, run v-change-sys-theme to delete the old CSS file and replace it with the new one which was just downloaded.
81+
if [ "$THEME" != "default" ]; then
82+
echo "(*) Applying updated system interface theme..."
83+
$BIN/v-change-sys-theme $THEME
84+
fi
85+
else
86+
echo "Update process aborted."
87+
fi

0 commit comments

Comments
 (0)