forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hostprep.sh
executable file
·77 lines (61 loc) · 2.1 KB
/
hostprep.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
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
#Created by Kendrick Coleman of the EMC {code} Team and Licensed under MIT.
#Please visit us at emccode.github.io
#This script will prepare an Ubuntu Host for running an ECS container.
#This has been properly tested with Docker Machine's default image in AWS.
#Read in variable arguments from command line
if [ -z "$1" ]; then
echo "You forgot to specify 3 IP Addresses"
exit 1
fi
case "$1" in
*\ * )
echo "Please remove all spaces and have IP addresses as comma seperated values"
exit 1
;;
esac
VOL="$2"
if [ -z "$2" ]; then
VOL="xvdf"
echo "Using xvdf as Volume mount"
fi
#create the seeds file
echo "Creating Seeds File"
printf '%s' $1 > seeds
#create network.json file
echo "Creating The network.json File"
hn=$(hostname)
ip=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
printf '{"private_interface_name":"eth0","public_interface_name":"eth0","hostname":"%s","public_ip":"%s"}' $hn $ip > network.json
#create some folders, set permissions, and format the attached volume
echo "Creating /ecs/uuid-1 folder"
mkdir -p /ecs/uuid-1
echo "Creating symlink"
ln -s /bin/grep /usr/bin/grep
echo "Downloading additional_prep.sh"
curl -O https://raw.githubusercontent.com/emccode/ecs-dockerswarm/master/additional_prep.sh
echo "Changing additional_prep.sh Permissions"
chmod 777 additional_prep.sh
echo "Starting the additional prep on attached volume"
./additional_prep.sh /dev/$VOL
echo "Changing /ecs Permissions"
chown -R 444 /ecs
echo "Creating /host/data folder"
mkdir -p /host/data
echo "Creating /host/files folder"
mkdir -p /host/files
echo "Copying network.json to /host/data"
cp network.json /host/data
echo 'Copying seeds to /host/files'
cp seeds /host/files
echo "Changing /host Permissions"
chown -R 444 /host
echo "Creating /var/log/vipr/emcvipr-object folder"
mkdir -p /var/log/vipr/emcvipr-object
echo "Changing /var/log/vipr/emcvipr-object Permissions"
chown 444 /var/log/vipr/emcvipr-object
echo "Creating /data folder"
mkdir /data
echo "Changing /data Permissions"
chown 444 /data
echo "Host has been successfully prepared"