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
[[ ${MAAS_PROFILE} ]] || MAAS_PROFILE=$(maas 2>/dev/null list|awk '{print $1}') | |
if [[ -z ${MAAS_PROFILE} ]];then | |
printf "Cannot determine MaaS profile name. Please log in to maas from the command line.\n\n" | |
#if being called from a function, return | |
[[ $0 = bash ]] && return 1 | |
#if being called from a script, exit | |
[[ -f $0 ]] && exit 1 |
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
#To fix bad hashInsert the following as after "late_commands:" in /etc/maas/preseeds/curtin_userdata | |
prxyfix_01_cmd: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo 'Acquire::http::Pipeline-Depth 0;' > /etc/apt/apt.conf.d/99FixBadProxy"] | |
prxyfix_02_cmd: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo 'Acquire::http::No-Cache true;' >> /etc/apt/apt.conf.d/99FixBadProxy"] | |
prxyfix_03_cmd: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo 'Acquire::BrokenProxy true;' >> /etc/apt/apt.conf.d/99FixBadProxy"] | |
#Automatically insert above into /etc/maas/preseeds/curtin_userdata using sed | |
sudo sed -e '/late_commands:/a \ \ prxyfix_01_cmd: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo '"'"'Acquire::http::Pipeline-Depth 0;'"'"' > /etc/apt/apt.conf.d/99FixBadProxy"]\n\ \ prxyfix_02_cmd: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo '"'"'Acquire::http::No-Cache true;'"'"' >> /etc/apt/apt.conf.d/99FixBadProxy"]\n\ \ prxyfix_03_cmd: ["curtin", "in-target", "--", "sh", "-c", "/bin/ec |
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
## Don't change the location of the RSCHK line. It must be first. | |
RSCHK=$_ | |
TRUE=true | |
FALSE=false | |
TEXT_FU_FUNCTIONS_VER=1.0 | |
SOURCEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | |
#Ensure that this script is being sourced, rather than being executed | |
[[ $RSCHK != $0 ]] || { echo "Error: ${SOURCEDIR}/${BASH_SOURCE[0]##*/} is being ran directly! Please \"source\" this script."; sleep 500;return; } |
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
#Workaround for 'Subnet matching query does not exist' error trying to delete a subnet in MaaS | |
#See bug https://bugs.launchpad.net/maas/+bug/1702527 | |
#Usage force-del-maas-subnet <maas subnet name> | |
#ex force-del-maas-subnet '192.168.122.0/24' | |
force-del-maas-subnet() { | |
unset SN_NAME MAAS_SN_ID MAAS_STATICIP_ID MAAS_INTIP_ID MATCH CONT | |
export MATCH=false | |
command -v ipcalc > /dev/null 2>&1 || sudo apt install -yq ipcalc | |
command -v ipcalc > /dev/null 2>&1 || { printf "This function requires ipcalc. Please install it via \"apt install ipcalc -y\"\n";return; } | |
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
# get-known mirrors grabs all officially registered ubuntu mirrors from launchpad.net | |
# Creates the following variables: | |
# KNOWN_MIRRORS - All mirrors | |
# HOST_MIRRORS - Mirrors ran by Ubuntu team @ Canonical | |
# CN_MIRROR - Country specific Hosted Mirror where Country determined by your IP addres | |
get-known-mirrors() { | |
unset KNOWN_MIRRORS | |
local THIS_COUNTRY="$(curl -sSL --connect-timeout 15 --max-time 20 https://whatismycountry.com/|/bin/grep -oP '(?<=>Your Country is )[^<]+')" | |
export KNOWN_MIRRORS=$(curl -sSL --connect-timeout 15 --max-time 20 https://launchpad.net/ubuntu/+archivemirrors|awk -F'["><]' '/application-summary/,/<\/table>/ { if(/th colspan="2">/){COUNTRY=$5;next} if(/http/||/ftp/||/rsync/){SITE=$3} if(/Mbps/||/Gbps/){SPEED=$3} if(/distromirrorstatus/){STATE=$5;gsub(/1 Gbps/,"1000",SPEED);gsub(/2 Gbps/,"2000",SPEED);gsub(/10 Gbps/,"10000",SPEED);gsub(/20 Gbps/,"20000",SPEED);gsub(/4 Gbps/,"4000",SPEED);gsub(/ Mbps/,"",SPEED);gsub(/behind/,"",STATE);gsub(/Up to date/,"0",STATE);gsub(/One |
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
# Preseed file for Canonical OrangeBox | |
# Part of OBInstaller Automation Scripts | |
# by Craig Bender <[email protected]> | |
# Locale | |
d-i debian-installer/locale string en_US.UTF-8 | |
# No splash | |
d-i debian-installer/splash boolean false |
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
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/ETrjzlKN0DnhkaIOLseBnD5aNfxWIkJQl7BuC0QXAdwg1TQDGswd4NBDfCve1CxXvc6PngOJU+iigLVXy/Bl3jvuZ8g5YYj0MbM/sXMQBSWgmzwwB8qjM6P4Qiu+1KONVTkXde5h/U07EIZus5ls1o8v9S3KeWIo2enSPE6Ol1fxuRqFZoZUhLQZjP6DGurdnAY3dxY7Nk1Y6Smmigqh0Tqmstdicjhu1wfPQaXgpVvluq3NaJvxpBnU7eKpXFsel3v+31xGSoDu9tTX9nhZL4dtz6/2tjwKuSTrTWhAKeZTpNHmPtroBGZZyu7+wjkIQgkBwVScfphMDV3glurt rbu # ssh-import-id lp:1chb1n | |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTbAB9JrOGVROxqCQz8xZoh31XcqrcmxnlMStCITMQBUVoispxLfP8UqrkEfr/MUIytJI+pARTIX/dQtLrcGIWprEOJGYAHU75AagPAZUaMQsCt1QULNegntt1mM7CzBPA8FaddNjTfMXsj0o3WlvTcsIqmJSfy500mY9ImS6KBbIk5dqxHAaQBGH3jsTLPjd+pMR23ybXsiNnm5BZ4XIDhABx7WqGW/nwc05AD/1WA7e1TANzzA3VHxZxglgQQFhGRYxf5WvDxG96mHi4kBIVz1hKGM74p9+75OoMOSb4IPjnjlZA2pueYDp77bP5Gaq3opVcSzLkzK3FKpvXNGsp RB Canonical SSH # ssh-import-id lp:1chb1n | |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDb3KIRYql1AxRIxs3oD8Z1crVVrHYyg3dNsZyw2dPSsIM1Z+Tatweqr2p1/xhhqiIdNg6D3lDMOUg3Sys+SGZXc7/ytz73B0YT5RHl1hArhTM58CL+3DyIeKj33q4mm70Sf9e86+MOvlNYD1QF8Lw |
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
maas-login() { | |
[[ -z ${MAAS_PROFILE} ]] && export MAAS_PROFILE=$(maas 2>/dev/null list|awk '{print $1}') | |
if [[ -z ${MAAS_PROFILE} ]];then | |
printf "\n\e[0;33m WARNING\e[0m:Cannot automatically determine the name of the MaaS profile.\n\n" | |
read -erp "Please enter the name of the MaaS profile that you created: " MAAS_PROFILE | |
fi | |
[[ -z ${MAAS_PROFILE} ]] && { printf "\n\e[0;31mERROR\e[0m: MaaS profile name cannot be blank\n\n";return 1; } | |
export MAAS_APIKEY=$(sudo maas 2>/dev/null apikey --username ${MAAS_PROFILE}) | |
[[ -z ${MAAS_APIKEY} ]] && { printf "Cannot determine MaaS API Key for ${MAAS_PROFILE}. Did you create a profile?\n\nUse sudo maas-region createadmin\n\n";return 0; } | |
export MAAS_URL=$(sudo awk '/maas_url/{print $2}' /etc/maas/regiond.conf) |
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
[[ ${MAAS_PROFILE} ]] || MAAS_PROFILE=$(maas 2>/dev/null list|awk '{print $1}') | |
if [[ -z ${MAAS_PROFILE} ]];then | |
printf "Cannot determine MaaS profile name. Please log in to maas from the command line.\n\n" | |
#if being called from a function, return | |
[[ $0 = bash ]] && return 1 | |
#if being called from a script, exit | |
[[ -f $0 ]] && exit 1 |
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
For LVM | |
-------- | |
1) add your ssh key to root's account | |
e.g. sudo su - root | |
ssh-import-id <lp-id> | |
2) ssh into box as root. Don't do this via sudo! | |
3) get volume ids of what you want to remove and what you want to add it to | |
e.g. cat /etc/fstab | |
3.a) Comment out the lines that contain volume ids of that you are going to remove (i.e. /home or swap) |
OlderNewer