-
Notifications
You must be signed in to change notification settings - Fork 4
/
runUnprivileged.sh
executable file
·29 lines (29 loc) · 1.17 KB
/
runUnprivileged.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
if [ -n "${OS_CONTAINER}" ]
then
# We are running under Docker
if [ -z ${UNPRIVILEGED_USER+x} ]
then
echo "You must set the UNPRIVILEGED_USER variable."
exit 1
fi
CMD_PREFIX="sudo -u ${UNPRIVILEGED_USER} --set-home"
# Construct a variable name listing RedHat Software Collections that must be
# enabled. This is something like SOFTWARE_COLLECTIONS_centos_7, where the
# : separator from Docker and any . have been replaced with _
SOFTWARE_COLLECTIONS_NAME="SOFTWARE_COLLECTIONS_${OS_CONTAINER}"
# Get the list of software collections for this image
SOFTWARE_COLLECTIONS="${!SOFTWARE_COLLECTIONS_NAME}"
# If there are any, inject an `scl enable` layer into the commandline
if [ -n "${SOFTWARE_COLLECTIONS}" ]
then
CMD_PREFIX="${CMD_PREFIX} scl enable ${SOFTWARE_COLLECTIONS} --"
fi
fi
echo "Wrapper script generated command prefix: ${CMD_PREFIX}"
QUOTED_ARGS=$(printf " %q" "$@")
${CMD_PREFIX} sh -c "INSTALL_DIR=${INSTALL_DIR}\
NEURON_BRANCH_OR_TAG=${NEURON_BRANCH_OR_TAG} NRN_PYTHON=${NRN_PYTHON} \
OS_FLAVOUR=${OS_FLAVOUR} OS_CONTAINER=${OS_CONTAINER} \
NRN_PACKAGE=${NRN_PACKAGE} bash --noprofile --norc -e -o pipefail \
--${QUOTED_ARGS}"