From 8ba85e2e4032d0f2d1bd35541d2bc211fed0d481 Mon Sep 17 00:00:00 2001 From: Reidar Cederqvist Date: Wed, 22 Jan 2025 08:07:00 +0000 Subject: [PATCH] sulu: 4.0.2 - remove unused config options - add new option to make sulu default WEB UI --- sulu/Readme.md | 34 ++++------ sulu/sulu-builder/Makefile | 68 +++---------------- .../etc/uci-defaults/41-make-sulu-default-ui | 54 +++++++++++++++ 3 files changed, 79 insertions(+), 77 deletions(-) create mode 100755 sulu/sulu-builder/files/etc/uci-defaults/41-make-sulu-default-ui diff --git a/sulu/Readme.md b/sulu/Readme.md index 0f9097e87..713482ba0 100644 --- a/sulu/Readme.md +++ b/sulu/Readme.md @@ -85,27 +85,9 @@ In the above example Makefile, if user need to install any plugin specific compo After adding the makefile, user need to specify the list of plugins in below config option, so that sulu-builder selects them and build them along with it. ```bash -CONFIG_SULU_EXTRA_PACKAGES="sulu-plugin1 sulu-plugin2 sulu-theme1" +CONFIG_SULU_BUILDER_EXTRA_PACKAGES="sulu-plugin1 sulu-plugin2 sulu-theme1" ``` -# SULU PWA (Progressive Web App) - -PWA applications generally used for well know secured sites, which can be installed directly from web-browser as desktop/mobile application. - -> Note: -> -> 1. It requires well defined SSL keys for deployment of PWA for a defined site. -> 2. It should be used with sites with well defined FQDN - -To enable SULU PWA application, user need to select PWA in sulu/sulu-builder config options and provide the path of the pwa key file - -```bash -CONFIG_SULU_PWA_APP=y -CONFIG_SULU_PWA_KEYS_PATH="/somepath_with_pwa.{crt,key}" -``` - -> Note: Replacing/changing the keys might requires uninstall/install of PWA App and CTRL+Shift+R in browser to drop the cached site and load the new site with new keys. - # How to create a new Sulu user with Role Based Access Controller Sulu has a predefined set of users, but if it is required to add user with more/less datamodel access rights, that can be done from a USP Controller(sulu etc) or by using the command line tool. @@ -186,3 +168,17 @@ reboot ``` After device boots sulu should be able to login with newly added user. + +## Make sulu the default UI + +If you want SULU to be hosted on port 443 instead of 8443, just select the config option + +```bash +CONFIG_SULU_DEFAULT_UI=y +``` + +or + +```bash +CONFIG_SULU_BUILDER_DEFAULT_UI=y +``` diff --git a/sulu/sulu-builder/Makefile b/sulu/sulu-builder/Makefile index 08b27e6db..852fe17d4 100644 --- a/sulu/sulu-builder/Makefile +++ b/sulu/sulu-builder/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sulu-builder -PKG_VERSION:=4.0.1 +PKG_VERSION:=4.0.2 PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git @@ -20,7 +20,7 @@ PKG_LICENSE:=PROPRIETARY IOPSYS PKG_LICENSE_FILES:=LICENSE SULU_PLUGINS:=$(filter-out sulu-builder,$(filter-out Readme.md,$(notdir $(wildcard ../*)))) -SULU_EXTRA:=$(subst $\",,$(CONFIG_SULU_EXTRA_PACKAGES)) +SULU_EXTRA:=$(subst $\",,$(CONFIG_SULU_BUILDER_EXTRA_PACKAGES)) include $(INCLUDE_DIR)/package.mk define Package/sulu/default @@ -57,65 +57,25 @@ define Package/sulu-builder/description endef define Package/sulu/config - config SULU_PWA_APP + config SULU_DEFAULT_UI depends on PACKAGE_sulu - bool "Enable SULU PWA App support" + bool "Makes Sulu run on port 443 instead of 8443" default n - help - Enable SULU PWA (Progressive Web App) support, this requires - 'pwa.crt' and 'pwa.key' to be installed in '/etc/sulu/' directory. - - config SULU_PWA_KEYS_PATH - depends on PACKAGE_sulu - string "Path of pwa.crt and pwa.key for sulu/PWA" - help - Provide directory path for the certficates for PWA, - directory must contain 'pwa.crt' and 'pwa.key'. - - config SULU_EXPERIMENTAL_WIDGETS - depends on PACKAGE_sulu - bool "Enable SULU under developement widget" - default n - help - Enable SULU Widgets which are under developement. endef define Package/sulu-builder/config - config SULU_EXTRA_PACKAGES + config SULU_BUILDER_EXTRA_PACKAGES depends on PACKAGE_sulu-builder string "Space separated list of sulu packages" help You can specify the list of non core sulu package, so that sulu-builder include them before building the core. - config SULU_ENV_DATA + config SULU_BUILDER_DEFAULT_UI depends on PACKAGE_sulu-builder - string "Sulu env data" - help - Use this option to initialize sulu build time environment options. - - config SULU_PWA_APP - depends on PACKAGE_sulu-builder - bool "Enable SULU PWA App support" + bool "Makes Sulu run on port 443 instead of 8443" default n - help - Enable SULU PWA (Progressive Web App) support, this requires - 'pwa.crt' and 'pwa.key' to be installed in '/etc/sulu/' directory. - - config SULU_PWA_KEYS_PATH - depends on PACKAGE_sulu-builder - string "Path of pwa.crt and pwa.key for sulu/PWA" - help - Provide directory path for the certficates for PWA, - directory must contain 'pwa.crt' and 'pwa.key'. - - config SULU_EXPERIMENTAL_WIDGETS - depends on PACKAGE_sulu-builder - bool "Enable SULU under developement widget" - default n - help - Enable SULU Widgets which are under developement. endef @@ -151,13 +111,11 @@ define Package/sulu/install/Default $(INSTALL_DIR) $(1)/etc/uci-defaults $(INSTALL_BIN) ./files/etc/uci-defaults/99-fix-sulu-config $(1)/etc/uci-defaults/ $(INSTALL_BIN) ./files/etc/uci-defaults/40-add-sulu-userinterface-config $(1)/etc/uci-defaults/ +ifneq ($(CONFIG_SULU_DEFAULT_UI)$(CONFIG_SULU_BUILDER_DEFAULT_UI),) + $(INSTALL_BIN) ./files/etc/uci-defaults/41-make-sulu-default-ui $(1)/etc/uci-defaults/ +endif $(INSTALL_BIN) ./files/etc/uci-defaults/01-update-nginx-uci-template $(1)/etc/uci-defaults/ $(INSTALL_BIN) ./files/etc/uci-defaults/10-add-mqtt-config $(1)/etc/uci-defaults/ -ifeq ($(CONFIG_SULU_PWA_APP),y) - $(INSTALL_BIN) ./files/etc/uci-defaults/99-eval-set-sulu-pwa-keys $(1)/etc/uci-defaults/ - $(INSTALL_DATA) $(CONFIG_SULU_PWA_KEYS_PATH)/pwa.crt $(1)/etc/sulu/ - $(INSTALL_DATA) $(CONFIG_SULU_PWA_KEYS_PATH)/pwa.key $(1)/etc/sulu/ -endif endef define Package/sulu/install/Post @@ -165,12 +123,6 @@ define Package/sulu/install/Post ifneq ($(CONFIG_PACKAGE_skopeo)$(CONFIG_PACKAGE_umoci),yy) $(RM) $(1)/sulu/presets/lcm-store.json endif -ifneq ($(CONFIG_SULU_EXPERIMENTAL_WIDGETS),y) - $(RM) $(1)/sulu/presets/mesh-onboarding-instructions.json -endif -ifneq ($(CONFIG_SULU_PWA_APP),y) - $(CP) $(PKG_BUILD_DIR)/dist/nonPWA.html $(1)/sulu/index.html -endif endef define Package/sulu/install diff --git a/sulu/sulu-builder/files/etc/uci-defaults/41-make-sulu-default-ui b/sulu/sulu-builder/files/etc/uci-defaults/41-make-sulu-default-ui new file mode 100755 index 000000000..f5b3cff19 --- /dev/null +++ b/sulu/sulu-builder/files/etc/uci-defaults/41-make-sulu-default-ui @@ -0,0 +1,54 @@ +#!/bin/sh + +. /lib/functions.sh + +uci_load nginx +# this is to make sure to not mess up existing config +if uci_get nginx _sulu_s >/dev/null 2>&1; then + exit 0 +fi + +move_default_nginx_listener_to_8443() { + + if [ ! -f /etc/config/nginx ]; then + return + fi + + if ! uci_get nginx _lan >/dev/null 2>&1; then + return + fi + + uci_remove nginx _lan listen + uci_add_list nginx _lan listen "8443 ssl default_server" + uci_add_list nginx _lan listen "[::]:8443 ssl default_server" + + if ! uci_get nginx _redirect2ssl >/dev/null 2>&1; then + return + fi + + uci_remove nginx _redirect2ssl listen + uci_add_list nginx _redirect2ssl listen "8080" + uci_add_list nginx _redirect2ssl listen "[::]:8080" + uci_set nginx _redirect2ssl return '302 https://$host:8443$request_uri' +} + +move_sulu_to_443_and_80() { + uci_load userinterface + if [ ! -f /etc/config/userinterface ]; then + return + fi + + set_port() { + local protocol + config_get protocol "$1" protocol + if [ "$protocol" == "HTTPS" ]; then + uci_set userinterface "$1" port "443" + elif [ "$protocol" == "HTTP" ]; then + uci_set userinterface "$1" port "80" + fi + } + config_foreach set_port http_access +} + +move_default_nginx_listener_to_8443 +move_sulu_to_443_and_80