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
#This will print the length of the longest field in a column across all records | |
# awk -F"|" '{ for (i=1; i<=NF; i++) { max[i] = length($i) > max[i] ? length($i) : max[i] ;ncols = i > ncols ? i : ncols }} END { for (col=1; col <= ncols; col++) {printf "%d\n", max[col]}}' | |
##This example has pipe separated record adjust field separator as needed | |
##This example only prints the max length of each column (in order) with a CR, adjust printf statement as needed | |
### Sample data #### | |
FOO=' | |
Host|SysID|DevID|Name|Model|Part ID|UUID|LABEL|FS|MNT|Bootable | |
node01ob20|pk3fqr|73|sda|KINGSTON SV300S3|48|f87c08cb-c444-4f81-af8a-5ed22947f63d|efi|fat32|/boot/efi|true | |
node01ob20|pk3fqr|73|sda|KINGSTON SV300S3|49|3a8024f2-0aa0-4005-8400-cf8d4a3d175d|root|ext4|/|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
#This will print the length of the longest field in a column across all records | |
# awk -F"|" '{ for (i=1; i<=NF; i++) { max[i] = length($i) > max[i] ? length($i) : max[i] ;ncols = i > ncols ? i : ncols }} END { for (col=1; col <= ncols; col++) {printf "%d\n", max[col]}}' | |
##This example has pipe separated record adjust field separator as needed | |
##This example only prints the max length of each column (in order) with a CR, adjust printf statement as needed | |
### Sample data #### | |
FOO=' | |
Host|SysID|DevID|Name|Model|Part ID|UUID|LABEL|FS|MNT|Bootable | |
node01ob20|pk3fqr|73|sda|KINGSTON SV300S3|48|f87c08cb-c444-4f81-af8a-5ed22947f63d|efi|fat32|/boot/efi|true | |
node01ob20|pk3fqr|73|sda|KINGSTON SV300S3|49|3a8024f2-0aa0-4005-8400-cf8d4a3d175d|root|ext4|/|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
juju-fix-missing-gpg-keys() { | |
#search juju debug log for missing GPG keys and apply them to all servers in the model | |
local -a MISSING_KEYS=($((juju debug-log --no-tail --replay|awk '/GPG error/{print $NF}')|sort -u)) | |
local -a MACHINES=($(juju machines|awk '/^[0-9]+/&&/started/{print $1}')) | |
for k in ${MISSING_KEYS[@]};do printf "%s $k\n" ${MACHINES[@]};done|\ | |
xargs -n2 -P0 bash -c 'juju 2>/dev/null ssh $0 sudo apt-key 2>/dev/null adv --recv-key --keyserver keyserver.ubuntu.com $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
maas-ready-nic-info () { | |
( printf "System|ID|VLAN|Tag|MAC|Name|Child of|Parent to|Hostname|Available Subnets on current VLAN\n"; | |
sudo -u postgres psql -P pager=off -F"|" --no-align -t maasdb -c \ | |
"SELECT node.system_id,interface.id,interface.vlan_id,vlan.vid,interface.mac_address,interface.name,ifparent.parent_id,ifchild.child_id,node.hostname, array_to_string(array_agg(distinct subnet.cidr),',') AS niclist \ | |
FROM maasserver_interface interface \ | |
LEFT OUTER JOIN maasserver_vlan vlan ON vlan.id = interface.vlan_id \ | |
LEFT OUTER JOIN maasserver_subnet subnet ON subnet.vlan_id = interface.vlan_id \ | |
LEFT OUTER JOIN maasserver_node node ON interface.node_id = node.id \ | |
LEFT OUTER JOIN maasserver_interfacerelationship ifparent ON interface.id = ifparent.child_id \ | |
LEFT OUTER JOIN maasserver_interfacerelationship ifchild ON interface.id = ifchild.parent_id \ |
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
#Updated to print full names when they include spaces and to display in columns | |
showrgb| \ | |
awk '{printf "%s", "\"\\e[1;38;2;"$1";"$2";"$3"m"; for(i=4;i<=NF;i++){printf "%s ", $i};printf "\\e[0m\"\n"}'| \ | |
xargs -L1 echo -e| \ | |
column |
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-insert-boot-param() { | |
local DESC="\e[1m${FUNCNAME}\e[0m: Insert a boot paramter into a specific, or all existing tags.\n" | |
maas-insert-boot-param_usage() { | |
printf "\n${DESC}\n" | |
printf "\e[1mUsage\e[0m: ${FUNCNAME%%_*} -p <param> [-t <tag>]\n\n" | |
printf "\e[1mOptions\e[0m:\n" | |
printf "\e[2G -p, --param \e[20GRequired: boot parameter to add\n" | |
printf "\e[20GEx: apparmor=0\n" | |
printf "\e[20GTip: Enclose multiple params in single quotes\n\n" | |
printf "\e[2G -t, --tag \e[20GOptional: Add only to a specific tag\n" |
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
#!/bin/bash | |
###NOTE### | |
# This requires requires linux to create a ChromeOS Recovery Image. | |
printf "\e[2GCreate ChromeOS Recovery media using Linux machine...\n\n" | |
printf "\e[2G - Please ensure a (min) 4GB USB disk is plugged in, then hit ENTER.\n" | |
read CONT |
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
#!/bin/bash | |
###NOTE### | |
# This requires: | |
# 1) ChromeOS Recovery Media for your machine (see https://bit.ly/makechromeos-media) | |
# 2) A separate linux machine to alter the ChromeOS recovery media | |
# 99.999% of this script was lifted wholesale from http://bit.ly/2oFvluu | |
# This just automtes the manual parts in the guidance provided | |
# |
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
curl -sSL https://timezoneapi.io/api/ip|\ | |
jq -r 'keys[0] as $k|.[$k]|to_entries[]|select((.key != "timezone" and .key != "datetime"))|"\(.key): \(.value)"' |