Last active
August 26, 2021 00:59
-
-
Save ejlevin1/861b9bb9742a1c58406314229faab5b3 to your computer and use it in GitHub Desktop.
rsi script runners
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example command for running within osx: | |
curl -s -L https://bit.ly/rs-rsi-osx | bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
USER_HOME=$(cd ~/ && pwd) | |
RS_DIR_PATH="$USER_HOME/.rs" | |
BIN_DIR_PATH="$RS_DIR_PATH/bin" | |
RSI_HEADERS_PATH="$RS_DIR_PATH/rsi.headers" | |
RSI_URL="https://rs-cli.s3.amazonaws.com/rsi-osx-x64" | |
RSI_BIN_PATH="$RS_DIR_PATH/bin/rsi" | |
mkdir -p $BIN_DIR_PATH | |
ETAG='' | |
if [ -f "$RSI_HEADERS_PATH" ] ; then | |
if [ -f "$RSI_BIN_PATH" ] ; then | |
ETAG=$(cat $RSI_HEADERS_PATH | grep ETag | awk -F\" '{ print $2 }') | |
ETAG="--header 'If-None-Match: \"$ETAG\"'" | |
# echo "Using etag [$ETAG] to check against binary." | |
else | |
echo "rsi binary not found at [$RSI_BIN_PATH] ... re-downloading headers." | |
fi | |
fi | |
CMD="curl -s -I $ETAG $RSI_URL > $RSI_HEADERS_PATH" | |
# echo "Command [$CMD]" | |
eval $CMD > $RSI_HEADERS_PATH | |
HTTP_STATUS=$(cat $RSI_HEADERS_PATH | grep HTTP | awk '{ print $2 }') | |
# echo "Http Status: $HTTP_STATUS" | |
if [ "$HTTP_STATUS" = "200" ] ; then | |
echo "Downloading rsi binary from [$RSI_URL]" | |
CMD="curl $RSI_URL -o $RSI_BIN_PATH" | |
eval $CMD | |
chmod +x $RSI_BIN_PATH | |
fi | |
# Append additional params if present | |
CMD="$RSI_BIN_PATH" | |
if [ ! -z "$@" ] ; then | |
CMD="$CMD $@" | |
fi | |
echo "Running [$CMD]" | |
eval $CMD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment