All pastes #196757 Raw Edit

asyd

public text v1 · immutable
·published 2006-10-10 21:15 UTC
rendered paste body
#!/bin/zsh

#
# Dedibox, post-install script
# Bruno Bonfils, <asyd@asyd.net>
#

# if [ -r /etc/hostname.vel0 ] && exit 0

set -x

buffer="            value='-z 1,88.191.252.7,88.191.252.0,255.255.255.0,88.191.252.1'"

buffer=(${(s:,:)${buffer##*-z }%\'})

ID=$buffer[1]
NETWORK=$buffer[2]
ADDRESS=$buffer[3]
GATEWAY=$buffer[4]


# write /etc/nodename and /etc/hostname.vel0
echo sd-$ID > /etc/nodename
echo sd-$ID > /etc/hostname.vel0

# write /etc/hosts
echo 127.0.0.1    localhost log > /etc/hosts
echo $ADDRESS     sd-$ID sd-$ID.dedibox.fr >> /etc/hosts

# write /etc/defaultrouter
echo $GATEWAY > /etc/defaultrouter

# write /etc/inet/netmasks
echo $NETWORK   $NETMASK > /etc/inet/netmasks

# Enable the network...
ifconfig vel0 plumb
ifconfig vel0 $ADDRESS netmask $NETMASK up
route add default $GATEWAY

# Disable ssh
svcadm disable ssh

# Purge hosts keys
rm /etc/ssh/ssh_host_dsa_key
rm /etc/ssh/ssh_host_rsa_key
rm /etc/ssh/ssh_host_dsa_key.pub
rm /etc/ssh/ssh_host_rsa_key.pub

# Generate new keys
/lib/svc/method/sshd -c

# Start ssh
svcadm enable ssh