Skip to content

Commit

Permalink
Merge pull request #174 from WhitewaterFoundry/development
Browse files Browse the repository at this point in the history
Development Pull
  • Loading branch information
Hayden authored Jul 8, 2019
2 parents df92e3d + 267b0b0 commit 6b86847
Show file tree
Hide file tree
Showing 57 changed files with 2,305 additions and 124 deletions.
80 changes: 48 additions & 32 deletions pengwin-setup
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,50 @@

SetupDir="/usr/local/pengwin-setup.d"

VERSION="1.2a"
export VERSION="1.2a"

# shellcheck disable=SC1090
source ${SetupDir}/common.sh "$@"

declare CANCELLED
declare SKIP_UPDATES

# define functions

function CheckUpgrades {
echo "Updating package database"
sudo apt-get update

# Check for .dist-upgrade file in /etc/apt and inform user dist-upgrade available if so
if [ -f "/etc/apt/.dist-upgrade" ] ; then
# whiptail prompt here, delete on dist-upgrade
echo "Distribution upgrade flag noticed! Alerting user"
if (whiptail --title "Upgrade Available" --yesno "A distribution upgrade is available. In addition to regular package upgrades, this may also install / remove packages. Would you like to continue?\n\nTo run a non-automated distribution upgrade and see package changes, or to perform this in your own time, run 'sudo apt-get dist-upgrade'" 12 90) then
sudo rm /etc/apt/.dist-upgrade
sudo apt-get dist-upgrade -y
exit 0
fi
fi
function check_upgrades() {
echo "Updating package database"

# Check if there's any upgrades to pengwin-setup / pengwin-base
echo "Running upgrade check..."
UPGRD_CHECK="$(sudo apt-get upgrade --show-upgraded --assume-no | grep pengwin)"
if [[ "${UPGRD_CHECK}" == *"pengwin"* ]] ; then
echo "Pengwin core package upgrades found"
if (whiptail --title "Upgrades Available" --yesno "Updates have been detected for Pengwin core packages. Would you like to update them? This is highly recommended. Note: Pengwin-setup will close after installation complete." 10 91) then

# Ensure that packages get updated without affecting other held packages like udev
sudo apt-mark unhold pengwin-base pengwin-setup > /dev/null 2>&1
sudo apt-get upgrade pengwin-base pengwin-setup -y
exit 0
fi
fi
local debian_security_ok="$(cat /etc/apt/sources.list 2>&1 | grep -c "https://deb.debian.org/debian-security testing/updates")"
if [[ ${debian_security_ok} != 0 ]] ; then
sudo sed -i 's$debian-security testing/updates$debian-security testing-security$g' /etc/apt/sources.list
fi

sudo apt-get update --allow-releaseinfo-change

# Check for .dist-upgrade file in /etc/apt and inform user dist-upgrade available if so
if [[ -f "/etc/apt/.dist-upgrade" ]] ; then
# whiptail prompt here, delete on dist-upgrade
echo "Distribution upgrade flag noticed! Alerting user"
if (whiptail --title "Upgrade Available" --yesno "A distribution upgrade is available. In addition to regular package upgrades, this may also install / remove packages. Would you like to continue?\n\nTo run a non-automated distribution upgrade and see package changes, or to perform this in your own time, run 'sudo apt-get dist-upgrade'" 12 90) ; then
sudo rm /etc/apt/.dist-upgrade
sudo apt-get dist-upgrade -y
exit 0
fi
fi

# Check if there's any upgrades to pengwin-setup / pengwin-base
echo "Running upgrade check..."
local upgrd_check="$(sudo apt-get upgrade --show-upgraded --assume-no | grep pengwin)"
if [[ "${upgrd_check}" == *"pengwin"* ]] ; then
echo "Pengwin core package upgrades found"
if (whiptail --title "Upgrades Available" --yesno "Updates have been detected for Pengwin core packages. Would you like to update them? This is highly recommended. Note: Pengwin-setup will close after installation complete." 10 91) ; then

# Ensure that packages get updated without affecting other held packages like udev
sudo apt-mark unhold pengwin-base pengwin-setup > /dev/null 2>&1
sudo apt-get upgrade pengwin-base pengwin-setup -y
exit 0
fi
fi
}

function WelcomePrompt {
Expand Down Expand Up @@ -65,15 +75,15 @@ function ByeMessage {
function install_menu() {
local menu_choice=$(
menu --title "pengwin-setup" --checklist --separate-output "\nHand-curated add-ons [SPACE to select, ENTER to confirm]:" 15 99 7 \
menu --title "pengwin-setup" --checklist --separate-output "\nHand-curated add-ons [SPACE to select, ENTER to confirm]:" 16 99 8 \
"EDITORS" "Install text editors neovim, emacs, or Visual Studio Code (requires X) " off \
"GUI" "Install an X server or various other GUI applications" off \
"MAINTENANCE" "Various maintenance tasks like home backup" off \
"PROGRAMMING" "Install various programming languages support" off \
"SERVICES" "Enable services support (SSH, rc.local)" off \
"SETTINGS" "Change various settings in Pengwin" off \
"TOOLS" "Install applications or servers" off \
"UNINSTALL" "Uninstall applications and packages installed by pengwin-setup" off \
3>&1 1>&2 2>&3)

Expand Down Expand Up @@ -127,6 +137,12 @@ function install_menu() {
exit_status=$?
fi

if [[ ${menu_choice} == *"UNINSTALL"* ]] ; then
echo "UNINSTALL"
bash ${SetupDir}/uninstall.sh "$@"
exit_status=$?
fi

if [[ ${exit_status} != 0 ]] ; then
install_menu "$@"
fi
Expand All @@ -137,11 +153,11 @@ WelcomePrompt
continue_prompt

if [[ ! ${SKIP_UPDATES} ]]; then
CheckUpgrades
check_upgrades
fi

# Ensure our packages are held to prevent odd situation of
# being updated while running other operations from pengwin-setup
# being updated while running other operations from pengwin-setup
# install menu
echo "Holding pengwin-base & pengwin-setup to ensure no changes while operating"
sudo apt-mark hold pengwin-base pengwin-setup > /dev/null 2>&1
Expand Down
136 changes: 115 additions & 21 deletions pengwin-setup.d/cloudcli.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#!/bin/bash

source $(dirname "$0")/common.sh "$@"
# shellcheck source=/usr/local/pengwin-setup.d/common.sh
source "$(dirname "$0")/common.sh" "$@"

# Declare globals
declare SetupDir
declare GOVERSION
declare wHome

function install_terraform() {
if (confirm --title "Terraform" --yesno "Would you like to install Terraform?" 8 40) ; then
echo "Installing Terraform..."

createtmp

wget -O terraform.zip https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_$(dpkg --print-architecture).zip
wget -O terraform.zip "https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_$(dpkg --print-architecture).zip"
unzip terraform.zip
sudo mv terraform /usr/bin
sudo chmod +x /usr/bin/terraform
Expand Down Expand Up @@ -38,7 +44,7 @@ function install_awscli() {
fi

createtmp
sudo apt-get -y install unzip
sudo apt-get -y install unzip python3-distutils
wget -O awscli-bundle.zip https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
unzip awscli-bundle.zip

Expand Down Expand Up @@ -66,33 +72,41 @@ function install_doctl() {
echo "Installing Digital Ocean CTL"

createtmp

echo "Checking for go"
if ! (go version); then
if ! go version ; then
if ! /usr/local/go/bin/go version ; then
echo "Downloading Go using wget."
wget -c "https://dl.google.com/go/go${GOVERSION}.linux-$(dpkg --print-architecture).tar.gz"
tar -xzf go*.tar.gz

export GOROOT=$(pwd)/go
export PATH="${GOROOT}/bin:$PATH"
else
# Whether it was just installed previously, or right now,
# makes sure to set correct env variables
export GOROOT=/usr/local/go
export PATH="${GOROOT}/bin:$PATH"
fi
fi

mkdir gohome
export GOPATH=$(pwd)/gohome

echo "Checking for git"
local git_exists

if (git version); then
local git_exists=1
git_exists=1
else
local git_exists=0
git_exists=0

sudo apt-get -y -q install git
fi

echo "Building doctl"
go get -u github.com/digitalocean/doctl/cmd/doctl
sudo cp $GOPATH/bin/doctl /usr/local/bin/doctl
sudo cp ${GOPATH}/bin/doctl /usr/local/bin/doctl

if [[ ${git_exists} -eq 0 ]]; then
sudo apt-get -y -q purge git
sudo apt-get -y -q autoremove
Expand All @@ -111,6 +125,22 @@ function install_doctl() {

fi
}

function install_kubectl() {

echo "Installing Helm"
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash

wget https://raw.githubusercontent.com/helm/helm/master/scripts/completions.bash
sudo cp completions.bash /etc/bash_completion.d/helm_completions.bash

echo "Installing kubectl"
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get -y -q update
sudo apt-get -y -q install kubectl

}
function install_ibmcli() {

if (confirm --title "IBM Cloud CLI" --yesno "Would you like to install the stand-alone IBM Cloud CLI?" 8 70) ; then
Expand All @@ -137,23 +167,80 @@ function install_ibmcli() {

ibmcloud --version

echo "Installing Helm"
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash
install_kubectl

cleantmp
else
echo "Skipping IBM Cloud CLI"

fi
}

function install_kubernetes() {

if (confirm --title "Kubernetes tooling" --yesno "Would you like to install the Kubernetes tooling?" 10 90) ; then

createtmp

install_kubectl

# Force the creation of a temporary .kube config directory
kubectl config set-cluster fake --server=https://5.6.7.8 --insecure-skip-tls-verify
kubectl config set-credentials nobody
kubectl config set-context fake --cluster=fake --namespace=default --user=nobody

# Install helm plugins: helm-github, helm-tiller, helm-restore

helm init --client-only
helm plugin install https://github.com/sagansystems/helm-github.git
helm plugin install https://github.com/rimusz/helm-tiller
helm plugin install https://github.com/maorfr/helm-restore

# Get the kubectx script
curl -O https://raw.githubusercontent.com/ahmetb/kubectx/master/kubectx
chmod +x kubectx
sudo mv kubectx /usr/local/bin/

# Get the kubens script
curl -O https://raw.githubusercontent.com/ahmetb/kubectx/master/kubens
chmod +x kubens
sudo mv kubens /usr/local/bin/

# Add the completion script to the /etc/bash_completion.d directory.
local base_url=https://raw.githubusercontent.com/ahmetb/kubectx/master/completion
curl ${base_url}/kubectx.bash | sudo tee /etc/bash_completion.d/kubectx > /dev/null
curl ${base_url}/kubens.bash | sudo tee /etc/bash_completion.d/kubens > /dev/null

if( ! docker version 2> /dev/null); then

bash "${SetupDir}/docker.sh" "$@"
fi

local kube_ctl="${wHome}/.kube/config"

wget https://raw.githubusercontent.com/helm/helm/master/scripts/completions.bash
sudo cp completions.bash /etc/bash_completion.d/helm_completions.bash
local kubernetes_enabled
while [[ ! -f ${kube_ctl} ]]; do
if ! (whiptail --title "KUBERNETES" --yesno "Please enable Kubernetes in Docker Desktop. Would you like to try again?" 9 75); then
return

fi

echo "Installing kubectl"
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get -y -q update
sudo apt-get -y -q install kubectl
done

mkdir -p ${HOME}/.kube
ln -sf ${kube_ctl} ${HOME}/.kube/config

kubectl cluster-info
kubens kube-system
kubectl get pods

cleantmp

else
echo "Skipping IBM Cloud CLI"
echo "Skipping Kubernetes tooling"

fi

}

function install_openstack() {
Expand Down Expand Up @@ -182,11 +269,12 @@ function install_openstack() {

function main() {
local choice=$(
whiptail --title "Cloud Management Menu" --checklist --separate-output "CLI tools for cloud management\n[SPACE to select, ENTER to confirm]:" 14 60 5 \
whiptail --title "Cloud Management Menu" --checklist --separate-output "CLI tools for cloud management\n[SPACE to select, ENTER to confirm]:" 16 60 7 \
"AWS" "AWS CLI" off \
"AZURE" "Azure CLI" off \
"DO" "Digital Ocean CLI" off \
"IBM" "IBM Cloud CLI" off \
"KUBERNETES" "Kubernetes tooling" off \
"OPENSTACK" "OpenStack command-line clients " off \
"TERRAFORM" "Terraform " off 3>&1 1>&2 2>&3
)
Expand Down Expand Up @@ -220,6 +308,12 @@ function main() {

fi

if [[ ${choice} == *"KUBERNETES"* ]] ; then

install_kubernetes "$@"

fi

if [[ ${choice} == *"OPENSTACK"* ]] ; then

install_openstack "$@"
Expand Down
5 changes: 5 additions & 0 deletions pengwin-setup.d/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ function process_arguments() {
SKIP_UPDATES=1
shift
;;
--norebuildicons)
echo "Skipping rebuild start menu"
SKIP_STARTMENU=1
shift
;;
*)
shift
esac
Expand Down
2 changes: 1 addition & 1 deletion pengwin-setup.d/cpp-vs-clion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function main {
echo "Installing CMake"

local dist="$(uname -m)"
wget -O cmake.sh "https://github.com/Microsoft/CMake/releases/download/untagged/cmake-3.13.18112701-MSVC_2-Linux-${dist/86_/}.sh"
wget -O cmake.sh "https://github.com/microsoft/CMake/releases/download/v3.13.18112701/cmake-3.13.18112701-MSVC_2-Linux-${dist/86_/}.sh"
sudo bash cmake.sh --skip-license --prefix=/usr/local

cleantmp
Expand Down
Loading

0 comments on commit 6b86847

Please sign in to comment.