sulu: Option to enable PWA

- Added option to enable PWA support
- Option to define path of PWA certificates
- Form validation fix
This commit is contained in:
Vivek Kumar Dutta 2023-08-03 19:00:56 +05:30
parent ec9495cd41
commit ebbe691ecc
No known key found for this signature in database
GPG key ID: 65C818099F37097D
5 changed files with 82 additions and 11 deletions

View file

@ -85,3 +85,19 @@ After adding the makefile, user need to specify the list of plugins in below con
```bash
CONFIG_SULU_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.

View file

@ -5,11 +5,11 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sulu-base
PKG_VERSION:=2.2.14
PKG_VERSION:=2.3.0
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/websdk/sulu.git
PKG_SOURCE_VERSION:=d784f1fdd9adff34bbf8daf8bf6510fc0c2d0e4d
PKG_SOURCE_VERSION:=f7d77710c288668c7abf84ec82eeffc613723004
PKG_MIRROR_HASH:=skip
SULU_MOD:=core

View file

@ -5,12 +5,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sulu-builder
PKG_VERSION:=2.2.18
PKG_VERSION:=2.3.0
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/websdk/sulu-builder.git
PKG_SOURCE_VERSION:=5e54e4e6bd9829019daeac535276521fc25d8d9e
PKG_SOURCE_VERSION:=6d4933ac821600b051193951f24765569da2c9a4
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_SOURCE_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/sulu-$(PKG_VERSION)/sulu-builder-$(PKG_SOURCE_VERSION)
@ -28,7 +28,8 @@ define Package/sulu/default
CATEGORY:=Utilities
SUBMENU:=SULU
TITLE:=SULU-CE
DEPENDS:=+nginx +mosquitto-auth-shadow +usermngr +jq
DEPENDS:=+mosquitto-auth-shadow +usermngr +jq
EXTRA_DEPENDS:=nginx
endef
define Package/sulu
@ -41,10 +42,10 @@ endef
define Package/sulu-builder
$(Package/sulu/default)
CONFLICTS:=sulu
TITLE += (Builder)
VARIANT:=builder
DEPENDS+=+sulu-base $(foreach plugin,$(SULU_PLUGINS), +PACKAGE_$(plugin):$(plugin)) $(foreach plugin,$(SULU_EXTRA), +PACKAGE_$(plugin):$(plugin))
MENU:=1
endef
define Package/sulu/description
@ -55,16 +56,45 @@ define Package/sulu-builder/description
SULU-CE ReactJS based Web UI builder.
endef
define Package/sulu/config
config SULU_PWA_APP
depends on PACKAGE_sulu
bool "Enable SULU PWA App support"
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'.
endef
define Package/sulu-builder/config
menu "Configuration"
depends on PACKAGE_sulu-builder
config SULU_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.
endmenu
config SULU_PWA_APP
depends on PACKAGE_sulu-builder
bool "Enable SULU PWA App support"
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'.
endef
ifeq ($(BUILD_VARIANT),builder)
@ -99,11 +129,19 @@ define Package/sulu/install/Default
$(INSTALL_BIN) ./files/etc/uci-defaults/40-add-sulu-nginx-config $(1)/etc/uci-defaults/
$(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
$(Package/sulu/install/Default)
$(CP) $(PKG_BUILD_DIR)/dist/* $(1)/sulu
ifneq ($(CONFIG_SULU_PWA_APP),y)
$(CP) $(PKG_BUILD_DIR)/dist/nonPWA.html $(1)/sulu/index.html
endif
ifneq ($(CONFIG_PACKAGE_skopeo)$(CONFIG_PACKAGE_umoci),yy)
$(RM) $(1)/sulu/config/widgets/lcm-store.json
endif
@ -112,6 +150,9 @@ endef
define Package/sulu-builder/install
$(Package/sulu/install/Default)
$(CP) $(PKG_BUILD_DIR)/build/dist/* $(1)/sulu
ifneq ($(CONFIG_SULU_PWA_APP),y)
$(CP) $(PKG_BUILD_DIR)/build/dist/nonPWA.html $(1)/sulu/index.html
endif
$(CP) $(PKG_BUILD_DIR)/build/src/config/*.json $(1)/sulu/config/
$(CP) $(PKG_BUILD_DIR)/build/src/config/widgets/diagnostics.json $(1)/sulu/config/widgets/
$(CP) $(PKG_BUILD_DIR)/build/src/config/widgets/wan.json $(1)/sulu/config/widgets/

View file

@ -0,0 +1,14 @@
#!/bin/sh
. /lib/functions.sh
set_sulu_pwa_key()
{
if [ -f "/etc/sulu/pwa.crt" -a -f "/etc/sulu/pwa.key" ]; then
uci_load nginx
uci_set nginx _sulu_s ssl_certificate '/etc/sulu/pwa.crt'
uci_set nginx _sulu_s ssl_certificate_key '/etc/sulu/pwa.key'
fi
}
set_sulu_pwa_key

View file

@ -8,7 +8,7 @@ PKG_VERSION:=2.2.18
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/websdk/sulu-multi-ap.git
PKG_SOURCE_VERSION:=85a22654455597cbf44d41f72e751a26cdac8092
PKG_SOURCE_VERSION:=ae4cb0a27b7d084aaad69e81cb4d96d88ecdffee
PKG_MIRROR_HASH:=skip
include ../sulu-builder/sulu.mk