aboutsummaryrefslogtreecommitdiff
path: root/etc/private
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-09-08 20:16:36 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-09-09 15:59:29 +0300
commiteb4f581b6a544a6535f771bcb7017bceca2530fc (patch)
tree560e6caec6c5677180013067998e59c77d3642be /etc/private
parent4e95c4bc157974f65f65b3c8e5103c6f8622610a (diff)
Fail if unable to obtain host name/address in etc/private/install/brep-startup
Diffstat (limited to 'etc/private')
-rwxr-xr-xetc/private/install/brep-startup10
1 files changed, 9 insertions, 1 deletions
diff --git a/etc/private/install/brep-startup b/etc/private/install/brep-startup
index 80cb255..7a5f262 100755
--- a/etc/private/install/brep-startup
+++ b/etc/private/install/brep-startup
@@ -16,6 +16,10 @@
# - Generate the loadtab using the current host name/IP and run the loader.
#
trap "{ exit 1; }" ERR
+set -o errtrace # Trap in functions.
+
+function info () { echo "$*" 1>&2; }
+function error () { info "error: $*"; exit 1; }
# Create the pkg repository, if required.
#
@@ -51,12 +55,16 @@ if [ "$h" == "localhost" ]; then
h="$(hostname -I | sed 's/ *$//')" # Strip the potential trailing space(s).
fi
+if [ -z "$h" ]; then
+ error "unable to obtain host name or IP address"
+fi
+
# Adjust the submission result URL host name in the brep module configuration
# file.
#
sed --in-place -re \
"\$!N;s%^\s*(submit-handler-argument\s+--result-url\s*\\n)\
-\s*(submit-handler-argument\s+https?://)[^/]+(.*)\$%\1\2$h\3%;P;D" \
+\s*(submit-handler-argument\s+https?://)[^/]*(.*)\$%\1\2$h\3%;P;D" \
"$HOME/config/brep-module.conf"
# (Re-)generate the loadtab file and reload the repository.