-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-tasks.sh
executable file
·174 lines (155 loc) · 5.58 KB
/
install-tasks.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
# su - core
export RUNMODE=$1
export VERSION=$2
sudo sysctl -w kernel.printk="2 4 1 7" > /dev/null
# If the first parameter was empty, assume no parameters were given
if [ "$RUNMODE" == "" ]; then
export RUNMODE="normal"
echo "RUNMODE WAS BLANK"
else
if [ "$RUNMODE" != "normal" ]; then #runmode is not normal
if [ "$RUNMODE" != "jenkins" ]; then #runmode is also not jenkins
# hardcode runmode to normal, take what was passed in as the version
export RUNMODE="normal"
export VERSION=$1
else
#runmode is jenkins
echo "RUNMODE = $RUNMODE" > /dev/null
echo "VERSION = $VERSION" > /dev/null
fi
else
#runmode is normal
echo "RUNMODE = $RUNMODE" > /dev/null
echo "VERSION = $VERSION" > /dev/null
fi
fi
if [ "$VERSION" == "" ]; then
export VERSION="latest"
fi
# echo "RUNMODE = $RUNMODE"
# echo "VERSION = $VERSION"
trap '' INT TSTP
cd /home/core
sudo mkdir /mnt/rtfs
# sudo mkdir /mnt/cdrom
# sudo mount /dev/cdrom /mnt/cdrom
sudo cp /mnt/cdrom/coreos/oem-data/conf-$RUNMODE-$VERSION.json /home/core/conftemplate.json
sudo chown core:core /home/core/conftemplate.json
cont=0
isvmware=0
export SSH_RSA=$(cat /mnt/cdrom/coreos/oem-data/ssh-key.pem.pub)
echo "Your CoreOs deployment is about to begin."
echo "{" > /home/core/conf.json
echo " \"ignition\": { \"version\": \"2.1.0\" }," >> /home/core/conf.json
echo " \"systemd\": {" >> /home/core/conf.json
echo " \"units\": [" >> /home/core/conf.json
echo " {" >> /home/core/conf.json
echo " \"name\": \"update-engine.service\"," >> /home/core/conf.json
echo " \"mask\": true" >> /home/core/conf.json
echo " }," >> /home/core/conf.json
echo " {" >> /home/core/conf.json
echo " \"name\": \"locksmithd.service\"," >> /home/core/conf.json
echo " \"mask\": true" >> /home/core/conf.json
echo " }," >> /home/core/conf.json
echo " {" >> /home/core/conf.json
echo " \"name\": \"configure.service\"," >> /home/core/conf.json
echo " \"enable\": true," >> /home/core/conf.json
echo " \"contents\": \"[Unit]\nDescription=A configuration unit used for deployment\nType=idle\n\n[Service]\nExecStart=/usr/bin/script -c \\\"/home/core/post-install-tasks.sh normal release\\\" /var/log/platform/install-configure.log\n\n[Install]\nWantedBy=multi-user.target\"" >> /home/core/conf.json
echo " }" >> /home/core/conf.json
echo " ]" >> /home/core/conf.json
echo " }," >> /home/core/conf.json
echo " \"storage\": {" >> /home/core/conf.json
echo " \"files\": [" >> /home/core/conf.json
echo " {" >> /home/core/conf.json
echo " \"filesystem\": \"root\"," >> /home/core/conf.json
echo " \"path\": \"/etc/coreos/update.conf\"," >> /home/core/conf.json
echo " \"contents\": {" >> /home/core/conf.json
echo " \"source\": \"data:,%0AREBOOT_STRATEGY%3D%22off%22\"," >> /home/core/conf.json
echo " \"verification\": {}" >> /home/core/conf.json
echo " }," >> /home/core/conf.json
echo " \"mode\": 420," >> /home/core/conf.json
echo " \"user\": {}," >> /home/core/conf.json
echo " \"group\": {}" >> /home/core/conf.json
echo " }" >> /home/core/conf.json
echo " ]" >> /home/core/conf.json
echo " }," >> /home/core/conf.json
echo " \"passwd\": {" >> /home/core/conf.json
echo " \"users\": [" >> /home/core/conf.json
echo " {" >> /home/core/conf.json
echo " \"name\": \"coreuser\"," >> /home/core/conf.json
echo " \"sshAuthorizedKeys\": [" >> /home/core/conf.json
echo " \"${SSH_RSA}\"" >> /home/core/conf.json
echo " ]," >> /home/core/conf.json
echo " \"create\": {" >> /home/core/conf.json
echo " \"groups\": [" >> /home/core/conf.json
echo " \"sudo\"," >> /home/core/conf.json
echo " \"docker\"" >> /home/core/conf.json
echo " ]" >> /home/core/conf.json
echo " }" >> /home/core/conf.json
echo " }" >> /home/core/conf.json
echo " ]" >> /home/core/conf.json
echo " }" >> /home/core/conf.json
echo "}" >> /home/core/conf.json
cont=0
isvmware=0
if [ "$RUNMODE" == "jenkins" ]; then
sudo coreos-install -d /dev/sda -i /home/core/conf.json -o vmware_raw -f /mnt/cdrom/coreos/oem-data/coreos_production_vmware_raw_image.bin.bz2
cont=1
isvmware=1
else
echo " Is this product deploying to a VMWare environment? (yes/no)"
while (( cont == 0 ))
do
read input
if [ "$input" == "yes" ]
then
sudo coreos-install -d /dev/sda -i /home/core/conf.json -o vmware_raw -f /mnt/cdrom/coreos/oem-data/coreos_production_vmware_raw_image.bin.bz2
cont=1
isvmware=1
else
if [ "$input" == "no" ]
then
sudo coreos-install -d /dev/sda -i /home/core/conf.json -f /mnt/cdrom/coreos/oem-data/coreos_production_image.bin.bz2
cont=1
isvmware=0
else
cont=0
echo "Could not interpret answer : " $input ". Please only input yes or no."
echo " Is this product deploying to a VMWare environment? (yes/no)"
fi
fi
done
fi
# After install, mount rootfs and copy container and service files
sudo mount /dev/sda9 /mnt/rtfs
sudo cp /mnt/cdrom/coreos/oem-data/kp.conf /mnt/rtfs/etc/sysctl.d/kp.conf
cd /mnt/rtfs/home/core
sudo cp /mnt/cdrom/coreos/oem-data/post-install-tasks.sh post-install-tasks.sh
sudo chown core:core post-install-tasks.sh
if [ $isvmware == 1 ]
then
echo "Rebooting"
echo "5"
sleep 1
echo "4"
sleep 1
echo "3"
sleep 1
echo "2"
sleep 1
echo "1"
sleep 1
else
echo "Powering Down"
echo "5"
sleep 1
echo "4"
sleep 1
echo "3"
sleep 1
echo "2"
sleep 1
echo "1"
sleep 1
fi