-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcustomization.sh
More file actions
executable file
·65 lines (53 loc) · 1.57 KB
/
customization.sh
File metadata and controls
executable file
·65 lines (53 loc) · 1.57 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
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
#!/bin/bash
set -ex
#Redirect stdout and stderr
#We need to append to logs, to get output from both
#parent process and child process
exec >> customization.log
exec 2>> customization.err
HOSTNAME=$1
IP=$2
SUBNET=$3
GATEWAY=$4
DNS=$5
if [ -z "$SUDO_COMMAND" ]
then
sudo /sbin/ip a a $IP/$SUBNET dev eth0
sudo /sbin/ip link set dev eth0 up
sudo /sbin/ip r a default via $GATEWAY
echo "doing git update"
( cd vmware-bootstrap-puppet/ && git pull )
echo "relaunching with elevated previliges"
sudo $0 $*
exit 0
fi
rm -rf /etc/udev/rules.d/70-persistent-net.rules
echo $HOSTNAME > /etc/hostname
/bin/cat > /etc/network/interfaces <<EOF
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address IPHERE
netmask SUBNETHERE
gateway GWHERE
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers DNSHERE
EOF
/bin/sed -e "s/IPHERE/$2/g"\
-e "s/SUBNETHERE/$3/g"\
-e "s/GWHERE/$4/g"\
-e "s/DNSHERE/$5/g" -i /etc/network/interfaces
export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -y
# Delete temp template hostname
/bin/sed '/127.0.1.1.*kimo.sw.in/d' -i /etc/hosts
# Add real hostname
echo "$IP $HOSTNAME" >> /etc/hosts
#Actually enable puppet to start on next boot
[ -e /tmp/dontenablepuppet ] || sed -i -e 's/=no/=yes/' /etc/default/puppet
reboot &