Skip to content

Instantly share code, notes, and snippets.

@ejlevin1
Last active August 26, 2021 00:59
Show Gist options
  • Save ejlevin1/861b9bb9742a1c58406314229faab5b3 to your computer and use it in GitHub Desktop.
Save ejlevin1/861b9bb9742a1c58406314229faab5b3 to your computer and use it in GitHub Desktop.
rsi script runners
# Example command for running within osx:
curl -s -L https://bit.ly/rs-rsi-osx | bash
#!/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