Added env-related notes to the knowledge base

This commit is contained in:
Michele Cereda
2022-05-12 22:28:07 +02:00
parent 7f76329514
commit e45c9fb412
3 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
# Envsubst
Substitutes environment variables in shell format strings.
## TL;DR
```shell
envsubst < input.file
envsubst < input.file > output.file
```
```shell
$ cat hello.file
hello $NAME
$ NAME='mek' envsubst < hello.file
hello mek
```

View File

@@ -0,0 +1,15 @@
# Export all variables in an envfile
## TL;DR
```shell
set -o allexport
source envfile
set +o allexport
```
## Sources
- [Set environment variables from file of key/value pairs]
[set environment variables from file of key/value pairs]: https://stackoverflow.com/questions/19331497/set-environment-variables-from-file-of-key-value-pairs#30969768

View File

@@ -0,0 +1,19 @@
# Get the environment of a process running in a container
## TL;DR
```shell
cat /proc/${PID}/environ
# Container in kubernetes.
kubectl exec pod-name -- cat /proc/1/environ
# Only works if the onboard `ps` is not from busybox.
ps e -p $PID
```
## Sources
- [Get the environment variables of running process in container]
[get the environment variables of running process in container]: https://unix.stackexchange.com/a/412730