mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
Added env-related notes to the knowledge base
This commit is contained in:
18
knowledge base/envsubst.md
Normal file
18
knowledge base/envsubst.md
Normal 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
|
||||
```
|
||||
15
knowledge base/export all variables in a envfile.md
Normal file
15
knowledge base/export all variables in a envfile.md
Normal 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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user