It is a good idea to use named variables for storing parameters of a script or function. We can use parameter expansion to either set a default or check mandatory arguments
Mandatory parameter
hello() {
NAME=${1:?provide name as first parameter}
echo "Hello $NAME!"
}
$ hello # $?=1
bash: 1: provide name as first parameter
$ hello Foo # $?=1
Hello Foo!
Parameter with default
hello() {
NAME=${1:-Marvin}
echo "Hello $NAME!"
}
$ hello # $?=0
Hello Marvin!
$ hello Foo # $?=1
Hello Foo!
Related cards:
FAQ for When PostgreSQL Indexes Are Corrupted After Locale Changes
When changing glibc versions, it's possible to end up with corrupt indexes in PostgreSQL.
Are My Indexes Affected?
If your database has...
Elasticsearch unassigned replica shards on single node instances
If you have a single node elasticsearch instance and indices with replicas enabled your cluster state will be yellow. If you have replica shards they should be moved to a different node for high availability purposes. With a single node this can't...
Intel Microcode Versions and Updates
Intel CPUs receive updates, including security relevant upgrades, through 2 channels:
- Firmware/UEFI BIOS updates can also update the microcode in CPUs. This is the preferred and persistent way
- the
intel-microcode
package can patch the micro...
Keepalived VRRP FAQ
How can I configure virtual IP's?
There are two parameter to set up virtual ips in Keepalived:
virtual_ipaddress
Addresses defined here are included into the VRRP Packages and are therefore limited in number, especially with IPv6.
Add...
HowTo apply Test Driven Development to Container Images
Apply Test Driven Development(TDD) to the process of building container images by defining test before writing code and automate the testing process. Iterate through the TDD cycle while developing and running the tests later in continuous integrat...
dumping and restoring PostgreSQL databases
This card is just about creating simple PostgreSQL dumps. This is no instruction for a backup strategy nor a guide for SQL dump performance optimization.
Read before starting
- I will assume that all commands will be executed as local `postgr...
Installing throttled to fix Lenovo laptops with nvidia graphics running Ubuntu losing performance after a while
We have observed Lenovo laptops with nvidia graphics losing performance after they have been in use for a few minutes. While we have not been able to pinpoint exactly what triggered the performance loss, we have found it mostly correlated with hig...
Exim: investigating frozen messages in the mailqueue
Investigate why mails are frozen
The exim documentation says:
Freezing occurs when a bounce message encounters a permanent failure because the...
HowTo: Get postgres shell in kubernetes
If your postgres database is only accessible from inside a kubernetes cluster, e.g. if it's configured in AWS RDS and not available to the public (as it should be!), here's how to open a psql
shell inside Kubernetes and connect to the database. ...
HowTo: Easier selecting and copying of text in tmux
When using tmux
, selecting and copying multiple lines of text can be a hassle, especially when using splits (highlighting lines will cross pane borders, copying contents from the other pane too) and when the user wishes to copy (thus, select) li...