v1.1.15 - added run-from-url function
This commit is contained in:
parent
001d010d53
commit
c3d89e2921
1 changed files with 20 additions and 0 deletions
20
functions
20
functions
|
|
@ -538,6 +538,26 @@ clone-repo(){
|
|||
run git clone --recurse-submodules $_url $_destination
|
||||
}
|
||||
|
||||
run-from-url(){
|
||||
url=$1
|
||||
args=${*:2}
|
||||
# check the interpreter using the shebang at the top of the file
|
||||
interpreter=$(curl -ks $url | head -n 1 | sed -e 's/\#\!//g' 2>/dev/null)
|
||||
# In case of missing shebang, default to bash
|
||||
if [ -z $interpreter ] ; then
|
||||
interpreter="/bin/bash"
|
||||
fi
|
||||
logger boxline "Running online script $url with args $args"
|
||||
if [[ "$interpreter" == "/bin/bash "]] ; then
|
||||
run curl -H 'Cache-Control: no-cache' -ks $url | $interpreter -s -- $args
|
||||
else
|
||||
run curl -H 'Cache-Control: no-cache' -ks $url > ${url##*/}
|
||||
run $interpreter ${url##*/} $args
|
||||
ec=$?
|
||||
run rm ${url##*/}
|
||||
return $ec
|
||||
}
|
||||
|
||||
ctrl_c(){
|
||||
echo -e "\n"
|
||||
fail "User interrupted with Ctrl-C"
|
||||
|
|
|
|||
Loading…
Reference in a new issue