From c76a4e8f68b177db9d74d466ed0045c8387cf132 Mon Sep 17 00:00:00 2001 From: wolfy Date: Tue, 17 May 2022 20:06:11 -0600 Subject: [PATCH] added startup file to handle user configuration --- scripts/docker/runit/arm_user_setup.sh | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 scripts/docker/runit/arm_user_setup.sh diff --git a/scripts/docker/runit/arm_user_setup.sh b/scripts/docker/runit/arm_user_setup.sh new file mode 100644 index 000000000..6643e87cd --- /dev/null +++ b/scripts/docker/runit/arm_user_setup.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# This script is first to run due to this: https://github.com/phusion/baseimage-docker#running_startup_scripts. +# +# It updates the UIG or GID of the included arm user to whatever value the user +# passes at runtime, if the value set is not the default value of 1000 +# +# If the container is run again without specifying UID and GID, this script +# resets the UID and GID of all files in ARM directories to the defaults + +DEFAULT_UID=1000 +DEFAULT_GID=1000 + +if [[ $ARM_UID -ne $DEFAULT_UID ]]; then + echo -e "Updating arm user id from $DEFAULT_UID to $ARM_UID..." + usermod -u "$ARM_UID" arm +elif [[ $ARM_UID -eq $DEFAULT_UID ]]; then + echo -e "Updating arm group id $ARM_UID to default (1000)..." + usermod -u $DEFAULT_UID arm +fi + +if [[ $ARM_GID -ne $DEFAULT_GID ]]; then + echo -e "Updating arm group id from $DEFAULT_GID to $ARM_GID..." + groupmod -g "$ARM_GID" arm +elif [[ $ARM_UID -eq $DEFAULT_GID ]]; then + echo -e "Updating arm group id $ARM_GID to default (1000)..." + groupmod -g $DEFAULT_GID arm +fi