This file contains hidden or 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
oscap-report() { | |
local REL=$(lsb_release -sr) SHOW=loc; | |
[[ $((${REL%%.*}%2)) && $((10#${REL##*.})) -eq 4 ]] && { true; } || { printf "\e[1;38;2;255;0;0mSorry\x21\e[0m OVAL Data is only available for LTS release\n\n";return 3; } | |
local OSCAP_REPORT="$HOME/oscap-eval-report__$(lsb_release -sd|awk '{gsub(/ /,"-");print tolower($0)}')-$(hostname -s).html" | |
OK() { printf "\e[74G\x20\e[0m[\x20\e[38;2;0;255;0mOK\e[0m\x20]\e[0m\n"; } | |
FAIL() { printf "\e[74G\e[0m\x20[\e[38;2;255;0;0mFAIL\e[0m]\n"; } | |
WARN() { printf "\e[74G\x20\e[0m[\e[38;2;255;200;0mWARN\e[0m]\n"; } | |
local -a PREREQS=(bzip2 html2text libopenscap8 w3m) | |
local -a PKGS=() | |
local OVAL_URL="https://security-metadata.canonical.com/oval/com.ubuntu.$(lsb_release -cs).usn.oval.xml.bz2" |
This file contains hidden or 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 | |
sudo -iu root psql -U postgres -h /var/snap/maas-test-db/common/postgres/sockets -d maasdb -c "ALTER ROLE maas WITH SUPERUSER" | |
sudo -iu root pg_dumpall -U maas -l maasdb -h /var/snap/maas-test-db/common/postgres/sockets -c|tee 1>/dev/null ~/dump.sql |
This file contains hidden or 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
ip-fwd-status() { find /sys/class/net -maxdepth 1 -type l ! -iname "*lo*" -printf "%P\n"|sort -uV|xargs -I@ -P1 sudo sysctl [email protected]; };export -f ip-fwd-status |
This file contains hidden or 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 | |
[[ -f ~/script.cmds ]] || { printf "\nMissing $HOME/script.cmds. Exiting\n";exit 1; } | |
dprompt() { [[ $HOME = $(pwd) ]] && { local DIR='~'; } || { local DIR=$(pwd); };printf "\e[01;32m$USER@${HOSTNAME}\e[0m:\e[01;34m${DIR}\e[0m$ ";};export -f dprompt | |
clear | |
declare -ag DCMDS=() | |
export DCMD_CNT=${#DCMDS[@]} | |
while IFS= read -er C;do DCMDS+=("${C%;$*}");done < <(cat script.cmds) | |
export DCMD_CNT=${#DCMDS[@]} | |
for D in "${DCMDS[@]}";do dprompt;echo "${D}"|pv -qL 10;bash -c "${D}";done |
This file contains hidden or 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
export PNID_REGEX=$(curl -fksSL https://raw.githubusercontent.com/systemd/systemd/main/src/udev/udev-builtin-net_id.c|grep -oPa '(?<=prefix = \x22)[^\x22]+'|sort -uV|paste -sd'|'|sed -r 's,l\|ww,[lw],g;s,^|$,\x27') |
This file contains hidden or 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
# Show value of $HOME when user does not preserve the environment | |
sudo bash -c 'echo $HOME' | |
# Show the value of $HOME when -E to preserve the sudo user's environment | |
sudo -E bash -c 'echo $HOME' | |
# Tip: If both are the same: | |
# | |
# - You ran this command directly as root (naughty!) |
This file contains hidden or 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
declare -ag SUDO_CHCK=($(sudo sudo -V|awk '/(safety|sanity):[\r]?$/,/remove:[\r]?$/{if (/^E|^Lo/) next;gsub(/\t|\r/,"");print}'|sort -uV)) | |
declare -ag SUDO_REMV=($(sudo sudo -V|awk '/remove:[\r]?$/,/preserve:[\r]?$/{if (/^E|^Lo/) next;gsub(/\t|\r/,"");print}'|sort -uV)) | |
declare -ag SUDO_KEEP=($(sudo sudo -V|awk '/preserve:[\r]?$/,/^Loc/{if (/^E|^Lo/) next;gsub(/\t|\r/,"");print}'|sort -uV)) |
This file contains hidden or 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
add-repo() { | |
add-repo_usage() { | |
# Help Blue, Help Blue Bold, Help Blue Italic, Italic Text and Reset Text | |
local HB='\e[38;2;72;226;225m' HBB='\e[1;38;2;72;226;225m' HBI='\e[3;38;2;72;226;225m' IT='\e[3m' RT='\e[0m' | |
printf "\n\e[2G${HBB}${FUNCNAME%_*}${RT}: ${IT}Add a repo using the new \x22signed-by\x22 feature${RT}\n\n" | |
printf "\e[2G${HBB}Usage${RT}:\n\n" | |
printf "\e[5G${FUNCNAME%_*} [ options ]\n\n" | |
printf "\e[2G${HBB}Options${RT}:\n\n" | |
printf "\e[5G-n,--repo-name\e[22GRepo Name\n\n" | |
printf "\e[5G-u,--repo-url\e[22GRepo URL (in sources.list format)\n\n" |
This file contains hidden or 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 | |
cloud-init clean --logs | |
cloud-init init --local | |
cloud-init init | |
cloud-init modules --mode=config | |
cloud-init modules --mode=final |
This file contains hidden or 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
amt-check() { | |
local G=https://github.com/mjg59/mei-amt-check.git | |
if [[ ! -f /srv/$(basename ${G%.*})/mei-amt-check ]];then | |
sudo chown -R $(id -un 1000):$(id -gn 1000) /srv | |
git clone ${G} /srv/$(basename ${G%.*}) | |
cd /srv/$(basename ${G%.*}) | |
make | |
fi | |
[[ -x /srv/$(basename ${G%.*})/mei-amt-check ]] && { sudo /srv/$(basename ${G%.*})/mei-amt-check; } | |
};export -f amt-check |