aboutsummaryrefslogtreecommitdiff
path: root/tcwg-base
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2018-06-06 14:30:43 +0000
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2018-06-12 12:20:54 +0000
commit48056aa3698b8481115ea94b27d3409f52a544ac (patch)
treea2d4c8d8e46a3d646ea7bd06ffdf9a8752923f03 /tcwg-base
parentea485a5059afdac2598402ea2e244e109f71ab8b (diff)
tcwg-base: Allow "new-user.sh --user USER" interface to create users.
User data will be fetched from image's /home-data for USER. Change-Id: Ic3a2808dbad196766cb440842fee497ab269c924
Diffstat (limited to 'tcwg-base')
-rwxr-xr-xtcwg-base/new-user.sh23
-rw-r--r--tcwg-base/tcwg-build/Dockerfile.in2
-rw-r--r--tcwg-base/tcwg-host/Dockerfile.in2
3 files changed, 19 insertions, 8 deletions
diff --git a/tcwg-base/new-user.sh b/tcwg-base/new-user.sh
index 07a1f3ec..727982a1 100755
--- a/tcwg-base/new-user.sh
+++ b/tcwg-base/new-user.sh
@@ -9,7 +9,7 @@ usage ()
passwd_ent=""
group=""
-home_data=""
+home_data="default"
user=""
verbose=false
@@ -27,6 +27,17 @@ done
if $verbose; then set -x; fi
+if [ x"$home_data" = "default" ]; then
+ home_data=""
+ if [ -d /home-data/ ]; then
+ home_data="/home-data"
+ fi
+fi
+
+if [ x"$passwd_ent" = x"" -a x"$home_data" != x"" -a x"$user" != x"" ]; then
+ passwd_ent=$(grep "^${user%%:*}:" "$home_data/passwd")
+fi
+
if [ x"$group" != x"" ]; then
gid=$(echo "$group" | cut -s -d: -f 2)
group=$(echo "$group" | cut -d: -f 1)
@@ -68,13 +79,13 @@ if [ x"$user" != x"" ]; then
chmod 0440 $sudoers_file
if [ x"$home_data" != x"" ]; then
- chown -R $user${gid:+:$gid} /home-data/$user/
- chmod -R go-w /home-data/$user/
- chmod -R go-rwx /home-data/$user/.ssh/
- rsync -a /home-data/$user/ /home/$user/
+ chown -R $user${gid:+:$gid} $home_data/$user/
+ chmod -R go-w $home_data/$user/
+ chmod -R go-rwx $home_data/$user/.ssh/
+ rsync -a $home_data/$user/ /home/$user/
# Make /home-data/$user a prestine copy of $user's /home to have
# access to files even when /home volume is reused from previous
# container instance.
- rsync -a /home/$user/ /home-data/$user/
+ rsync -a /home/$user/ $home_data/$user/
fi
fi
diff --git a/tcwg-base/tcwg-build/Dockerfile.in b/tcwg-base/tcwg-build/Dockerfile.in
index 4f5cab9e..d9a8f692 100644
--- a/tcwg-base/tcwg-build/Dockerfile.in
+++ b/tcwg-base/tcwg-build/Dockerfile.in
@@ -4,7 +4,7 @@ RUN while read line; do \
if [ x"$(echo "$line" | cut -d: -f 4)" != x"9000" ]; then \
continue; \
fi; \
- new-user.sh --passwd "$line" --home-data /home-data; \
+ new-user.sh --passwd "$line"; \
done </home-data/passwd
#if ARCH_amd64 || ARCH_i386
diff --git a/tcwg-base/tcwg-host/Dockerfile.in b/tcwg-base/tcwg-host/Dockerfile.in
index 968098ef..4c001308 100644
--- a/tcwg-base/tcwg-host/Dockerfile.in
+++ b/tcwg-base/tcwg-host/Dockerfile.in
@@ -1,7 +1,7 @@
FROM linaro/ci-#{ARCH}-tcwg-base-ubuntu:#{DISTRO}
RUN while read line; do \
- new-user.sh --passwd "$line" --home-data /home-data; \
+ new-user.sh --passwd "$line"; \
done </home-data/passwd
COPY start.sh /