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

goto-build: deny root access; shell fixes

parent ed372974
No related branches found
No related tags found
1 merge request!64Update readme + docs
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
# #
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2024-01-19 v1.0 <axel.hahn@iml.unibe.ch> first lines # 2024-01-19 v1.0 <axel.hahn@iml.unibe.ch> first lines
# 2024-07-25 v1.1 <axel.hahn@iml.unibe.ch> deny root access; shell fixes
# ====================================================================== # ======================================================================
cd $( dirname $0 )/.. cd "$( dirname "$0" )/.." || exit 1
CI_APPROOT=$( pwd ) CI_APPROOT=$( pwd )
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -24,6 +25,14 @@ cat <<HEADEREND ...@@ -24,6 +25,14 @@ cat <<HEADEREND
HEADEREND HEADEREND
# ----------------------------------------------------------------------
# deny start as root
# ----------------------------------------------------------------------
if [ "$( id -u )" -eq 0 ]; then
echo "ERROR: do not start this script as root."
exit 1
fi
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# detect workdir # detect workdir
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -42,9 +51,9 @@ builddir="$CI_WORKDIR/build/" ...@@ -42,9 +51,9 @@ builddir="$CI_WORKDIR/build/"
# detect builds on error # detect builds on error
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
ls $builddir >/dev/null || exit 1 ls "$builddir" >/dev/null || exit 1
echo "Searching for builds im $builddir..." echo "Searching for builds im $builddir..."
founddirs=$( find $builddir -maxdepth 2 -type d | grep '2[0-1][0-9][0-9][0-1][0-9][0-3][0-9]' | sort ) founddirs=$( find "$builddir" -maxdepth 2 -type d | grep '2[0-1][0-9][0-9][0-1][0-9][0-3][0-9]' | sort )
if [ -z "$founddirs" ]; then if [ -z "$founddirs" ]; then
echo "Good news: No build dirs (builds on error) were found. Aborting." echo "Good news: No build dirs (builds on error) were found. Aborting."
...@@ -69,7 +78,6 @@ echo -n "I want to jump to > " ...@@ -69,7 +78,6 @@ echo -n "I want to jump to > "
read -r DIR_APPROOT read -r DIR_APPROOT
test -z "$DIR_APPROOT" && exit 1 test -z "$DIR_APPROOT" && exit 1
# DIR_APPROOT="/var/imldeployment/build/$DIR_APPROOT"
ls "$DIR_APPROOT" >/dev/null || exit 2 ls "$DIR_APPROOT" >/dev/null || exit 2
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -82,7 +90,7 @@ export DIR_SSH_KEYS="$CI_WORKDIR/data/sshkeys" ...@@ -82,7 +90,7 @@ export DIR_SSH_KEYS="$CI_WORKDIR/data/sshkeys"
export NVMINIT="$CI_APPROOT/shellscripts/nvm_init.sh"; export NVMINIT="$CI_APPROOT/shellscripts/nvm_init.sh";
export RVMSCRIPT="/usr/local/rvm/scripts/rvm"; export RVMSCRIPT="/usr/local/rvm/scripts/rvm";
cd "$DIR_APPROOT" cd "$DIR_APPROOT" || exit 1
cat <<EOF cat <<EOF
* Switching now into build dir * Switching now into build dir
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment