Merge "Add DIB_LOCAL_CONFIG_USERNAME to local-config"

This commit is contained in:
Jenkins 2015-11-30 05:38:36 +00:00 committed by Gerrit Code Review
commit 403c37ba25
3 changed files with 20 additions and 5 deletions

View File

@ -3,3 +3,11 @@ local-config
============
Copies local user settings such as .ssh/authorized\_keys and $http\_proxy into
the image.
Environment Variables
---------------------
DIB_LOCAL_CONFIG_USERNAME
:Required: No
:Default: root
:Description: Username used when installing .ssh/authorized\_keys.

View File

@ -0,0 +1 @@
export DIB_LOCAL_CONFIG_USERNAME=${DIB_LOCAL_CONFIG_USERNAME:-root}

View File

@ -8,9 +8,15 @@ fi
set -eu
set -o pipefail
if [ -e "/tmp/in_target.d/ssh-authorized-keys" ]; then
mkdir -p /root/.ssh
cat /tmp/in_target.d/ssh-authorized-keys >> /root/.ssh/authorized_keys
chmod 0700 /root/.ssh
chmod 0600 /root/.ssh/authorized_keys
if [ "$DIB_LOCAL_CONFIG_USERNAME" == "root" ]; then
DIR_NAME=${DIB_LOCAL_CONFIG_USERNAME}
else
DIR_NAME=home/${DIB_LOCAL_CONFIG_USERNAME}
fi
if [ -e "/tmp/in_target.d/ssh-authorized-keys" ]; then
mkdir -p /${DIR_NAME}/.ssh
cat /tmp/in_target.d/ssh-authorized-keys >> /${DIR_NAME}/.ssh/authorized_keys
chmod 0700 /${DIR_NAME}/.ssh
chmod 0600 /${DIR_NAME}/.ssh/authorized_keys
fi