Skip to content

Instantly share code, notes, and snippets.

@ChrisMcKee
Created April 18, 2018 17:15
Show Gist options
  • Save ChrisMcKee/dba6ec16f21df98068b24fab0642930a to your computer and use it in GitHub Desktop.
Save ChrisMcKee/dba6ec16f21df98068b24fab0642930a to your computer and use it in GitHub Desktop.
#!/bin/bash
curl_check ()
{
echo "Checking for curl..."
if command -v curl > /dev/null; then
echo "Detected curl..."
else
echo "Installing curl..."
apt-get install -q -y curl
fi
}
wget_check ()
{
echo "Checking for wget..."
if command -v wget > /dev/null; then
echo "Detected wget..."
else
echo "Installing wget..."
apt-get install -q -y wget
fi
}
install_debian_keyring ()
{
if [ "${os}" = "debian" ]; then
echo "Installing debian-archive-keyring which is needed for installing "
echo "apt-transport-https on many Debian systems."
apt-get install -y debian-archive-keyring &> /dev/null
fi
}
main ()
{
curl_check
wget_check
install_debian_keyring
echo -n "Installing apt-transport-https... "
apt-get install -y apt-transport-https &> /dev/null
echo "done."
cd /tmp
wget https://nginx.org/keys/nginx_signing.key
apt-key add nginx_signing.key
rm nginx_signing.key
cat <<EOF > /etc/apt/sources.list.d/nginx.list
deb https://nginx.org/packages/ubuntu/ xenial nginx
deb-src https://nginx.org/packages/ubuntu/ xenial nginx
EOF
echo -n "Running apt-get update... "
apt-get update &> /dev/null
echo -n "Done"
apt-get install nginx -yq
echo -n "Nginx is is now installed"
}
sudo bash -c "$(declare -f); main"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment