forked from vsandovalj/cPodFactory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprep_cpod.sh
executable file
·42 lines (31 loc) · 1.21 KB
/
prep_cpod.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
38
39
40
41
42
#!/bin/bash
. ./env
[ "$1" == "" ] && echo "usage: $0 <name_of_cpod>" && exit 1
HOSTS=/etc/hosts
GEN_PASSWD=$( ./extra/passwd_for_cpod.sh ${1} )
main() {
echo "=== Preparing cPod called '$1'."
SHELL_SCRIPT=prep_and_add_esx.sh
SCRIPT_DIR=/tmp/scripts
SCRIPT=/tmp/scripts/$$
mkdir -p ${SCRIPT_DIR}
cp ${COMPUTE_DIR}/${SHELL_SCRIPT} ${SCRIPT}
sed -i -e "s/###ROOT_PASSWD###/${ROOT_PASSWD}/" -e "s/###GEN_PASSWD###/${GEN_PASSWD}/" ${SCRIPT}
CPOD_NAME="cpod-$1"
CPOD_NAME_LOWER=$( echo ${CPOD_NAME} | tr '[:upper:]' '[:lower:]' )
#IP=$( cat ${HOSTS} | grep ${CPOD_NAME_LOWER} | cut -f1 )
#STATUS=1
#while [ ${STATUS} -gt 0 ]
#do
# echo "Waiting for cPodRouter of ${CPOD_NAME_LOWER}..."
# STATUS=$( ping -c 1 ${CPOD_NAME_LOWER} 2>&1 > /dev/null ; echo $? )
# STATUS=$(expr $STATUS)
#done
./compute/wait_ip.sh ${CPOD_NAME_LOWER}
sshpass -p "${ROOT_PASSWD}" scp ~/.ssh/id_rsa.pub root@${CPOD_NAME_LOWER}:/root/.ssh/authorized_keys
scp -o StrictHostKeyChecking=no ${SCRIPT} root@${CPOD_NAME_LOWER}:./${SHELL_SCRIPT}
ssh -o StrictHostKeyChecking=no root@${CPOD_NAME_LOWER} "./${SHELL_SCRIPT}"
rm ${SCRIPT}
}
main $1