diff --git a/jobhelper.sh b/jobhelper.sh index 9d73c9461a86a1e7f1f4df6297a3948585683160..86d39ad0c8d930c549af772327d95984359372c3 100755 --- a/jobhelper.sh +++ b/jobhelper.sh @@ -42,6 +42,11 @@ STORAGEFILE="${DIR_JOBS}/transfer.job" function j_init(){ j_banner + if [ -r "${DIR_JOBS}/env" ]; + then + echo "INFO: loading custom environment ${DIR_JOBS}/env" + . "${DIR_JOBS}/env" + fi if [ ! -d "${DIR_LOGS}" ]; then mkdir -p "${DIR_LOGS}" && echo "INFO: dir created ${DIR_LOGS}" @@ -374,20 +379,27 @@ function j_requireProcess(){ fi } +# detect ms windows by cygwin, mingw, msys ... +# see https://en.wikipedia.org/wiki/Uname +# return code is 0 for YES +function _isMswindows(){ + uname | grep -iE "(CYGWIN_NT|MINGW|MSYS_NT|Windows_NT|WindowsNT)" >/dev/null +} + # ------------------------------------------------------------ # check if it was startet with a given user # This is skipped if MS windows was detected with "mingw". # param string username, i.e. root # ------------------------------------------------------------ function j_requireUser(){ - # TODO: this is an incomplete check. Check more strings eg. cygwin - if uname | grep -iE "mingw" >/dev/null; then - return 0 - fi - sUser=$(id | cut -f 2 -d "(" | cut -f 1 -d ")") - if [[ "$sUser" != "$1" ]]; then - >&2 echo "ERROR: user $1 is reqired." - exit 5 + if _isMswindows; then + echo "SKIP: j_requireUser $1 is not handled on MS Windows." + else + sUser=$(id | cut -f 2 -d "(" | cut -f 1 -d ")") + if [[ "$sUser" != "$1" ]]; then + >&2 echo "ERROR: user $1 is reqired." + exit 5 + fi fi }