Skip to content

Commit

Permalink
ympd: fix for DSM 5
Browse files Browse the repository at this point in the history
- needs a single executable for service command
  • Loading branch information
hgy59 committed Nov 14, 2023
1 parent 2628b05 commit 9ac1a89
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
11 changes: 9 additions & 2 deletions spk/ympd/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
SPK_NAME = ympd
SPK_VERS = 1.3.0
SPK_REV = 1
SPK_REV = 2
SPK_ICON = src/ympd.png
DSM_UI_DIR = app

DEPENDS = cross/ympd

MAINTAINER = hgy59
DESCRIPTION = ympd: Standalone MPD Web GUI written in C, utilizing Websockets and Bootstrap/JS.
CHANGELOG = "Initial package release."
CHANGELOG = "Fix service start for DSM 5 / SRM."

DISPLAY_NAME = MPD Web GUI

Expand All @@ -22,4 +22,11 @@ SERVICE_USER = auto
SERVICE_SETUP = src/service-setup.sh
ADMIN_PORT = $(SERVICE_PORT)

POST_STRIP_TARGET = ympd_extra_install

include ../../mk/spksrc.spk.mk

.PHONY: ympd_extra_install
ympd_extra_install:
@$(MSG) Install service script
@install -m 755 src/start.sh $(STAGING_DIR)/bin/
9 changes: 6 additions & 3 deletions spk/ympd/src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

SERVICE_COMMAND="${SYNOPKG_PKGDEST}/bin/ympd -w ${SERVICE_PORT}"
SVC_BACKGROUND=y
SVC_WRITE_PID=y
# pass variables by env
export PID_FILE=${PID_FILE}
export SERVICE_PORT=${SERVICE_PORT}
export SYNOPKG_PKGDEST=${SYNOPKG_PKGDEST}

SERVICE_COMMAND="${SYNOPKG_PKGDEST}/bin/start.sh"
19 changes: 19 additions & 0 deletions spk/ympd/src/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

# we need a single file to start the service and create the pid-file
# the combination of
# - SVC_BACKGROUND=y
# - SVC_WRITE_PID=y
# does not work in DSM 5 when SERVICE_COMMAND is a command with parameters.
# On DSM 5 /bin/sh is ash and not bash and '/bin/sh -c "command parameter" &' will create a new process for "command parameter"
# finally we have two processes in the background, but are not able to retrieve the PID of "command parameter"
#

if [ -z "${SYNOPKG_PKGDEST}" -o -z "${PID_FILE}" -o -z "${SERVICE_PORT}" ]; then
echo "ERROR: SYNOPKG_PKGDEST, PID_FILE or SERVICE_PORT is not defined. This script must be run in the context of DSM service command."
exit 1
fi

${SYNOPKG_PKGDEST}/bin/ympd -w ${SERVICE_PORT}
echo "$!" > ${PID_FILE}

0 comments on commit 9ac1a89

Please sign in to comment.