Skip to content

Commit

Permalink
syncthing: update to v1.23.4 and include next-gen-gui (#5523)
Browse files Browse the repository at this point in the history
* syncthing: update to v1.22.2 and include next-gen-gui
- update syncthing to v1.22.2
- include next-get-gui and provide it under /tech-ui
- fix parameter of ca_reloader.sh
- fix link in wizard files

* syncthing #3320
- avoid the creation of a default folder on first startup

* fix usage text in ca_reloader.sh

* clarify that the parameter --no-default-folder is ignored after the first start of syncthing

* Update spk/syncthing/Makefile

Co-authored-by: André Colomb <github.com@andre.colomb.de>

* Update cross/syncthing/PLIST

Co-authored-by: André Colomb <github.com@andre.colomb.de>

* avoid to use $HOME as default sync folder

* update syncthing configuration

- avoid the use of '--home' argument as not related to HOME env. variable
- enable to define custom HOME folder in options.conf

* create options.conf.new on package update for DSM<7

* update wizard pages

- add customization information to wizard
- fix install_uifile_fre (add wizard_username and wizard_password)
- add information for options.conf.new to upgrade wizard

* Update spk/syncthing/src/service-setup.sh

Co-authored-by: André Colomb <github.com@andre.colomb.de>

* move tech-ui to dedicated module and download prebuilt release

- omit to compile synchthing --with-next-gen-gui

* syncthing: udpate to v1.23.4

Co-authored-by: André Colomb <github.com@andre.colomb.de>

* final cleanup
- avoid running ca_reloader.sh on DSM 7+

---------

Co-authored-by: André Colomb <github.com@andre.colomb.de>
  • Loading branch information
hgy59 and acolomb committed Apr 26, 2023
1 parent d3423ac commit 19ec801
Show file tree
Hide file tree
Showing 14 changed files with 212 additions and 43 deletions.
29 changes: 29 additions & 0 deletions cross/syncthing-tech-ui/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
PKG_NAME = syncthing-tech-ui
PKG_REAL_NAME = tech-ui
PKG_VERS = 1.0.0
PKG_EXT = zip
PKG_DIST_NAME = $(PKG_REAL_NAME)-v$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/syncthing/tech-ui/releases/download/v$(PKG_VERS)
PKG_DIR = $(PKG_REAL_NAME)-v$(PKG_VERS)

# Remarks:
# The repository https://github.com/syncthing/tech-ui is archived
# Current development is in https://github.com/syncthing/syncthing/tree/main/next-gen-gui
# but there are no downloadable releases for tech-ui in the syncthing repository.
#
# Until otherwise requested, we take the only official release published on Apr 17, 2020.
#

HOMEPAGE = https://github.com/syncthing/syncthing/tree/main/next-gen-gui
COMMENT = Alternative, stripped down status UI for large setups.
LICENSE = MPL-2.0

INSTALL_TARGET = syncthing-tech-ui_install

include ../../mk/spksrc.install-resources.mk

.PHONY: syncthing-tech-ui_install
syncthing-tech-ui_install:
@$(MSG) Install tech-ui
@install -d -m 755 $(STAGING_INSTALL_PREFIX)/gui/default/tech-ui
@tar -cf - -C $(WORK_DIR)/tech-ui . | tar -xf - -C $(STAGING_INSTALL_PREFIX)/gui/default/tech-ui
1 change: 1 addition & 0 deletions cross/syncthing-tech-ui/PLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rsc:gui/default/tech-ui/
3 changes: 3 additions & 0 deletions cross/syncthing-tech-ui/digests
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tech-ui-v1.0.0.zip SHA1 155679ebd818c736208cb57ac29e8d2ffb7351b9
tech-ui-v1.0.0.zip SHA256 aab6df18f9d82ec6ea72414ab9cfaedce963d27e3d87a1b729d2f30f43b16558
tech-ui-v1.0.0.zip MD5 159e7acfe7333f5051acaa56e2a83453
6 changes: 3 additions & 3 deletions cross/syncthing/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
PKG_NAME = syncthing
PKG_VERS = 1.22.1
PKG_VERS = 1.23.4
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_NAME)-source-v$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/syncthing/syncthing/releases/download/v$(PKG_VERS)
PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIR = src/github.com/$(PKG_NAME)
EXTRACT_PATH = $(WORK_DIR)/$(PKG_DIR)

DEPENDS = native/go
BUILD_DEPENDS = native/go

HOMEPAGE = https://www.syncthing.net/
COMMENT = Syncthing is a continuous file synchronization program. It synchronizes files between two or more computers.
Expand All @@ -22,6 +21,7 @@ include ../../mk/spksrc.cross-go.mk

BUILD_ARGS = -goos=$(GOOS) -goarch=$(GO_ARCH) -version=v$(PKG_VERS)

.PHONY: syncthing_compile
# use custom build to remove GOARCH from ENV and for custom BUILD_ARGS
syncthing_compile:
cd $(GO_SRC_DIR) && env $(filter-out GOARCH=%, $(ENV)) go run build.go $(BUILD_ARGS) build
6 changes: 3 additions & 3 deletions cross/syncthing/digests
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
syncthing-1.22.1.tar.gz SHA1 c8e0e75b0ba5b04f4f7ce8a98dcf7212733dce37
syncthing-1.22.1.tar.gz SHA256 b024d112167e0e81a785ab98c1a044aee1ac041dfe57a62772c08284f875a5bd
syncthing-1.22.1.tar.gz MD5 6947b7b3a1eaf03d8e6f371894c37b41
syncthing-source-v1.23.4.tar.gz SHA1 e4aead28fa927acc618d69d702a75703faa37bc0
syncthing-source-v1.23.4.tar.gz SHA256 06a2882f8ac49e15faf96025b01d0edcd4cc190a419d5de98fbe8271695329fa
syncthing-source-v1.23.4.tar.gz MD5 59280b2e551a8001ce84867c27398aa3
12 changes: 7 additions & 5 deletions spk/syncthing/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
SPK_NAME = syncthing
SPK_VERS = 1.22.1
SPK_REV = 28
SPK_VERS = 1.23.4
SPK_REV = 29
SPK_ICON = src/syncthing.png
DSM_UI_DIR = app

DEPENDS = cross/$(SPK_NAME)
DEPENDS = cross/syncthing
DEPENDS += cross/syncthing-tech-ui

# archs not supported by go
UNSUPPORTED_ARCHS = $(PPC_ARCHS)

MAINTAINER = acolomb
DESCRIPTION = Automatically sync files via secure, distributed technology.
DESCRIPTION_FRE = Synchronisation automatique de fichiers via une technologie sécurisée et distribuée.
DISPLAY_NAME = Syncthing
CHANGELOG = "1. Update syncthing to v1.22.1."
CHANGELOG = "1. Update syncthing to v1.23.4.<br/>2. Include next gen gui (path: /tech-ui)."
HOMEPAGE = https://www.syncthing.net
LICENSE = MPLv2.0
STARTABLE = yes
Expand All @@ -22,7 +24,7 @@ WIZARDS_DIR = src/wizard/
SERVICE_USER = auto
SERVICE_SETUP = src/service-setup.sh
SERVICE_PORT = 8384
SERVICE_PORT_TITLE = $(DISPLAY_NAME)
SERVICE_PORT_TITLE = Syncthing Web GUI
SERVICE_CERT = syncthing_webui
SERVICE_CERT_RELOAD = tools/ca_reloader.sh

Expand Down
21 changes: 12 additions & 9 deletions spk/syncthing/src/ca_reloader.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
#!/bin/sh

source /etc.defaults/VERSION
if [ ${majorversion} -ge 7 ]; then
echo "ERROR: ${0} does not work on DSM 7+" >&2
exit -1
fi

CERT_DIR=/usr/local/etc/certificate/syncthing/syncthing_webui
CONF_DIR=/var/packages/syncthing/var
if [ ! -d "$CONF_DIR" ]; then
CONF_DIR=/var/packages/syncthing/target/var
fi
SYNCTHING=/var/packages/syncthing/target/bin/syncthing

case $1 in
syncthing_webui)
# Forcefully overwrite certificate files by symlinks
ln -sf $CERT_DIR/cert.pem $CONF_DIR/https-cert.pem
ln -sf $CERT_DIR/privkey.pem $CONF_DIR/https-key.pem
ln -sf ${CERT_DIR}/cert.pem ${CONF_DIR}/https-cert.pem
ln -sf ${CERT_DIR}/privkey.pem ${CONF_DIR}/https-key.pem

# Required: set $HOME environment variable
HOME=$CONF_DIR
HOME=${CONF_DIR}
export HOME

$SYNCTHING cli --home=$CONF_DIR operations restart
${SYNCTHING} cli --config=${CONF_DIR} --data=${CONF_DIR} operations restart
RESTART_STATUS=$?
exit $RESTART_STATUS
exit ${RESTART_STATUS}
;;
*)
echo "Usage: $0 syncthing-webui" >&2
echo "Usage: $0 syncthing_webui" >&2
exit 1
;;
esac
2 changes: 1 addition & 1 deletion spk/syncthing/src/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<insecureAllowOldTLSVersions>false</insecureAllowOldTLSVersions>
</options>
<defaults>
<folder ignorePerms="true">
<folder ignorePerms="true" path="">
</folder>
</defaults>
</configuration>
24 changes: 20 additions & 4 deletions spk/syncthing/src/options.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
#!/bin/sh
# This file will be added to start-stop-status script
# This file is included in the start-stop-status script
# for customization of syncthing service

# To add additional parameters to start syncthing with, define the variable SYNCTHING_OPTIONS
# For possible options see syncthing --help

# Example: uncomment this to start syncthing with all devices paused
# SYNCTHING_OPTIONS="-paused"
# Example: to start syncthing with all devices paused
#SYNCTHING_OPTIONS="--paused"


# Additionally you can define environment variables for the syncthing service
# REMARKS:
# HOME is the only variable that is exported by the start-stop-status script
# other environment variables must be exported here.
#
# Example: set a custom folder for the web gui
# - this folder needs a subfolder with the template name (default is "default")
# containing the web page resources
#export STGUIASSETS=/my_custom_web_gui_folder
#
# Example: set your custom HOME folder:
#HOME=/volume1/my_syncthing_home_folder
52 changes: 42 additions & 10 deletions spk/syncthing/src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
# syncthing service definition
SYNCTHING="${SYNOPKG_PKGDEST}/bin/syncthing"
SERVICE_COMMAND="${SYNCTHING} serve --home=${SYNOPKG_PKGVAR}"
# define folder for configuration (config, keys, database, logs)
SYNCTHING_CONFIG="--config=${SYNOPKG_PKGVAR} --data=${SYNOPKG_PKGVAR}"
SERVICE_COMMAND="${SYNCTHING} serve ${SYNCTHING_CONFIG}"
SVC_BACKGROUND=y
SVC_WRITE_PID=y

GROUP="sc-syncthing"

# Required to run any syncthing command: set $HOME environment variable
HOME=${SYNOPKG_PKGVAR}
export HOME

# include next gen gui
export STGUIASSETS=${SYNOPKG_PKGDEST}/gui

set_credentials() {
if [ -n "${wizard_username}" -a -n "${wizard_password}" ]; then
echo "set user name ${wizard_username} for syncthing Web GUI access"
# Password needs to be hashed for config entry
${SYNCTHING} generate --home=${SYNOPKG_PKGVAR} \
--gui-user="${wizard_username}" --gui-password="${wizard_password}"
# Required to run any syncthing command: set $HOME environment variable
HOME=${SYNOPKG_PKGVAR} ${SYNCTHING} generate \
--config=${SYNOPKG_PKGVAR} \
--gui-user="${wizard_username}" \
--gui-password="${wizard_password}"
fi
}

Expand All @@ -27,12 +31,20 @@ service_postinst() {

service_prestart ()
{
# Read additional startup options from var/options.conf
# Read additional startup options and variables from var/options.conf
if [ -f ${SYNOPKG_PKGVAR}/options.conf ]; then
. ${SYNOPKG_PKGVAR}/options.conf
SERVICE_COMMAND="${SERVICE_COMMAND} ${SYNCTHING_OPTIONS}"
fi

# Required to run any syncthing command: set $HOME environment variable
if [ -z "${HOME}" ]; then
# if HOME is not set in options.conf
# use a default folder the package user has permissions for
HOME=${SYNOPKG_PKGVAR}
fi
export HOME

# If the system has a TLS certificate for us, force its usage
cert_dir=/usr/local/etc/certificate/${SYNOPKG_PKGNAME}/${SERVICE_CERT}
if [ -f ${cert_dir}/cert.pem -a -f ${cert_dir}/privkey.pem ]; then
Expand All @@ -41,6 +53,25 @@ service_prestart ()
fi
}


service_save ()
{
if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then
if [ -e ${SYNOPKG_PKGVAR}/options.conf.new ]; then
echo "remove former version of options.conf.new"
rm -f ${SYNOPKG_PKGVAR}/options.conf.new
fi
fi
}

service_restore ()
{
if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then
echo "install updated options.conf as options.conf.new"
mv -f ${SYNOPKG_PKGVAR}/options.conf ${SYNOPKG_PKGVAR}/options.conf.new
fi
}

version_le()
{
if printf '%s\n' "$1" "$2" | sort -VC ; then
Expand All @@ -51,8 +82,9 @@ version_le()

service_preupgrade()
{
CUR_VER=$(${SYNCTHING} --version | awk '{print $2}' | awk --field-separator=- '{print $1}')
PKG_VER=$(${SYNOPKG_PKGINST_TEMP_DIR}/bin/syncthing --version | awk '{print $2}' | awk --field-separator=- '{print $1}')
# Required to run any syncthing command: set $HOME environment variable
CUR_VER=$(HOME=${SYNOPKG_PKGVAR} ${SYNCTHING} --version | awk '{print $2}' | awk --field-separator=- '{print $1}')
PKG_VER=$(HOME=${SYNOPKG_PKGVAR} ${SYNOPKG_PKGINST_TEMP_DIR}/bin/syncthing --version | awk '{print $2}' | awk --field-separator=- '{print $1}')
if version_le $CUR_VER $PKG_VER; then
echo "Package ${PKG_VER} is newer than or same as installed binary ${CUR_VER}"
else
Expand Down
13 changes: 11 additions & 2 deletions spk/syncthing/src/wizard/install_uifile
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,19 @@
]
},
{
"step_title": "DSM Permissions",
"step_title": "Permissions and Customization",
"items": [
{
"desc": "Permissions for this package are handled by the <b>'sc-syncthing'</b> group. <br>Using File Station, add this group to every folder Syncthing should be allowed to access.<br>Please read <a <a target=\"_blank\" href=\"https://github.com/SynoCommunity/spksrc/wiki/Permission-Management\">Permission Management</a> for details."
"desc": "<b>Permissions</b>"
},
{
"desc": "Permissions for this package are handled by the <b>'sc-syncthing'</b> group. <br>Using File Station, add this group to every folder Syncthing should be allowed to access. <br/>Please read <a target=\"_blank\" href=\"https://github.com/SynoCommunity/spksrc/wiki/Permission-Management\">Permission Management</a> for details."
},
{
"desc": "<b>Customization</b>"
},
{
"desc": "For advanced customization you can edit the file <code>/var/packages/syncthing/var/options.conf</code>. For example, you can define a custom <code>HOME</code> folder or additional parameters to start Syncthing with. <br/>To modify the options file, you need <code>SSH</code> access with a privileged user account. To apply your modifications, you have to restart Syncthing in the Package Center."
}
]
}
Expand Down
54 changes: 52 additions & 2 deletions spk/syncthing/src/wizard/install_uifile_fre
Original file line number Diff line number Diff line change
@@ -1,10 +1,60 @@
[
{
"step_title": "Permissions DSM",
"step_title": "Authentification pour interface graphique",
"invalid_next_disabled": true,
"items": [
{
"desc": "Les permissions de toutes les applications de téléchargement sont gérées par le groupe <b>'sc-syncthing'</b> dans DSM.<br>Depuis File Station, ajouter ce groupe à tout répertoire auquel Syncthing doit avoir accès.<br>Merci de lire <a target=\"_blank\" href=\"https://github.com/SynoCommunity/spksrc/wiki/Permission-Management\">Permission Management</a> pour plus de détails."
"desc": "L'interface graphique Syncthing ne doit pas être accessible sans authentification. Ce serait dangereux car avec l'accès à l'interface graphique Web, n'importe quel dossier peut être configuré pour être partagé par un tiers malveillant.<br/>Veuillez fournir un nom d'utilisateur et un mot de passe pour vous protéger contre les connexions non autorisées. Il sera requis à chaque ouverture de l'interface graphique de Syncthing.<br/><br/>(Laisser l'un ou l'autre des champs vide désactive l'authentification.)"
},
{
"type": "textfield",
"subitems": [
{
"key": "wizard_username",
"desc": "Nom d'utilisateur",
"defaultValue": "syncthing",
"validator": {
"allowBlank": true,
"regex": {
"expr": "/^[^<>:*/?\"|]*$/",
"errorText": "Caractère non autorisé dans le nom d'utilisateur"
}
}
}
]
},
{
"type": "password",
"subitems": [
{
"key": "wizard_password",
"desc": "Le mot de passe",
"validator": {
"allowBlank": true,
"regex": {
"expr": "/^[^<>:*/?\"|]*$/",
"errorText": "Caractère non autorisé dans le mot de passe"
}
}
}
]
}
]
},
{
"step_title": "Permissions et Personnalisation",
"items": [
{
"desc": "<b>Permissions</b>"
},
{
"desc": "Les permissions pour cette application sont gérées par le groupe <b>'sc-syncthing'</b>.<br>Depuis File Station, ajouter ce groupe à tout répertoire auquel Syncthing doit avoir accès.<br>Merci de lire <a target=\"_blank\" href=\"https://github.com/SynoCommunity/spksrc/wiki/Permission-Management\">Permission Management</a> pour plus de détails."
},
{
"desc": "<b>Personnalisation</b>"
},
{
"desc": "Pour une personnalisation avancée, vous pouvez modifier le fichier <code>/var/packages/syncthing/var/options.conf</code>. Par exemple, vous pouvez définir un dossier <code>HOME</code> personnalisé ou des paramètres supplémentaires avec lesquels démarrer Syncthing. <br/>Pour modifier le fichier d'options, vous avez besoin d'un accès <code>SSH</code> avec un compte utilisateur privilégié. <br/>Pour appliquer vos modifications, vous devez redémarrer Syncthing dans le Centre de paquets." }
]
}
]
Expand Down
16 changes: 14 additions & 2 deletions spk/syncthing/src/wizard/upgrade_uifile
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
[
{
"step_title": "DSM Permissions",
"step_title": "Permissions and Customization",
"items": [
{
"desc": "Permissions for this package are handled by the <b>'sc-syncthing'</b> group. <br>Using File Station, add this group to every folder Syncthing should be allowed to access.<br>Please read <a <a target=\"_blank\" href=\"https://github.com/SynoCommunity/spksrc/wiki/Permission-Management\">Permission Management</a> for details."
"desc": "<b>Permissions</b>"
},
{
"desc": "Permissions for this package are handled by the <b>'sc-syncthing'</b> group. <br>Using File Station, add this group to every folder Syncthing should be allowed to access. <br/>Please read <a target=\"_blank\" href=\"https://github.com/SynoCommunity/spksrc/wiki/Permission-Management\">Permission Management</a> for details."
},
{
"desc": "<b>Customization</b>"
},
{
"desc": "For advanced customization you can edit the file <code>/var/packages/syncthing/var/options.conf</code>. For example, you can define a custom <code>HOME</code> folder or additional parameters to start Syncthing with. <br/>To modify the options file, you need <code>SSH</code> access with a privileged user. To apply your modifications, you have to restart Syncthing in the Package Center."
},
{
"desc": "<b>This update does not modify your existing <code>options.conf</code> file. Please find additional examples in the provided file <code>options.conf.new</code> in the same folder.</b>"
}
]
}
Expand Down
Loading

0 comments on commit 19ec801

Please sign in to comment.