5
#check our internal maas network settings. Fall back to 10.14.
7
if [ -f /etc/hp-proliant.conf ]; then
8
PREFIX=$(awk -F '[:]' NR==1'{print $3"."$4}' /etc/hp-proliant.conf)
14
if [ "$(id -u ubuntu)" != "1000" ]; then
15
echo "ERROR: Read the docs; a proper hp-proliant setup requires the default user to be [ubuntu]" 1>&2
23
echo "ERROR: Read the docs; a hp-proliant setup requires the hostname to be in the form [c*n*]" 1>&2
27
# TODO: Check that the AMTs are on static IPs
28
# TODO: Check dual hard drives, which one is which
29
# TODO: Ensure we have two interfaces, one internal, one external
33
echo "debconf maas/default-maas-url string ${PREFIX}.4.1" | debconf-set-selections -
34
echo "debconf maas-cluster-controller/maas-url string http://${PREFIX}.4.1/MAAS" | debconf-set-selections -
35
echo "debconf maas/installation-note boolean true" | debconf-set-selections -
36
echo "debconf iptables-persistent/autosave_done boolean true" | debconf-set-selections -
37
echo "debconf iptables-persistent/autosave_v4 boolean true" | debconf-set-selections -
38
echo "debconf iptables-persistent/autosave_v6 boolean true" | debconf-set-selections -
42
# modprobe 8021q || true
43
# sed -i -e "/8021q/d" /etc/modules || true
44
# echo "8021q" >> /etc/modules
45
# Set up the two network interfaces
46
external_interface=$(ip route ls | grep ^default | awk '{print $5}')
48
for interface in $(ifconfig -a -s | grep -v ^Iface | awk '{print $1}'); do
57
internal_interface="$interface"
63
[ -z "$internal_interface" ] && internal_interface=eth0
65
default_mac=$(ifconfig "$internal_interface" | grep "^$internal_interface" | sed -e "s/.*HWaddr //")
66
# Tell NetworkManager to piss off
67
# sed -i -e "/^unmanaged-devices=mac:$default_mac$/d" /etc/NetworkManager/NetworkManager.conf
68
# cat >>/etc/NetworkManager/NetworkManager.conf <<EOF
70
#unmanaged-devices=mac:$default_mac
72
# invoke-rc.d network-manager restart
73
cp /etc/network/interfaces /etc/network/interfaces.orig
74
cat >/etc/network/interfaces <<EOF
76
iface lo inet loopback
78
auto $external_interface
79
iface $external_interface inet dhcp
81
auto $internal_interface
82
iface $internal_interface inet manual
88
broadcast ${PREFIX}.255.255
89
bridge_ports $internal_interface
95
# VLAN 1, Network configuration network
97
#iface eth0.1 inet static
102
#broadcast 10.255.255.255
105
ifdown --force $internal_interface || true
106
ifdown --force br0 || true
107
ifup $internal_interface
109
# Wait a moment for the network to normalize
110
echo "INFO: Conservatively sleeping 30 seconds to ensure networking has settled"
114
setup_external_drive() {
115
# External drive must be:
116
# a) partitioned into 1 big partition
119
root_disk=$(mount | grep " on / " | awk '{print $1}' | sed -e "s/[0-9]\+$//")
120
# Find biggest non-root disk
121
ext_disk=$(fdisk -l | grep "^Disk /" | grep -v $root_disk | sort -k4 -n -r | awk '{print $2}' | awk -F: '{print $1}')
122
partition="${ext_disk}1"
123
if [ -b "$ext_disk" ]; then
124
if [ ! -b "$partition" ]; then
125
# Create the partition, if it doesn't exist already
133
mkfs.ext4 "$partition"
135
sed -i -e "/ \/srv/d" /etc/fstab
136
# Add the fstab entry
137
uuid=$(blkid -s UUID -o value "$partition")
138
echo "UUID=$uuid /srv ext4 defaults 1 1" >> /etc/fstab
140
umount $partition || true
148
#setup_external_drive