-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.tftpl
More file actions
37 lines (31 loc) · 1.79 KB
/
setup.tftpl
File metadata and controls
37 lines (31 loc) · 1.79 KB
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
set -x
exec > >(tee /var/log/user-data.log|logger -t user-data ) 2>&1
echo BEGIN
date '+%Y-%m-%d %H:%M:%S'
my_nameserver=$(ifconfig eth0 | grep "inet " | awk '{print $2}')
my_ip=$(ifconfig eth0 | grep "inet " | awk '{print $2}')
my_default_gw=$(ip route show | grep default | awk '{print $3}')
my_cidr=$(awk -F. '{
split($0, octets)
for (i in octets) {
mask += 8 - log(2**8 - octets[i])/log(2);
}
print mask
}' <<< $(ifconfig eth0 | grep "inet " | awk '{print $4}'))
sudo su
export ITP_HOME=/opt/itp
export CATALINA_HOME=/opt/apache-tomcat
chmod +x /opt/itp_global_conf/auto_deploy.sh
sed -i 's/^hosts:.*/hosts: files dns/' /etc/nsswitch.conf
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
admin_registration_password=$(/usr/local/bin/aws secretsmanager get-secret-value --secret-id ${admin_registration_password_secret_arn} --query SecretString --output text)
ssh_password=$(/usr/local/bin/aws secretsmanager get-secret-value --secret-id ${admin_ssh_password_secret_arn} --query SecretString --output text)
/opt/itp_global_conf/auto_deploy.sh --hostname "$(hostname)" --ip-address "$my_ip" --dns-servers "$my_nameserver" --registration-password "$admin_registration_password" --cidr "$my_cidr" --default-gateway "$my_default_gw" --machine-type "Admin"
echo $ssh_password | passwd --stdin cbadmin
# Allow using this host as jump box
sed -i 's/.*AllowTcpForwarding.*/AllowTcpForwarding yes/g' /etc/ssh/sshd_config
systemctl restart sshd
#/opt/itp_global_conf/auto_deploy_cloud.sh --hostname "$(hostname)" --dhcp 1 --ip-address "$my_ip" --dns-servers "$my_nameserver" --registration-password "$password" --cidr "$my_cidr" --default-gateway "$my_default_gw" --machine-type "Admin"