Skip to content

Commit

Permalink
Patch needed for elevated privs
Browse files Browse the repository at this point in the history
  • Loading branch information
mreid-tt committed Dec 15, 2022
1 parent f07161b commit e13d4d6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions spk/sonarr/src/service-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,23 @@ validate_prereplace ()
fi
}

# Commands in 'service_prereplace' require calls to these executables with elevated privelages
### /usr/bin/sed
### /usr/syno/bin/servicetool
### /usr/syno/bin/synopkg
### /usr/syno/sbin/synopkghelper

service_prereplace ()
{
# check if target service port is in use
if [ "$(servicetool --conf-port-conflict-check --tcp "${SYNOPKG_PKGPORT}" | awk '{print $2; exit}')" = "true" ]; then
if [ "$(servicetool --conf-port-conflict-check --tcp "${SYNOPKG_PKGPORT}" | awk '{print $8; exit}')" = "nzbdrone" ]; then
# change nzbdrone port assignment
synopkg stop nzbdrone 2>&1
sed -i "s/^adminport=\"[0-9]\+\"$/adminport=\"${SERVICE_PORT_LEGACY}\"/g" "${LEGACY_SYNOPKG_PKGROOT}/INFO"
servicetool --remove-configure-file --package nzbdrone.sc 2>&1
sed -i "s/^dst\.ports=\"[0-9]\+\/tcp\"$/dst\.ports=\"${SERVICE_PORT_LEGACY}\/tcp\"/g" "${LEGACY_SYNOPKG_PKGDEST}/app/nzbdrone.sc"
synopkghelper update nzbdrone port-config 2>&1
synopkg stop nzbdrone >/dev/null 2>&1
sed -i "s/^adminport=\"[0-9]\+\"$/adminport=\"${SERVICE_PORT_LEGACY}\"/g" "${LEGACY_SYNOPKG_PKGROOT}/INFO" >/dev/null 2>&1
servicetool --remove-configure-file --package nzbdrone.sc >/dev/null 2>&1
sed -i "s/^dst\.ports=\"[0-9]\+\/tcp\"$/dst\.ports=\"${SERVICE_PORT_LEGACY}\/tcp\"/g" "${LEGACY_SYNOPKG_PKGDEST}/app/nzbdrone.sc" >/dev/null 2>&1
synopkghelper update nzbdrone port-config >/dev/null 2>&1
else
# port not used by nzbdrone
echo "Unable to release port ${SYNOPKG_PKGPORT} as it is in use by $(servicetool --conf-port-conflict-check --tcp "${SYNOPKG_PKGPORT}" | awk '{print $8; exit}')."
Expand Down

0 comments on commit e13d4d6

Please sign in to comment.