Skip to content
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #20 from Privado-Inc/dev
Browse files Browse the repository at this point in the history
sync with dev
  • Loading branch information
ojaswa1942 authored Apr 27, 2022
2 parents 43984ee + 054a253 commit a6350ac
Showing 1 changed file with 41 additions and 16 deletions.
57 changes: 41 additions & 16 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,52 @@ function downloadAndInstallLatestVersion {
tar -xf /tmp/privado-$OS-$ARCH.tar.gz -C $HOME/.privado/bin
fi

PROFILE_PATH="$HOME/.bashrc"
NO_FILE=""
for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zshrc"
do
if [[ -f $HOME/$EACH_PROFILE ]]; then
cat $HOME/$EACH_PROFILE | grep "/.privado" || echo "export PATH=\$PATH:$HOME/.privado/bin" >> $HOME/$EACH_PROFILE
PROFILE_PATH=$HOME/$EACH_PROFILE
NO_FILE="true"
break
fi
done
WHO_AM_I=$(whoami)

if [[ "$WHO_AM_I" == "root" ]]; then
cp $HOME/.privado/bin/privado /usr/local/bin/privado
chmod 755 /usr/local/bin/privado
echo "Installation is complete! Run 'privado' to use Privado CLI"
else
DEFAULT_PROFILE_PATH="$HOME/.bashrc"
NO_FILE=""
for EACH_PROFILE in ".profile" ".bash_profile" ".zshrc"
do
if [[ -f $HOME/$EACH_PROFILE ]]; then
cat $HOME/$EACH_PROFILE | grep -q "/.privado" || echo "export PATH=\$PATH:$HOME/.privado/bin" >> $HOME/$EACH_PROFILE
NO_FILE="true"
fi
done

if [[ "$NO_FILE" == "" ]]; then
echo "export PATH=\$PATH:$HOME/.privado/bin" >> $PROFILE_PATH
if [[ "$NO_FILE" == "" ]] || [[ "$OS" == "linux" ]]; then
cat $DEFAULT_PROFILE_PATH | grep -q "/.privado" || echo "export PATH=\$PATH:$HOME/.privado/bin" >> $DEFAULT_PROFILE_PATH
fi

echo "Installation is complete! Please open a new session and use the privado cli tool"
fi
}

function checkDocker {
docker ps > /dev/null 2>&1
EXIT_CODE=$?
if [[ "$EXIT_CODE" != "0" ]]; then
echo "> Preflight checks failed!"
echo "> Either Docker is not installed, not running, or you do not have appropriate permissions to use the same. Please retry this script with sudo privileges."
exit
fi
}


function preFlightChecks {
checkDocker
}

echo "Installation is complete. Please open a new session or run the command"
echo ". $PROFILE_PATH"
echo "In your existing session"
function cleanup {
rm -f /tmp/privado-*
}

findOS
findArch
preFlightChecks
downloadAndInstallLatestVersion
cleanup

0 comments on commit a6350ac

Please sign in to comment.