Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright (c) 2019 AT&T Intellectual Property. |
| 3 | # Copyright (c) 2019 Nokia. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | |
| 19 | # |
| 20 | # SSH |
| 21 | # |
| 22 | if [ -n "${SSH_PRIVATE_KEY}" ] && [ -n "${PACKAGEREPO}" ] ; then |
| 23 | |
| 24 | # ssh configs (no private key) |
| 25 | mkdir -p ${HOME}/.ssh |
| 26 | test -n "${PACKAGEREPO}" && ssh-keyscan -H ${PACKAGEREPO} >> ${HOME}/.ssh/known_hosts |
| 27 | echo -e "IdentityFile ~/.ssh/id_rsa\n" > ${HOME}/.ssh/config |
| 28 | echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ${HOME}/.ssh/config |
| 29 | chmod -R go= ${HOME}/.ssh/ |
| 30 | chmod -R u+rw ${HOME}/.ssh/ |
| 31 | |
| 32 | # gitconfig |
| 33 | test -n "${PACKAGEREPO}" && echo -e "[url \"ssh://git@${PACKAGEREPO}/\"]\n\tinsteadOf = https://${PACKAGEREPO}/" > ${HOME}/.gitconfig |
| 34 | |
| 35 | # ssh agent |
| 36 | TEMPFILE=/dev/shm/deployment.key |
| 37 | echo "$SSH_PRIVATE_KEY" > $TEMPFILE |
| 38 | chmod 0600 $TEMPFILE |
| 39 | eval $(ssh-agent) |
| 40 | ssh-add $TEMPFILE |
| 41 | rm $TEMPFILE |
| 42 | fi |
| 43 | |
| 44 | if [ -n "${NETRC_CONFIG}" ] ; then |
| 45 | echo "${NETRC_CONFIG}" > /root/.netrc |
| 46 | fi |
| 47 | |
| 48 | |
| 49 | exec $* |