setup basic networking

by yann
25 deployments · 12 still active · last rev. 6 years ago

- sets the hostname of the machine
- sets its private ip (assumes netmask is always 255.255.128.0)

Compatible with: No distros currently supported
						#!/bin/bash
# <udf name="privip" label="private ip to install to eth0:0">
# <udf name="hostname" label="hostname">

logfile=/root/stackscript.log
echo "Setting Hostname to ${HOSTNAME}" >> $logfile
echo ${HOSTNAME} > /etc/hostname
hostname -F /etc/hostname

short=`echo ${HOSTNAME} | cut -d. -f1`
ip=`ip addr show label eth0 | grep 'inet ' | cut -d/ -f1 | awk '{print $2}'`
echo "Setting ip to $ip for $short" >> $logfile
echo -e "\n# our own entry\n${ip} ${HOSTNAME} ${short}" >> /etc/hosts

echo "Setting private interface address to ${PRIVIP}" >> $logfile
cat >>/etc/network/interfaces <<EOF

auto eth0:0
iface eth0:0 inet static
 address $PRIVIP
 netmask 255.255.128.0
EOF

/etc/init.d/networking restart