From a9f1cc59ff1932bf88b4889c35d46ab9ad25ceb4 Mon Sep 17 00:00:00 2001 From: Mario Alegre Date: Thu, 3 Dec 2020 18:03:08 -0500 Subject: [PATCH] added user creation/config to install script --- install.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index f196c9e..0bf33a7 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ #!/bin/bash set -eEuo pipefail -trap 'echo "Error detected: aborting installation."' ERR +trap 'echo "Error detected: aborting installation"' ERR echo "Attempting to autodetect distro ..." distro=$(lsb_release -is) @@ -47,10 +47,20 @@ else fi sudo chmod +x /etc/containers/startup.sh -if id -u containers; then - echo "Configuring user 'containers' ..." - -echo 'Creating "containers" user ...' - +# configure containers user +name=containers +uid=5000 +subrange="1000000:1000000000" +if ! getent group $name; then + echo "Creating group '$name' ..." + groupadd -r -g $uid $name +fi +if ! getent passwd $name; then + echo "Creating user '$name' ..." + useradd -r -u $uid -p '*'-s /sbin/nologin -d /srv/vol -g $name $name +fi +echo "Configuring user '$name' ..." +groupmod -g $uid $name +usermod -u $uid -p '*' -s /sbin/nologin -d /srv/vol/ -G '' -v $subrange -w $subrange -g $name $name echo "Install finished successfully."