From 4d78052dd4f19372161391e93cde688f2fa8b864 Mon Sep 17 00:00:00 2001 From: Andre F de Miranda Date: Sun, 14 May 2017 22:14:33 +1000 Subject: [PATCH] NIFI-1709 - Introduce logic to probe Linux version using /etc/os-release to nifi.sh Add explicit paths to support SLES 11 SP4 / OpenSUSE init.d layout This closes #1794 --- .../src/main/resources/bin/nifi.sh | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh index dd6e5688b4..35fdfa1849 100755 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh @@ -81,6 +81,12 @@ detectOS() { export LDR_CNTRL=MAXDATA=0xB0000000@DSA echo ${LDR_CNTRL} fi + # In addition to those, go around the linux space and query the widely + # adopted /etc/os-release to detect linux variants + if [ -f /etc/os-release ] + then + source /etc/os-release + fi } unlimitFD() { @@ -174,6 +180,8 @@ install() { SVC_NAME=$2 fi + # since systemd seems to honour /etc/init.d we don't still create native systemd services + # yet... initd_dir='/etc/init.d' SVC_FILE="${initd_dir}/${SVC_NAME}" @@ -222,11 +230,22 @@ SERVICEDESCRIPTOR # Provide the user execute access on the file chmod u+x ${SVC_FILE} - rm -f "/etc/rc2.d/S65${SVC_NAME}" - ln -s "/etc/init.d/${SVC_NAME}" "/etc/rc2.d/S65${SVC_NAME}" || { echo "Could not create link /etc/rc2.d/S65${SVC_NAME}"; exit 1; } - rm -f "/etc/rc2.d/K65${SVC_NAME}" - ln -s "/etc/init.d/${SVC_NAME}" "/etc/rc2.d/K65${SVC_NAME}" || { echo "Could not create link /etc/rc2.d/K65${SVC_NAME}"; exit 1; } - echo "Service ${SVC_NAME} installed" + + # If SLES or OpenSuse... + if [ "${ID}" = "opensuse" ] || [ "${ID}" = "sles" ]; then + rm -f "/etc/rc.d/rc2.d/S65${SVC_NAME}" + ln -s "/etc/init.d/${SVC_NAME}" "/etc/rc.d/rc2.d/S65${SVC_NAME}" || { echo "Could not create link /etc/rc.d/rc2.d/S65${SVC_NAME}"; exit 1; } + rm -f "/etc/rc.d/rc2.d/K65${SVC_NAME}" + ln -s "/etc/init.d/${SVC_NAME}" "/etc/rc.d/rc2.d/K65${SVC_NAME}" || { echo "Could not create link /etc/rc.d/rc2.d/K65${SVC_NAME}"; exit 1; } + echo "Service ${SVC_NAME} installed" + # Anything other fallback to the old approach + else + rm -f "/etc/rc2.d/S65${SVC_NAME}" + ln -s "/etc/init.d/${SVC_NAME}" "/etc/rc2.d/S65${SVC_NAME}" || { echo "Could not create link /etc/rc2.d/S65${SVC_NAME}"; exit 1; } + rm -f "/etc/rc2.d/K65${SVC_NAME}" + ln -s "/etc/init.d/${SVC_NAME}" "/etc/rc2.d/K65${SVC_NAME}" || { echo "Could not create link /etc/rc2.d/K65${SVC_NAME}"; exit 1; } + echo "Service ${SVC_NAME} installed" + fi } run() {