From 10b8331f21b59f4d2d1a9d21cef4935ba3774860 Mon Sep 17 00:00:00 2001 From: desrod Date: Fri, 20 Apr 2018 14:13:25 -0400 Subject: [PATCH] Removing renamed build.sh --- build.sh | 283 ------------------------------------------------------- 1 file changed, 283 deletions(-) delete mode 100755 build.sh diff --git a/build.sh b/build.sh deleted file mode 100755 index 17593c3..0000000 --- a/build.sh +++ /dev/null @@ -1,283 +0,0 @@ -#!/bin/bash - -required_bins=( ip jq sudo uuid ) - -check_bins() { - - # Append any needed binaries we need to check for, to our list - if [[ $1 ]]; then - required_bins+=("$1") - fi - - for binary in "${required_bins[@]}"; do - if ! [ -x "$(command -v "$binary")" ]; then - printf "Error: Necessary program '%s' is not installed. Please fix, aborting now.\n\n" "$binary" >&2 - exit 1 - fi - done -} - -# Initialize some vars we'll reuse later in the build, bootstrap -init_variables() { - # This is the user who 'maas' uses when commissioning nodes - virsh_user="ubuntu" - maas_profile="admin" - maas_pass="openstack" - - # This is the user whose keys get imported into maas by default - launchpad_user="setuid" - - maas_system_ip="$(hostname -I | awk '{print $1}')" - maas_bridge_ip="$(ip addr show virbr0 | awk '/inet/ {print $2}' | cut -d/ -f1)" - maas_endpoint="http://$maas_bridge_ip:5240/MAAS" - - # This is the proxy that MAAS itself uses (the "internal" MAAS proxy) - maas_local_proxy="http://$maas_bridge_ip:8000" - maas_upstream_dns="1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4" - - # This is an upstream, peer proxy that MAAS may need to talk to (tinyproxy in this case) - # maas_upstream_proxy="http://$maas_system_ip:8888" - - virsh_chassis="qemu+ssh://${virsh_user}@${maas_system_ip}/system" - - maas_packages=(maas maas-cli maas-proxy maas-dhcp maas-dns maas-rack-controller maas-region-api maas-common) - pg_packages=(postgresql-9.5 postgresql-client postgresql-client-common postgresql-common) -} - -remove_maas() { - # Drop the MAAS db ("maasdb"), so we don't risk reusing it - sudo -u postgres psql -c "select pg_terminate_backend(pid) from pg_stat_activity where datname='maasdb'" - sudo -u postgres psql -c "drop database maasdb" - - # Remove everything, start clean and clear from the top - sudo DEBIAN_FRONTEND=noninteractive apt-get -y remove --purge "${maas_packages[@]}" "${pg_packages[@]}" && \ - sudo apt-get -fuy autoremove - - # Yes, they're removed but we want them PURGED, so this becomes idempotent - for package in "${maas_packages[@]}" "${pg_packages[@]}"; do - sudo dpkg -P "$package" - done -} - -install_maas() { - # This is separate from the removal, so we can handle them atomically - # sudo apt -fuy --reinstall install maas maas-cli jq tinyproxy htop vim-common - sudo apt -fuy --reinstall install "${maas_packages[@]}" "${pg_packages[@]}" -} - -purge_admin_user() { - -read -r -d '' purgeadmin < clouds-"$rand_uuid".yaml < credentials-"$rand_uuid".yaml < config-"$rand_uuid".yaml < Do EVERYTHING (maas, juju cloud, juju bootstrap) - -b Build out and bootstrap a new MAAS - -c Add a new cloud + credentials - -i Just install the dependencies and exit - -j Bootstrap the Juju controller called - -n Create MAAS kvm nodes (to be imported into chassis) - -r Remove the entire MAAS server + dependencies - -t Tear down the cloud named - " -} - - -if [ $# -eq 0 ]; then - printf "%s needs options to function correctly. Valid options are:" "$0" - show_help - exit 0 -fi - -init_variables - -while getopts ":a:bc:ij:nt:r" opt; do - case $opt in - a ) - check_bins - remove_maas - install_maas - build_maas - bootstrap_maas - add_cloud "$OPTARG" - ;; - b ) - echo "Building out a new MAAS server" - # install_maas - install_maas - build_maas - bootstrap_maas - exit 0 - ;; - c ) - check_bins maas - init_variables - add_cloud "$OPTARG" - ;; - i ) - echo "Installing MAAS and PostgreSQL dependencies" - install_maas - exit 0 - ;; - j ) - echo "Bootstrapping Juju controller $OPTARG" - add_cloud "$OPTARG" - exit 0 - ;; - r ) - remove_maas - exit 0 - ;; - t ) - destroy_cloud "$OPTARG" - exit 0 - ;; - \? ) - printf "Unrecognized option: -%s. Valid options are:" "$OPTARG" >&2 - show_help - exit 1 - ;; - : ) - printf "Option -%s needs an argument.\n" "$OPTARG" >&2 - show_help - echo "" - exit 1 - ;; - esac -done