Home · RSS · E-Mail · GitHub · GitLab · Twitter · Mastodon · LinkedIn

$tool bits

first published:

Same procedure as last time? Same procedure, just for stuff which won’t require an own post (yet).

» curl

Save with remote filename (short -O):

1
curl http://example.com --remote-name

Save with given filename (short -o):

1
curl http://example.com --output filename

http://www.compciv.org/recipes/cli/downloading-with-curl/

To follow redirects add --location (short -L). Silent add --silent (short -s).

» dd

» Copy an ISO to an USB-stick

1
sudo dd if=ubuntu-20.04.1-live-server-amd64.iso of=/dev/xyz bs=16M status=progress

https://www.cyberciti.biz/faq/creating-a-bootable-ubuntu-usb-stick-on-a-debian-linux/

» Takeover Installation

Overwrite your existing system (seems to be a bit buggy, maybe important parts of the image itself get overwritten)

1
xz -d -c /tmp/talos.raw.xz | dd of=/dev/sda bs=16M status=progress && sync

» envsubst

Replace environment variables (e.g. ${MY_VAR}) in a file:

1
envsubst < "source.txt" > "destination.txt"

If the input and output file should be the same:

1
envsubst < "source.txt" | sponge "source.txt"

or without sponge but more verbose:

1
envsubst < "source.txt" > "destination.txt" && mv "destination.txt" "source.txt" && rm "destination.txt"

envsubst is part of the gettext package and sponge of the moreutils package in Alpine Linux.

Reference: derobert and Derek Mahar

» find

List all files with a specific name, e.g. .DS_Store:

1
find . -type f -name '.DS_Store'

Add -delete to delete all of them.

» git

» Delete Remote Tag

1
git push --delete origin <TAG>

» Globally set default branch to main

1
git config --global init.defaultBranch main

» Squash a feature branch

Manually squash a branch:

1
2
git reset --soft origin/main
git commit --all --message "REPLACE ME"

» Github Workflows

» Access a private repository

When you need access to another private repository inside a Github Workflow (e.g. private Go package repo), add this to your Job’s steps:

1
2
3
- name: "Setup git to fetch private repos"
  run: |
        git config --global url.https://${{ secrets.ACCESS_TOKEN }}@github.com/.insteadOf https://github.com/

Where ACESS_TOKEN is a token which has access to the private repo.

References:

» grep

List all files with occurences of SearchPattern in /path/to/folder and subfolders:

1
grep --color=always --recursive --binary-file=without-match --files-with-matches --ignore-case --fixed-strings "SearchPattern" /path/to/folder

If you want to use a regexp, remove --fixed-strings.

Reference: How to use “grep” command to find text including subdirectories

» helm

» Cascade check possible null values

When you want to check a value (here addr) where other sections might be null (e.g. networking or ipv4) use round brackets so the if condition will be false instead of just crashing.

1
2
3
{{- if not ((.Values.networking).ipv4).addr }}
    {{ fail "setting 'networking.ipv4.addr' is required"}}
{{- end }}

» Resource Checksum Annotation

Add the checksum of another resource (e.g. configmap or secret) to the deployment annoatations. This way, the deployment will be restarted when the checksum (configmap/secret) changes. Otherwise, it could be easily forgotten to restart the deployment and you are wondering why it doesn’t behave as you would expect.

1
2
annotations:
    checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}

» NixOS

Update the system (equivalent to apt update && apt upgrade on Debian):

1
nixos-rebuild switch --upgrade

https://nixos.org/manual/nixos/stable/#sec-upgrading

» Prometheus

» 0 instead of no data

Add OR on() vector(0) to your query.

Credits: Nicolai Antiferov

» tar

extract:

1
tar --extract --gzip --file file.tar.gz [file1 file2 dir1 dir2]

Add --verbose when you want to see which files got extracted.

Not so difficult when you use the long flag names. The flags all together in short: -xzvf.

https://www.cyberciti.biz/faq/linux-unix-bsd-extract-targz-file/

» talosctl

» Reboot

1
talosctl reboot --wait

» Upgrade

Upgrade to e.g. v1.2.0. Use --force when you are running a single node cluster.

1
talosctl upgrade --image ghcr.io/siderolabs/installer:v1.2.0 --wait [--force]



Home · RSS · E-Mail · GitHub · GitLab · Twitter · Mastodon · LinkedIn