-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinit.sh
executable file
·37 lines (31 loc) · 897 Bytes
/
init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /bin/bash
echo "------------------------------"
echo "| Jenkins image by taypo.com |"
echo "------------------------------"
# Prepare directories
mkdir -p $HOME/.ssh
chmod 700 $HOME/.ssh
touch $HOME/.ssh/known_hosts
# Generate public private key pair
if [ ! -f $HOME/.ssh/id_rsa.pub ]; then
ssh-keygen -t rsa -f $HOME/.ssh/id_rsa -q -N ""
echo "=> Generated ssh keys"
fi
echo "=> Public key:"
cat $HOME/.ssh/id_rsa.pub
# Add known hosts
if [ -n "${KNOWN_HOSTS}" ]; then
echo "=> Found known hosts"
IFS=$'\n'
arr=$(echo ${KNOWN_HOSTS} | tr "," "\n")
for x in $arr
do
cat $HOME/.ssh/known_hosts | grep "$x" >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "=> Adding host to .ssh/known_hosts: $x"
ssh-keyscan $x >> $HOME/.ssh/known_hosts
fi
done
fi
# Run the original jenkins script
source /usr/local/bin/jenkins.sh