-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
startup
42 lines (34 loc) · 989 Bytes
/
startup
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
#!/bin/bash
metadata_base="http://metadata.google.internal/computeMetadata/v1"
hostname=`curl -H "Metadata-Flavor: Google" $metadata_base/instance/hostname |cut -d. -f1`
fleet=`echo $hostname |cut -d- -f1`
tier=`echo $hostname |cut -d- -f2`
metro=`echo $hostname |cut -d- -f3`
echo "$fleet - $tier - $metro"
HC_ROOT=/opt/hyeoncheon
# common: install packages
apt update && \
apt install -y traceroute && \
apt install -y mtr-tiny && \
apt install -y iputils-ping && \
apt install -y tcpdump && \
apt clean
case "$fleet" in
tester)
echo "This is Tester. Do nothing."
;;
prober)
mkdir -p $HC_ROOT/bin
curl -s http://master/bogo -o $HC_ROOT/bin/bogo
chmod 755 $HC_ROOT/bin/bogo
sysctl -w net.ipv4.ping_group_range="0 2147483647"
echo "$HC_ROOT/bin/bogo |logger -t bogo" |at now
echo "reboot" |at 02:00 # time in UTC = 11:00 KST
# using at command as workaround for defunct
;;
*)
echo "could not determined my fleet. abort!"
exit 1
esac
echo "done"
exit 0