diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2020-03-18 15:34:46 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2020-03-18 15:34:46 +0100 |
commit | d2cfe9ce5bb409472f10590aa1ae069b2a971a49 (patch) | |
tree | 81b689c72bd180aae410c6bf822f46980a43458c /utils/lib.sh | |
parent | 86e79488aab3ff434c6682a9464ba2eee49158e9 (diff) | |
download | searxng-d2cfe9ce5bb409472f10590aa1ae069b2a971a49.tar.gz searxng-d2cfe9ce5bb409472f10590aa1ae069b2a971a49.zip |
LXC: add /.lxcenv
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'utils/lib.sh')
-rwxr-xr-x | utils/lib.sh | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/utils/lib.sh b/utils/lib.sh index e13acca3e..e9bfc929f 100755 --- a/utils/lib.sh +++ b/utils/lib.sh @@ -1065,18 +1065,31 @@ EOF in_container() { # Test if shell runs in a container. # - # hint: Reads init process environment, therefore root access is required! - # # usage: in_container && echo "process running inside a LXC container" # in_container || echo "process is not running inside a LXC container" # - - sudo_or_exit + # sudo_or_exit + # hint: Reads init process environment, therefore root access is required! # to be safe, take a look at the environment of process 1 (/sbin/init) - grep -qa 'container=lxc' /proc/1/environ + # grep -qa 'container=lxc' /proc/1/environ + + # see lxc_init_container + [[ -f /.lxcenv ]] } +lxc_init_container() { + # Create a /.lxcenv file in the root folder. Call this once after container + # is inital started. + + # usage: lxc_create_root_dot_lxcenv <name> + + info_msg "create /.lxcenv in container $1" + cat <<EOF | lxc exec "${1}" -- bash | prefix_stdout "[${_BBlue}${1}${_creset}] " +touch "/.lxcenv" +ls -l "/.lxcenv" +EOF +} lxc_exists(){ # usage: lxc_exists <name> || echo "container <name> does not exists" |