From f104d414b28b8b6584d841fe11c262f5c31ea3a4 Mon Sep 17 00:00:00 2001 From: kwindrem <58538395+kwindrem@users.noreply.github.com> Date: Fri, 6 Aug 2021 16:48:13 -0700 Subject: [PATCH] switch to new services location as of v2.80~10, services were relocated to /opt/victronenergy/services --- .DS_Store | Bin 6148 -> 6148 bytes ServiceResources | 46 +++++++++++++++++++++++++++++----------------- timeStamp | 2 +- version | 2 +- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/.DS_Store b/.DS_Store index be5869bc2f6657d7893b5a606adbd7439481573a..0d964166fcee4b02bfb1511928df8caf05752513 100644 GIT binary patch delta 75 zcmZoMXfc?u%pr-Bfq{XAL60GwA(NpbH{Zo2DJMS(D8>QA+Zf^xJEF>`pviB1CMOO6 Dl3)>L delta 75 zcmZoMXfc?u%poq0fq{XAL60GwA(NpbH{Zo2DJMS(D8>QAVxe(|9Z}^|(BwBhlM@F3 DnL!aB diff --git a/ServiceResources b/ServiceResources index 007cb96..c0ba903 100755 --- a/ServiceResources +++ b/ServiceResources @@ -18,6 +18,18 @@ # The intent is to force supervise to run the new version # must be called from other functions that have already made the necessary checks +# starting with v2.80~10, services are stored in this directory which is overlayed onto /service +# all services need to be added there rather than /service +# Note: service calls (eg svc) are still made on /service/... + +victronServicesDir="/opt/victronenergy/service" +if [ -d "$victronServicesDir" ]; then + serviceDir="$victronServicesDir" +else + serviceDir="/service" +fi +echo "#### serviceDir $serviceDir" + _killServiceProcesses () { local pkg=$1 @@ -31,10 +43,10 @@ _killServiceProcesses () _startService () { local pkg=$1 - rm -f "/service/$pkg/down" + rm -f "$serviceDir/$pkg/down" svc -u "/service/$pkg" - if [ -e "/service/$pkg/log" ]; then - rm -f "/service/$pkg/log/down" + if [ -e "$serviceDir/$pkg/log" ]; then + rm -f "$serviceDir/$pkg/log/down" svc -u "/service/$pkg/log" fi } @@ -47,7 +59,7 @@ startService () fi local pkg=$1 - if [ -e "/service/$pkg" ]; then + if [ -e "$serviceDir/$pkg" ]; then logMessage "starting $pkg service" _startService $pkg fi @@ -57,10 +69,10 @@ startService () _stopService () { local pkg=$1 - touch "/service/$pkg/down" + touch "$serviceDir/$pkg/down" svc -d "/service/$pkg" - if [ -e "/service/$pkg/log" ]; then - touch "/service/$pkg/log/down" + if [ -e "$serviceDir/$pkg/log" ]; then + touch "$serviceDir/$pkg/log/down" svc -d "/service/$pkg/log" fi _killServiceProcesses $pkg @@ -74,7 +86,7 @@ stopService () fi local pkg=$1 - if [ -e "/service/$pkg" ]; then + if [ -e "$serviceDir/$pkg" ]; then logMessage "stopping $pkg service" _stopService $pkg fi @@ -91,7 +103,7 @@ _removeService () svc -d "/service/$pkg" # remove the active service directory - rm -rf "/service/$pkg" + rm -rf "$serviceDir/$pkg" # kill related processes _killServiceProcesses $pkg @@ -105,7 +117,7 @@ removeService () fi local pkg=$1 - if [ -e "/service/$pkg" ]; then + if [ -e "$serviceDir/$pkg" ]; then logMessage "removing $pkg service" _removeService $pkg fi @@ -136,27 +148,27 @@ installService () local pkg=$1 local serviceRestartNeeded=false - if [ -L "/service/$pkg" ]; then + if [ -L "$serviceDir/$pkg" ]; then logMessage "$pkg removing old service (was symbolic link)" _removeService $pkg fi # service not yet installed, COPY service directory to the active locaiton - if [ ! -e "/service/$pkg" ]; then + if [ ! -e "$serviceDir/$pkg" ]; then logMessage "$pkg installing service" - cp -R "$scriptDir/service" "/service/$pkg" + cp -R "$scriptDir/service" "$serviceDir/$pkg" # service already installed - only copy changed files, then restart service else logMessage "restarting $pkg service" if [ -f "$scriptDir/service/run" ]; then - cmp -s "$scriptDir/service/run" "/service/$pkg/run" > /dev/null + cmp -s "$scriptDir/service/run" "$serviceDir/$pkg/run" > /dev/null if [ $? != 0 ]; then - cp "$scriptDir/service/run" "/service/$pkg/run" + cp "$scriptDir/service/run" "$serviceDir/$pkg/run" fi fi if [ -f "$scriptDir/service/log/run" ]; then - cmp -s "$scriptDir/service/log/run" "/service/$pkg/log/run" > /dev/null + cmp -s "$scriptDir/service/log/run" "$serviceDir/$pkg/log/run" > /dev/null if [ $? != 0 ]; then - cp "$scriptDir/service/log/run" "/service/$pkg/log/run" + cp "$scriptDir/service/log/run" "$serviceDir/$pkg/log/run" fi fi _killServiceProcesses $pkg diff --git a/timeStamp b/timeStamp index e04e3e2..94a195a 100644 --- a/timeStamp +++ b/timeStamp @@ -1 +1 @@ -1628205710 +1628293383 diff --git a/version b/version index 28c2139..eb41430 100644 --- a/version +++ b/version @@ -1 +1 @@ -v2.1 +v2.2