X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=jenkins-init-scripts%2Fcreate-jenkins-user.sh;h=980eacf1377fcc0b6f9594cd67d89e88bbfaf9e9;hb=bafd57c92d85a6c8b2c3fd3dbe30aa3a09f8f620;hp=0983129fa4ecb74f95f2e07cd079907ca302998c;hpb=60badecd78ccc62dd171b507b6e95c7e3229929e;p=releng%2Fglobal-jjb.git diff --git a/jenkins-init-scripts/create-jenkins-user.sh b/jenkins-init-scripts/create-jenkins-user.sh index 0983129f..980eacf1 100755 --- a/jenkins-init-scripts/create-jenkins-user.sh +++ b/jenkins-init-scripts/create-jenkins-user.sh @@ -12,10 +12,10 @@ OS=$(facter operatingsystem | tr '[:upper:]' '[:lower:]') OS_RELEASE=$(facter lsbdistrelease | tr '[:upper:]' '[:lower:]') -if [[ "$OS_RELEASE" == "18.04" ]] && [[ "$OS" == 'ubuntu' ]] -then - echo 'PATH=$HOME/.local/bin:$PATH -export PATH' >> /etc/profile +if [[ "$OS_RELEASE" == "18.04" && "$OS" == 'ubuntu' ]]; then + # We do not want var expansion here as profile script expands at runtime. + # shellcheck disable=SC2016 + echo 'export PATH=$HOME/.local/bin:$PATH' >> /etc/profile fi useradd -m -s /bin/bash jenkins @@ -30,12 +30,13 @@ if grep -q mock /etc/group; then fi mkdir /home/jenkins/.ssh -cp -r "/home/${OS}/.ssh/authorized_keys" /home/jenkins/.ssh/authorized_keys +cp "/home/${OS}/.ssh/authorized_keys" /home/jenkins/.ssh/authorized_keys +chmod 0600 /home/jenkins/.ssh/authorized_keys # Generate ssh key for use by Robot jobs echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa chown -R jenkins:jenkins /home/jenkins/.ssh -chmod 700 /home/jenkins/.ssh +chmod 0700 /home/jenkins/.ssh # The '/w' volume may already be part of image [[ ! -d '/w' ]] && mkdir /w