add system default ini and allow ~ in workdir

This commit is contained in:
Trevor Batley
2023-05-10 10:17:35 +10:00
parent 3d62c04c19
commit 2edef6eb76
4 changed files with 67 additions and 38 deletions

View File

@@ -4,12 +4,16 @@
# monitor results and log
#
inifilename=$(echo ~)"/.smegit/config"
if [ -z $inifilename ] ; then
# Not here, look a bit further up
echo "No ini file found $inifiename"
echo "get-repo-and-build.sh <organisation> <reponame> [<local>]"
exit 1
fi
if [ ! -e $inifilename ] ; then
# Not here, look at system default
if [ ! -e /etc/smegit.ini ] ; then
echo "No ini file found $inifiename or /etc/smegit.ini"
echo "get-repo-and-build.sh <organisation> <reponame> [<local>]"
exit 1
else
initfilename="/etc/smegit.ini"
fi
fi
while read -r line || [[ -n "$line" ]]; do
if [[ $line =~ ^\[.*\]$ ]]
then
@@ -47,7 +51,14 @@ if [ $3 ] ; then
fi
ORG_NAME="$1"
REPO_NAME="$2"
WORKDIR=$(echo ~)${smegit_WORKDIR}
if [[ $smegit_WORKDIR == ~* ]] ; then
# relative to users home dir
WORKDIR=$(echo ~)${smegit_WORKDIR:1}
else
# absolute path
WORKDIR=${smegit_WORKDIR}
fi
if [ $DEBUG ] ; then echo "WORKDIR=$WORKDIR" ; fi
GITFiles=$WORKDIR/GITFiles/$ORG_NAME
REPOURL="$GITEAHOST/$ORG_NAME/$REPO_NAME.git"