Skip to content

Commit

Permalink
MINIFICPP-2407 minifi.sh: exit on error
Browse files Browse the repository at this point in the history
Also: report error when trying to install as non-root

Signed-off-by: Ferenc Gerlits <[email protected]>
This closes #1819
  • Loading branch information
szaszm authored and fgerlits committed Jul 11, 2024
1 parent 6e4bd96 commit f70a44a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
19 changes: 10 additions & 9 deletions bin/minifi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}")"
Expand All @@ -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.'
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion generateVersion.sh
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down

0 comments on commit f70a44a

Please sign in to comment.