This repository has been archived by the owner on Jan 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathoneClickDeploy.sh
executable file
·64 lines (45 loc) · 2.04 KB
/
oneClickDeploy.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
SHOULD_WE_SEND="False"
SSH_KEY="/root/.ssh/id_rsa"
LOGSERV_NAME="tincmaster.wan.bsf-intranet.org"
sync_log=`echo $1 | cut -d= -f1`
value1=`echo $1 | cut -d= -f2`
ideascube_id=`echo $2 | cut -d= -f1`
value2=`echo $2 | cut -d= -f2`
timezone=`echo $3 | cut -d= -f1`
value3=`echo $3 | cut -d= -f2`
## Push log server SSH fingerprint to known hosts
ssh-keyscan -H $LOGSERV_NAME >> /etc/ssh/ssh_known_hosts
echo "$sync_log"
if [ "$sync_log" = sync_log ] && [ "$value1" = True ] && [ ! -f "$SSH_KEY" ]; then
SHOULD_WE_SEND="True"
echo -e "\n\n\n" | ssh-keygen -t rsa -f /root/.ssh/id_rsa -b 4096 -C "[email protected]" -N ""
ssh-copy-id -o StrictHostKeyChecking=no ansible@$LOGSERV_NAME
elif [ "$sync_log" = sync_log ] && [ "$value1" = True ] && [ -f "$SSH_KEY" ]; then
SHOULD_WE_SEND="True"
elif [ "$sync_log" = "sync_log" ] && [ "$value1" = False ]; then
SHOULD_WE_SEND="False"
else
echo -e "
YOU HAVE TO BE ROOT TO LAUNCH THIS SCRIPT !
Usage : ./oneClickDeploy.sh sync_log=True ideascube_id=kb_mooc_cog timezone=Europe/Paris
sync_log=True|False : Whether send or not log system to a central server. A server with SSH access is required in this case
ideascube_id=File_Name : Must be the same name as the one used for the ideascube configuration file
timezone=Europe/Paris : The timezone
"
exit 0;
fi
echo "[+] Install ansible..."
sed -i -e '/^deb cdrom/d' /etc/apt/sources.list
apt-get update
apt-get install -y python-pip git python-dev libffi-dev libssl-dev gnutls-bin
pip install ansible==1.9.4 markupsafe
echo "[+] Clone ansiblecube repo..."
mkdir --mode 0755 -p /var/lib/ansible/local
cd /var/lib/ansible/
git clone https://github.com/ideascube/ansiblecube.git local
[ ! -d /etc/ansible ] && mkdir /etc/ansible
cp /var/lib/ansible/local/hosts /etc/ansible/hosts
echo "[+] Run globalInstall playbook..."
/usr/local/bin/ansible-pull -d /var/lib/ansible/local -i hosts -U https://github.com/ideascube/ansiblecube.git globalInstall.yml --extra-vars "sync_log="$SHOULD_WE_SEND" ideascube_id=$value2 timezone=$value3"
echo "[+] Done."