From 5dade63241f771cdb2c2e1b201c62ad0b2748626 Mon Sep 17 00:00:00 2001 From: faisal Date: Fri, 15 Jul 2022 16:48:35 -0500 Subject: [PATCH] added ubstakker --- README.md | 3 +++ build.sh | 13 +++++------- install.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 8 deletions(-) create mode 100755 install.sh diff --git a/README.md b/README.md index 058f109..c1c3442 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ A simple http request checker to monitor if it's up or down. Scheduling is done through cron jobs. ```bash +# Install on unix/linux environment with +curl -s -S -L https://raw.githubusercontent.com/altlimit/statusalert/master/install.sh | bash + # Run against a valid *.http using VSCode REST Client statusalert --http-file test.http ``` diff --git a/build.sh b/build.sh index d6171e4..d6fdc11 100755 --- a/build.sh +++ b/build.sh @@ -4,18 +4,15 @@ echo "Building..." rm -rf ./build GOOS=windows GOARCH=amd64 go build -o build/win/statusalert.exe GOOS=linux GOARCH=amd64 go build -o build/linux/statusalert -GOOS=darwin GOARCH=amd64 go build -o build/osx/statusalert -cp -R site build/win/ -cp -R site build/linux/ -cp -R site build/osx/ +GOOS=darwin GOARCH=amd64 go build -o build/darwin/statusalert cd build/win zip -rq ../win.zip . -x ".*" cd ../linux -zip -rq ../linux.zip . -x ".*" -cd ../osx -zip -rq ../osx.zip . -x ".*" +tar -czf ../linux.tgz statusalert +cd ../darwin +tar -czf ../darwin.tgz statusalert cd .. -rm -rf osx +rm -rf darwin rm -rf linux rm -rf win echo "Done" \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..db3fd18 --- /dev/null +++ b/install.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +set -e + +add_to_path() { + shell="$SHELL"; + rcfile=".bashrc" + if [[ "$shell" == *"zsh" ]]; then + rcfile=".zshrc"; + fi + if grep -q "/.altlimit/bin" "$HOME/$rcfile"; then + echo "~/.altlimit/bin already in zsh path" + else + echo "Adding ~/.altlimit/bin to PATH in $rcfile"; + echo 'export PATH=$PATH:$HOME/.altlimit/bin' >> $HOME/$rcfile; + echo "Restart your terminal or run 'source ~/$rcfile'" + fi +} + +install_binary() { + if [[ ! -d $HOME/.altlimit/bin ]]; then + echo "Making $HOME/.altlimit/bin" + mkdir -p $HOME/.altlimit/bin; + fi + echo "Downloading latest statusalert binary at: $1"; + curl -o $HOME/.altlimit/bin/statusalert.tgz -s -S -L "$1" + tar -xf $HOME/.altlimit/bin/statusalert.tgz -C $HOME/.altlimit/bin/ + rm $HOME/.altlimit/bin/statusalert.tgz + if [ $? -ne 0 ]; then + echo "Download failed."; + exit 1; + fi + chmod +x $HOME/.altlimit/bin/statusalert; + add_to_path; + echo "statusalert has been installed at $HOME/.altlimit/bin"; +} + +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + MACHINE_TYPE=`uname -m` + if [ ${MACHINE_TYPE} == 'x86_64' ]; then + install_binary "https://github.com/altlimit/statusalert/releases/download/latest/linux.tgz" + else + echo "${MACHINE_TYPE} not supported. Try building from source."; + exit 1; + fi +elif [[ "$OSTYPE" == "darwin"* ]]; then + # Mac OSX + MACHINE_TYPE=`uname -m` + if [ ${MACHINE_TYPE} == 'x86_64' ]; then + install_binary "https://github.com/altlimit/statusalert/releases/download/latest/darwin.tgz" + else + echo "${MACHINE_TYPE} not supported. Try building from source."; + exit 1; + fi +else + echo "$OSTYPE not yet supported."; + exit 1; +fi