This is an automated email from the ASF dual-hosted git repository. fgerlits pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit f70a44ab80425002c501ee169b1a6fe2369d2be3 Author: Marton Szasz <[email protected]> AuthorDate: Mon Jun 17 15:30:46 2024 +0200 MINIFICPP-2407 minifi.sh: exit on error Also: report error when trying to install as non-root Signed-off-by: Ferenc Gerlits <[email protected]> This closes #1819 --- bin/minifi.sh | 19 ++++++++++--------- generateVersion.sh | 4 +++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/bin/minifi.sh b/bin/minifi.sh index b3f15ab68..b68e18523 100755 --- a/bin/minifi.sh +++ b/bin/minifi.sh @@ -17,6 +17,8 @@ # Script structure inspired from Apache Karaf and other Apache projects with similar startup approaches +set -e + PROGNAME=$(basename "$0") SCRIPTPATH="$( cd "$(dirname "$0")" || exit 1; pwd -P )" MINIFI_HOME="$(dirname "${SCRIPTPATH}")" @@ -36,24 +38,15 @@ die() { detectOS() { # OS specific support (must be 'true' or 'false'). cygwin=false; - aix=false; darwin=false; case "$(uname)" in CYGWIN*) cygwin=true ;; - AIX*) - aix=true - ;; Darwin) darwin=true ;; esac - # For AIX, set an environment variable - if ${aix}; then - export LDR_CNTRL=MAXDATA=0xB0000000@DSA - echo ${LDR_CNTRL} - fi if [ "${cygwin}" = "true" ]; then echo 'Apache MiNiFi as a service is not supported on Cygwin.' @@ -113,6 +106,10 @@ check_service_installed_linux() { } install() { + if [ "$(id -u)" -ne 0 ]; then + die "This script must be run as root to install or uninstall the MiNiFi service. Try 'sudo $0 $*'." + fi + echo "Uninstalling any previous versions" uninstall @@ -125,6 +122,10 @@ install() { } uninstall() { + if [ "$(id -u)" -ne 0 ]; then + die "This script must be run as root to install or uninstall the MiNiFi service. Try 'sudo $0 $*'." + fi + detectOS if [ "${darwin}" = "true" ]; then uninstall_macos diff --git a/generateVersion.sh b/generateVersion.sh index 194d3d09c..ff25afba8 100755 --- a/generateVersion.sh +++ b/generateVersion.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +set -e + version=$1 src_dir=$2 out_dir=$3
