Skip to content

Commit

Permalink
Update setup.sh (#124)
Browse files Browse the repository at this point in the history
Signed-off-by: David P. Chassin <dchassin@slac.stanford.edu>
Signed-off-by: David P. Chassin <david.chassin@me.com>
  • Loading branch information
David P. Chassin authored and dchassin committed Oct 12, 2023
1 parent 31b2de7 commit e2264bd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
##
STDOUT=/dev/stdout
STDERR=/dev/stderr
DEFAULT_ORIGIN="https://github.com/arras-energy/gridlabd/master"
error () { echo "ERROR [setup.sh]: $*" > $STDERR ; exit 1; }
if [ -d $(dirname $0)/.git ]; then
DEFAULT_ORIGIN=$(git remote get-url origin | sed -e 's|https://github.com/||' | sed -e 's|.git$||')/$(git rev-parse --abbrev-ref HEAD)
export GRIDLABD_ORIGIN="."
else
DEFAULT_ORIGIN=arras-energy/gridlabd/master
export GRIDLABD_ORIGIN="$DEFAULT_ORIGIN"
fi
while [ $# -gt 0 ]; do
case "$1" in
Expand All @@ -49,6 +50,9 @@ while [ $# -gt 0 ]; do
--local)
export GRIDLABD_ORIGIN="."
;;
--remote)
export GRIDLABD_ORIGIN="$DEFAULT_ORIGIN"
;;
*)
export GRIDLABD_ORIGIN="$1"
;;
Expand All @@ -57,12 +61,9 @@ while [ $# -gt 0 ]; do
done
export SYSTEMNAME=$(uname -s)
if [ "$GRIDLABD_ORIGIN" = "." ]; then
sh setup/$SYSTEMNAME.sh 1>$STDOUT 2>$STDERR || error "setup failed"
sh $(dirname $0)/setup/$SYSTEMNAME.sh 1>$STDOUT 2>$STDERR || error "setup failed"
else
curl --version 1>/dev/null 2>&1 || error "you must install curl first"
if [ -z "$GRIDLABD_ORIGIN" ] ; then
export GRIDLABD_ORIGIN=$DEFAULT_ORIGIN
fi
test "$(echo $GRIDLABD_ORIGIN | cut -c-8)" != "https://" && GRIDLABD_ORIGIN=https://raw.githubusercontent.com/$GRIDLABD_ORIGIN
echo GRIDLABD_ORIGIN=$GRIDLABD_ORIGIN
if curl -H 'Cache-Control: no-cache' -fsL $GRIDLABD_ORIGIN/setup/$SYSTEMNAME.sh > /tmp/setup_$$.sh ; then
Expand All @@ -71,4 +72,4 @@ else
else
error "unable to find $GRIDLABD_ORIGIN/setup/$SYSTEMNAME.sh. Manual setup required."
fi
fi
fi

0 comments on commit e2264bd

Please sign in to comment.