Last active
May 21, 2021 20:28
-
-
Save kenhia/3a7176c2195dc5a0f5d319cdb850c064 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/bash | |
INSTRUCTIONS_URL='https://www.bing.com' | |
echo "More information and instructions: $INSTRUCTIONS_URL" | |
echo | |
echo "About to check if this system has the bare essentials." | |
echo | |
echo "This checks if you have:" | |
echo " git" | |
echo " python3" | |
echo | |
echo "If you are missing any of the above, this script will attempt to install them" | |
echo "in which case one or more 'sudo apt ...' commands will be run and sudo will" | |
echo "prompt for your password to allow it to invoke 'sudo'" | |
echo | |
read -p "Continue [y|N]? " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ ! $REPLY =~ ^[Yy]$ ]] | |
then | |
echo "Stopping. You will need to rerun this script later." | |
exit 1 | |
else | |
echo | |
echo "Continuing with the checks." | |
fi | |
function check_if_installed() { | |
prog=$1 | |
command -v $prog >/dev/null 2>&1 | |
echo $? | |
} | |
function add_missing_apt_package() { | |
package=$1 | |
if [ -z $MISSING_APT_PACKAGES ]; then | |
MISSING_APT_PACKAGES=$package | |
else | |
MISSING_APT_PACKAGES=$MISSING_APT_PACKAGES:$package | |
fi | |
} | |
# Check for git | |
found_git=$(check_if_installed git) | |
if [ $found_git -eq 0 ]; then | |
echo "We have git!" | |
else | |
echo "Missing git :-(" | |
add_missing_apt_package git | |
fi | |
# Check for Python Installation | |
found_python3=$(check_if_installed python3) | |
if [ $found_python3 -eq 0 ]; then | |
echo "We have python3" | |
else | |
echo "Missing python3" | |
add_missing_apt_package python3 | |
fi | |
if [ -z $AZURE_DEVOPS_EXT_PAT ]; then | |
echo "Missing the PAT!" | |
fi | |
# Check for az | |
found_az=$(check_if_installed az) | |
if [ $found_az -eq 0 ]; then | |
echo "We have az" | |
else | |
echo "Need to install az somehow" | |
fi | |
echo $MISSING_APT_PACKAGES | |
if [ "$MISSING_APT_PACKAGES" ]; then | |
echo 'fake sudo apt update' | |
IFS=':' | |
read -ra ADDR <<< "$MISSING_APT_PACKAGES" | |
for i in "${ADDR[@]}"; do | |
echo "fake sudo apt install $i" | |
done | |
IFS=' ' | |
else | |
echo 'No additional packages needed!' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment