summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@ifm.com>2022-01-15 20:20:54 +0100
committerMatthias Beyer <matthias.beyer@ifm.com>2022-02-14 16:04:54 +0100
commitfa77b3c3463dc0721597322ca1daa02fb733d725 (patch)
tree3c34ea485e1edcffae559f280fd70ef4ea649eac
parent7614962f733ca7c9ae05f68e04c1dff2088db97d (diff)
containers: Extract user setup to dedicated script, include it in mosquitto container setup
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
-rw-r--r--examples/containers.nix9
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/containers.nix b/examples/containers.nix
index cd62d23b..60c83f76 100644
--- a/examples/containers.nix
+++ b/examples/containers.nix
@@ -4,7 +4,8 @@
}:
let
- setupScript = pkgs.writeScriptBin "setup-container" ''
+
+ user-setup = pkgs.writeScriptBin "user-setup" ''
#!${pkgs.runtimeShell}
set +x
@@ -13,7 +14,9 @@ let
groupadd tedge-users
groupadd tedge
useradd --system --no-create-home --shell /sbin/nologin -g tedge tedge
+ '';
+ setupScript = pkgs.writeScriptBin "setup-container" ''
install -g tedge -o tedge -m 755 -d /etc/tedge
install -g tedge -o tedge -m 755 -d /etc/tedge/operations
install -g tedge -o tedge -m 755 -d /etc/tedge/plugins
@@ -49,6 +52,8 @@ in {
#!${pkgs.runtimeShell}
${pkgs.dockerTools.shadowSetup}
+ ${pkgs.bash}/bin/bash ${user-setup}/bin/user-setup || exit 1
+
groupadd mosquitto
useradd --system --no-create-home --shell /sbin/nologin -g mosquitto mosquitto
@@ -78,6 +83,7 @@ in {
runAsRoot = ''
#!${pkgs.runtimeShell}
${pkgs.dockerTools.shadowSetup}
+ ${pkgs.bash}/bin/bash ${user-setup}/bin/user-setup || exit 1
${pkgs.bash}/bin/bash ${setupScript}/bin/setup-container || exit 1
mkdir -p /run/lock
@@ -102,6 +108,7 @@ in {
runAsRoot = ''
#!${pkgs.runtimeShell}
${pkgs.dockerTools.shadowSetup}
+ ${pkgs.bash}/bin/bash ${user-setup}/bin/user-setup || exit 1
${pkgs.bash}/bin/bash ${setupScript}/bin/setup-container || exit 1
mkdir -p /run/lock