-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprimaryfb
73 lines (60 loc) · 1.98 KB
/
primaryfb
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
65
66
67
68
69
70
71
72
73
#!bin/bash
ws_ip=10.0.2.3
db_ip=10.0.5.3
if [[-e /root/started ]]; then
echo "Firstboot has already started"
exit
fi
touch /root/started
echo $IFACE >> /root/started
if [[ $IFACE == lo ]]; then
echo "loopback is up"
exit
fi
ssh-keygen -f /root/.ssh/id_rsa -t rsa -N ''
sudo sshpass -p "juniper123" ssh-copy-id -o StrictHostKeyChecking=no -i /root/.ssh/id_rsa.pub root@$ws_ip
echo "ssh pass completed"
rsync -r /var/www/* root@$ws_ip:/var/www/.
echo "rsync completed"
sudo ssh root@$ws_ip 'sudo service apache2 restart'
echo "remotely executed apache restart"
sed -i "/host/c\host = '$ws_ip'," /etc/lsyncd/lsyncd.conf.lua
echo "set host in lsyncd config file"
service lsyncd start
echo "started the lsyncd process"
service lsyncd restart
#Get my ip address
MY_IFACE=`route | grep '^default' | grep -o '[^ ]*$'`
MY_IP=`/sbin/ifconfig $MY_FACE $1 | grep "inet" | awk -F' ' '{print $2}'| awk -F ':' '{print $2}'|awk "NR==1"`
echo "my ip:"
echo $MY_IP
BASE_URL="http://$MY_IP"
#Set the hostname entry in /etc/hosts
echo "$MY_IP jnpr-example.com ws-primary" >> /etc/hosts
echo "127.0.0.1 ws-primary" >> /etc/hosts
#arp-scan --interface=ens3 10.0.5.3-10.0.5.253 > data_db.txt
#awk '{print $1}' data_db.txt |head -n -3|tail -n +3 >ip_db.txt
#db_ip=`awk "NR==1" ip_db.txt`
#echo "db ip"
#echo $db_ip
#Databse info
DB_USER="wpuser"
DB_PASS="password"
DB_NAME="wordpress"
DB_HOST=$db_ip
DEST="jnpr-example.com"
SITE_PATH=/var/www/html/jnpr-example.com/public_html/
# Install wordpress
sudo -u www-data -s -- <<EOF
echo 'Updating jnpr-example.com...'
wp core config --path=$SITE_PATH --dbhost=$DB_HOST --dbname=$DB_NAME --dbuser=$DB_USER --dbpass=$DB_PASS --extra-php <<PHP
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);
define('WP_MEMORY_LIMIT', '256M');
PHP
wp core install --path=$SITE_PATH --url="http://jnpr-example.com" --title="Contrail Example" --admin_user="adminuser" --admin_password="password" [email protected]
echo
EOF
#Delete me
rm $0