Răsfoiți Sursa

Fixed Whitelabel Descriptions and added functionality to reset whitelabelling. (#3952)

* Fixed Whitelabel Descriptions and added functionality to reset whitelabelling.

* Fixed case where update would remove custom folder due to wrong comparison

* Resolve comments

* Change: Reset White label to Reset logo

---------

Co-authored-by: Christoph Schläpfer <c.schlaepfer@datact.ch>
Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
Christoph Schlaepfer 2 ani în urmă
părinte
comite
ace8a0ddaa

+ 17 - 14
bin/v-update-white-label-logo

@@ -6,20 +6,19 @@
 #
 # Replace Hestia logos with User created logo's
 
-download=${1-no}
 #----------------------------------------------------------#
 #                Variables & Functions                     #
 #----------------------------------------------------------#
 
 # Argument definition
-restart=$1
-skip=$2
+download=${1-no}
+reset=${2-no}
 
 # Includes
 # shellcheck source=/etc/hestiacp/hestia.conf
 source /etc/hestiacp/hestia.conf
 # shellcheck source=/usr/local/hestia/func/main.sh
-source $HESTIA/func/main.sh
+source "$HESTIA/func/main.sh"
 # load config file
 source_conf "$HESTIA/conf/hestia.conf"
 
@@ -27,34 +26,38 @@ source_conf "$HESTIA/conf/hestia.conf"
 #                       Action                             #
 #----------------------------------------------------------#
 
+if [ "$reset" = "yes" ]; then
+	rm -rf "$HESTIA/web/images/custom/"
+fi
+
 if [ -f "$HESTIA/web/images/custom/logo.svg" ]; then
-	cp -f $HESTIA/web/images/custom/logo.svg $HESTIA/web/images/logo.svg
+	cp -f "$HESTIA/web/images/custom/logo.svg" "$HESTIA/web/images/logo.svg"
 elif [ ! -f "$HESTIA/web/images/custom/logo.svg" ] && [ "$download" = "yes" ]; then
-	download_file https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/images/logo.svg $HESTIA/web/images/logo.svg
+	download_file "https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/images/logo.svg" "$HESTIA/web/images/logo.svg"
 fi
 
 if [ -f "$HESTIA/web/images/custom/logo.png" ]; then
-	cp -f $HESTIA/web/images/custom/logo.png $HESTIA/web/images/logo.png
+	cp -f $"HESTIA/web/images/custom/logo.png" "$HESTIA/web/images/logo.png"
 elif [ ! -f "$HESTIA/web/images/custom/logo.png" ] && [ "$download" = "yes" ]; then
-	download_file https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/images/logo.png $HESTIA/web/images/logo.png
+	download_file "https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/images/logo.png" "$HESTIA/web/images/logo.png"
 fi
 
 if [ -f "$HESTIA/web/images/custom/logo-header.svg" ]; then
-	cp -f $HESTIA/web/images/custom/logo-header.svg $HESTIA/web/images/logo-header.svg
+	cp -f "$HESTIA/web/images/custom/logo-header.svg" "$HESTIA/web/images/logo-header.svg"
 elif [ ! -f "$HESTIA/web/images/custom/logo-header.svg" ] && [ "$download" = "yes" ]; then
-	download_file https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/images/logo-header.svg $HESTIA/web/images/logo-header.svg
+	download_file "https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/images/logo-header.svg" "$HESTIA/web/images/logo-header.svg"
 fi
 
 if [ -f "$HESTIA/web/images/custom/favicon.png" ]; then
-	cp -f $HESTIA/web/images/custom/favicon.png $HESTIA/web/images/favicon.png
+	cp -f" $HESTIA/web/images/custom/favicon.png" "$HESTIA/web/images/favicon.png"
 elif [ ! -f "$HESTIA/web/images/custom/favicon.png" ] && [ "$download" = "yes" ]; then
-	download_file https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/images/favicon.png $HESTIA/web/images/favicon.png
+	download_file "https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/images/favicon.png" "$HESTIA/web/images/favicon.png"
 fi
 
 if [ -f "$HESTIA/web/images/custom/favicon.ico" ]; then
-	cp -f $HESTIA/web/images/custom/favicon.ico $HESTIA/web/favicon.ico
+	cp -f "$HESTIA/web/images/custom/favicon.ico" "$HESTIA/web/favicon.ico"
 elif [ ! -f "$HESTIA/web/images/custom/favicon.ico" ] && [ "$download" = "yes" ]; then
-	download_file https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/favicon.ico $HESTIA/web/favicon.ico
+	download_file "https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/favicon.ico" "$HESTIA/web/favicon.ico"
 fi
 
 #----------------------------------------------------------#

+ 6 - 0
web/edit/server/whitelabel/index.php

@@ -78,6 +78,12 @@ if (!empty($_POST)) {
 			$return_var,
 		);
 	}
+	if (!empty($_POST["v_update_logo"])) {
+		exec(HESTIA_CMD . "v-update-white-label-logo");
+	}
+	if (!empty($_POST["v_reset_logo"])) {
+		exec(HESTIA_CMD . "v-update-white-label-logo yes yes");
+	}
 }
 
 // Check system configuration

+ 10 - 4
web/templates/pages/edit_whitelabel.php

@@ -113,7 +113,7 @@
 					</div>
 				</div>
 			</details>
-			<!-- Basic options section -->
+			<!-- Custom Logo options section -->
 			<details class="collapse u-mb10">
 				<summary class="collapse-header">
 					<i class="fas fa-gear u-mr15"></i>
@@ -130,17 +130,23 @@
 						<ul>
 							<li>logo.svg <small>(100px x 120px)</small></li>
 							<li>logo.png <small>(100px x 120px)</small></li>
-							<li>logo-header.png <small>(54x x 29px)</small></li>
+							<li>logo-header.svg <small>(54x x 29px)</small></li>
 							<li>favicon.png <small>(64px x 64px)</small></li>
-							<li>favicon.ico<<small>(16px x 16px)</small></li>
+							<li>favicon.ico<small>(16px x 16px)</small></li>
 						</ul>
 					</div>
 					<div class="u-mb10">
-						<input type="checkbox" id="v_update_logo" name="v_update_logo">
+						<input type="checkbox" id="v_update_logo" name="v_update_logo" value="yes">
 						<label for="v_update_logo" class="form-label">
 							<?= _("Update logo") ?>
 						</label>
 					</div>
+					<div class="u-mb10">
+						<input type="checkbox" id="v_reset_logo" name="v_reset_logo" value="yes">
+						<label for="v_reset_logo" class="form-label">
+							<?= _("Reset Logo") ?>
+						</label>
+					</div>
 			</details>
 		</div>
 	</form>