Skip to content

Commit

Permalink
Test of pr/SynoCommunity#5649
Browse files Browse the repository at this point in the history
redesign shared folder handling
  • Loading branch information
mreid-tt committed Mar 17, 2023
1 parent 136d70d commit 047dc32
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
8 changes: 0 additions & 8 deletions mk/spksrc.service.installer.dsm7
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,6 @@ preinst ()
call_func "validate_preinst"
call_func "service_preinst" install_log

# Check volume exists
if [ -n "${SHARE_PATH}" ]; then
if [ ! -d "${SHARE_VOLUME}" ]; then
echo "ERROR: Volume ${SHARE_VOLUME} does not exist." | $TEE 1>&2
exit 1
fi
fi

exit 0
}

Expand Down
8 changes: 2 additions & 6 deletions mk/spksrc.service.installer.functions
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

### common installer functions and variables for synocommunity generic service installer
#
# functions are common for all DSM versions
Expand Down Expand Up @@ -48,11 +47,8 @@ initialize_variables ()

# Extract share volume and share name from download location if provided
if [ -n "${SHARE_PATH}" ]; then
if [ -n "${wizard_volume}" ]; then
SHARE_PATH="${wizard_volume}/${SHARE_PATH}"
fi
SHARE_VOLUME=$(echo "${SHARE_PATH}" | awk -F/ '{print "/"$2}')
SHARE_NAME=$(echo "${SHARE_PATH}" | awk -F/ '{print $3}')
SHARE_VOLUME=$(echo "$(realpath ${SHARE_PATH})" | awk -F/ '{print "/"$2}')
SHARE_NAME=$(echo $(realpath ${SHARE_PATH}) | awk -F/ '{print $3}')
fi
}

Expand Down
28 changes: 18 additions & 10 deletions mk/spksrc.service.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
# SERVICE_CERT_RELOAD (optional) package-relative path to a script for reloading the service after certificate changes
# SERVICE_TYPE service type for dsm-ui config file, default = "url"
# SERVICE_WIZARD_GROUP (optional) use name of wizard-variable to define the GROUP
# SERVICE_WIZARD_SHARE (optional) use name of wizard-varible to define SHARE_PATH (uses DSM data share worker for DSM 7)
# USE_DATA_SHARE_WORKER (optional) use DSM data share worker for SERVICE_WIZARD_SHARE and DSM 6 too
# SERVICE_WIZARD_SHARE (optional) use name of wizard-varible to define folder name of SHARE_PATH (uses DSM data share worker for DSM 7)
# USE_DATA_SHARE_WORKER (optional) use DSM data share worker for SERVICE_WIZARD_SHARE for DSM 6 too
# SERVICE_USER (optional) runtime user account for generic service support.
# "auto" is the only value supported with DSM 7 and defines sc-${SPK_NAME} as service user.
# SPK_GROUP (optional) defines the group to use in privilege resource file
Expand Down Expand Up @@ -123,15 +123,11 @@ $(DSM_SCRIPTS_DIR)/service-setup:
@echo 'fi' >> $@
@echo '' >> $@
ifneq ($(strip $(SERVICE_USER)),)
ifeq ($(call version_ge, ${TCVERSION}, 7.0),1)
@echo USER=\"sc-$(SPK_USER)\" >> $@
@echo USER=\"$(SPK_USER)\" >> $@
ifeq ($(call version_ge, ${TCVERSION}, 6.0),1)
@echo EFF_USER=\"sc-$(SPK_USER)\" >> $@
else
@echo "# Base service USER to run background process prefixed according to DSM" >> $@
@echo USER=\"$(SPK_USER)\" >> $@
@echo "PRIV_PREFIX=sc-" >> $@
@echo "SYNOUSER_PREFIX=svc-" >> $@
@echo 'if [ -n "$${SYNOPKG_DSM_VERSION_MAJOR}" ] && [ "$${SYNOPKG_DSM_VERSION_MAJOR}" -lt 6 ]; then EFF_USER="$${SYNOUSER_PREFIX}$${USER}"; else EFF_USER="$${PRIV_PREFIX}$${USER}"; fi' >> $@
@echo EFF_USER=\"svc-$(SPK_USER)\" >> $@
endif
@echo '' >> $@
endif
Expand All @@ -142,7 +138,19 @@ ifneq ($(strip $(SERVICE_WIZARD_GROUP)),)
endif
ifneq ($(strip $(SERVICE_WIZARD_SHARE)),)
@echo "# DSM shared folder location from UI if provided" >> $@
@echo 'if [ -n "$${$(SERVICE_WIZARD_SHARE)}" ]; then SHARE_PATH="$${$(SERVICE_WIZARD_SHARE)}"; fi' >> $@
@echo 'if [ -n "$${$(SERVICE_WIZARD_SHARE)}" ]; then' >> $@
ifeq ($(call version_ge, ${TCVERSION}, 7.0),1)
@echo ' SHARE_PATH=$$(realpath "/var/packages/$${SYNOPKG_PKGNAME}/shares/$${$(SERVICE_WIZARD_SHARE)}")' >> $@
else
@echo ' if synoshare --get "$${$(SERVICE_WIZARD_SHARE)}" &> /dev/null; then ' >> $@
@echo ' SHARE_PATH=$$(synoshare --get "$${$(SERVICE_WIZARD_SHARE)}" | awk 'NR==4' | cut -d] -f1 | cut -d[ -f2)' >> $@
@echo ' echo "SHARE_PATH from share [$${SHARE_PATH}]"' >> $@
@echo ' else' >> $@
@echo ' SHARE_PATH="$${$(SERVICE_WIZARD_SHARE)}"' >> $@
@echo ' echo "SHARE_PATH [$${SHARE_PATH}] is not an existing shared folder"' >> $@
@echo ' fi' >> $@
endif
@echo 'fi' >> $@
@echo '' >> $@
endif
ifneq ($(strip $(SERVICE_PORT)),)
Expand Down

0 comments on commit 047dc32

Please sign in to comment.