Meetups/Infra/2024-08-05
Jump to navigation
Jump to search
A day of sharing shell tools & tricks. Some discussion of networking, in use and broken at noisebridge.
Introductions[edit | edit source]
- [name] - [background]. [goals for meetup, or interests to explore]
- Loren - self
- Doug - writing documentation all day, looking for light relief. Docusaurus. Here to learn, do my penance
- MisterName - mostly a backend coder, here to learn what tips and tricks I can, learn about varieties of systems in the cloud
- Jake - backend for work, free time mostly games, interested in getting some self-hosted stuff up
- Kevin - system administrator. Here to see how people use Linux and stuff
- Yihan - just finished bachelors. DNS.
- Cloud - not part of this, studying bio. Host 5mof once a month. Persuasive design, shaping environment.
- Shah - first time at this meetup, run a company that does IoT, custom solutions for automating buildings. High-voltage, lights, monitoring use of space. Lots of experience with infrastructure, deployment.
Lesson or Demo[edit | edit source]
- Read aloud: clarify for meetup. We are taking notes in a riseup pad (or I am--help appreciated, and links). We have meeting notes posted to the wiki. noisebridge.net, search Infra, or Meetups/Infra. (the Infrastructure page has a disambiguation link.)
- Shell, web services, self-hosting, networking!
- shell niceties: fzf, fd, jq, z.lua (bash built-ins: declare, pushd/popd/dirs, help [built-in])
fzf examples: # lets you select files, for which xargs ls then gives long listings ls | fzf | xargs ls -lh # lists files in reverse order, using 30% of screen, again providing long listing ls | fzf --multi --reverse --height=30% | xargs ls -lh See: https://github.com/junegunn/fzf
z is a powerful replacement for the 'cd' command. examples: z foo # cd to most frecent dir matching foo z foo bar # cd to most frecent dir matching foo and bar z -r foo # cd to highest ranked dir matching foo z -t foo # cd to most recently accessed dir matching foo z -l foo # list matches instead of cd z -c foo # restrict matches to subdirs of $PWD z -e foo # echo the best match, don't cd z -x path # remove path from history See: https://github.com/skywind3000/z.lua
GNOME JavaScript Shell extension programming is a way to marry GUI with bash/csh/zsh and to program it all in JavaScript See: https://gjs.guide/
- jq:
- https://httpbin.org/anything
- (spacex -- fan/user api: https://thespacedevs.com/llapi)
jq examples: # retrieve a JSON list of rocket launches and display the launch name & date-time curl -o - https://ll.thespacedevs.com/2.2.0/launch/ 2>/dev/null | jq '.results[] | "\(.name): \(.net)"'
https://web.stanford.edu/class/cs8 1n/command.txt
- fd
- bash prompt example
declare -Ax _c=([black]="\\033[0;30m" [cyan]="\\033[0;36m" [yellow]="\\033[1;33m" [dark_gray]="\\033[1;30m" [nc]="\\033[0m" [brown]="\\033[0;33" [light_green]="\\033[1;32m" [orange]="\\033[0;33m" [blue]="\\033[0;34m" [red]="\\033[0;31m" [light_red]="\\033[1;31m" [light_cyan]="\\033[1;36m" [light_blue]="\\033[1;34m" [light_gray]="\\033[0;37m" [white]="\\033[1;37m" [green]="\\033[0;32m" [purple]="\\033[0;35m" [light_purple]="\\033[1;35m" ) _ret(){ return ${1:-0}; }; # _ret 1; echo $? ## test return status in prompt get_prompt(){ local ps1 ps1="\${debian_chroot:+(\$debian_chroot)}" 2 ps1+="\[\033[0;30;45m\]\D{w%W.%m/%d}" ps1+="\${dow:\D{%u}:1}" ps1+="\D{.%T}" # 3 ps1+="\[\033[00m\] " ### $ echo $USER@${HOSTNAME%%.*io} | lolcat -S 42 -F .9 -f ### $ for ix in {1..7}; do { echo -n "$ix: "; head -c 8 /dev/urandom | base64;} | lolcat -F 0.75 -S -$ix -f ; done ps1+="$(echo $USER@${HOSTNAME%%.*io} | lolcat -f -F .75 -S -$(printf '%(%u)T' -1))" ### $ echo $USER@${HOSTNAME%%.*io} | lolcat -f -F .75 -S -$(date +%u) ps1+="\[\033[00m\] " ps1+="\[\033[0;34m\]\w" ps1+="\[\033[00m\] " ps1+=$"\n" ps1+="${_c[purple]}\${NOTE}" ps1+="\${NOTE:+" ps1+=$"\n" #ps1+="}${_c[nc]}" ps1+="}\[\033[0m\]" ps1+="|" #ps1+="${_c[red]}" ps1+="\[\033[0;31m\]" ps1+="\${?##0}" #ps1+="${_c[nc]}" ps1+="\[\033[0m\]" ps1+="$ " echo "$ps1" } get_prompt # PS1="$(. .prompt.bash)" # calls get_prompt, returns string here
- networking? -- applied lesson. --- iot discussio with shah
- something cool you learned how to do from the command line
Declarative builds and deployments. Nix is a tool that takes a unique approach to package management and system configuration. Learn how to make reproducible, declarative and reliable systems.
https://nix.dev/tutorials/nix-language.html
https://grahamc.com/blog/nix-and-layered-docker-images/
https://github.com/sharkdp/bat
_ta () { local VERBOSITY=0; for arg in "$@"; do case "$arg" in -v) VERBOSITY=$((VERBOSITY+1)) ;; esac; done; declare -p VERBOSITY; echo "$@" } #2606:4700:4700::1001 #2606:4700:4700::1111 #1.1.1.1 #1.0.0.1 netcheck(){ local VERBOSITY=0; for arg in "$@"; do case "$arg" in -v) VERBOSITY=$((VERBOSITY+1)) ;; esac; done; verbose(){ [[ $(( $VERBOSITY )) -gt 0 ]] && echo "$*"; } #contexteval(){ echo -n "$1: "; eval "${@:2}";} #contexteval(){ eval "${@:2}" | sed -Ee "s/^/$1: /";} . ~/.env.ansi #contexteval(){ eval "timeout .5 ${@:2}" | while read line; do echo -ne "${_c[blue]}$1${_c[nc]}: "; echo "$line"; done;} #contextevalcolor(){ contexteval(){ OUT="$(eval "timeout .5 ${@:2}")" # | ifne -n echo '[none/timeout]'")" RET=$? (( $RET == 0 )) && COLOR="$(tput setaf 2)" || COLOR="$(tput setaf 1)" echo "$OUT" | while IFS='\n' read line; do echo -ne "${_c[blue]}$1${_c[nc]}: "; echo -e "${COLOR}$line${_c[nc]}"; done; } verbose "# end-to-end ip connectivity // not sensitive to DNS" contexteval "inet/wan/cf(v4)" fping -r0 1.1 contexteval "inet/wan/cf(v6)" fping -r0 2606:4700:4700::1001 verbose "# lan ip connectivity, checks wifi, local //" contexteval 'inet/lan/v4' fping _gateway -Amnr0 -4 contexteval 'inet/lan/v6' fping _gateway -Amnr0 -6 contexteval 'inet/lan' fping _outbound -Amnr0 contexteval "inet/lan/gateway" fping -r0 $(ip r | grep default | cut -d' ' -f3) verbose "# configuration of dns, if connectivity works, DHCP'd recursive server down/slow or blocking of global dns / vpn" contexteval "dns/resolvectl dns" resolvectl dns verbose "# e2e check of dns" contexteval "dns/host noisebridge.net" host noisebridge.net } netcheck "$@" netcheck(){ local VERBOSITY=0; for arg in "$@"; do case "$arg" in -v) VERBOSITY=$((VERBOSITY+1)) ;; esac; done; verbose(){ [[ $(( $VERBOSITY )) -gt 0 ]] && echo "$*"; } #contexteval(){ echo -n "$1: "; eval "${@:2}";} #contexteval(){ eval "${@:2}" | sed -Ee "s/^/$1: /";} . ~/.env.ansi #contexteval(){ eval "${@:2}" | while read line; do echo -ne "${_c[blue]}$1${_c[nc]}: "; echo "$line"; done;} #contexteval(){ echo -e "${_c[blue]}$1${_c[nc]}: "; eval "${@:2}";} contexteval(){ echoeval "$@"; } #(){ echo -e "${_c[blue]}$1${_c[nc]}: "; eval "${@:2}";} verbose "# end-to-end ip connectivity // not sensitive to DNS" contexteval "inet/wan/cf" fping -r0 1.1 contexteval "inet/wan/cf" fping -r0 2606:4700:4700::1001 verbose "# lan ip connectivity, checks wifi, local //" contexteval "inet/lan/gateway" fping -r0 $(ip r | grep default | cut -d' ' -f3) verbose "# configuration of dns, if connectivity works, DHCP'd recursive server down/slow or blocking of global dns / vpn" contexteval "dns/resolvectl dns" resolvectl dns verbose "# e2e check of dns" contexteval "dns/host noisebridge.net" host noisebridge.net verbose "# check captive portal" contexteval "dns/host noisebridge.net" curl -s http://networkcheck.kde.org/ } #netcheck "$@"
Links[edit | edit source]
https://github.com/noisebridge/infrastructure/blob/bd255d818e1d8e9ef0691b3f1a862373de32219a/backups/bin/backup-edgerouter.sh#L4 https://github.com/noisebridge/infrastructure/blob/bd255d818e1d8e9ef0691b3f1a862373de32219a/backups/routers/biketrailer.noisebridge.net#L411 https://search.brave.com/search?q=fastroaming&source=desktop&summary=1&summary_og=524a58b8f28a30be6ba742 https://search.brave.com/search?q=proxmox&source=desktop https://en.wikipedia.org/wiki/Proxmox_Virtual_Environment https://search.brave.com/search?q=github+bat&source=desktop https://nixos.org/ https://nix.dev/tutorials/nix-language.html https://nix.dev/manual/nix/2.18/language/ https://determinate.systems/ https://grahamc.com/blog/nix-and-layered-docker-images/ https://nix.dev/tutorials/nixos/building-and-running-docker-images
Outro Poll[edit | edit source]
something you learned today? something you want to follow up on your own, or next week here?
- Loren: .... / nb LAN / DHCP router fix
- Doug: fzf, investigate more /
- Mister Name : time saving in the shell, / specific topics, presentations -- appreciate that approach.
- Jake -- Getting NextCLoud working, self-hosted, https://yunohost.org/
- Yihan -- proxmox. 2 servers, 32g, 64g.
- Shah -- best uses for deploying infrastructure - secure. opinionated deployments.
- Kevin -- switch out some command line tools, use nix as a package manager on mac