Skip to content
Snippets Groups Projects
Commit 14d0bd5b authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

detect ms win; load env file

parent 5d677afa
No related branches found
No related tags found
1 merge request!95ignore required user on MS windows
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment