From f5098b64574bb2b3454d100d1ce6d075aff7580c Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 26 Jan 2014 16:16:08 +0100 Subject: setup-arch-vm: use avahi for automatic dns; configure hostname from libvirt domain Signed-off-by: Florian Pritz --- setup-arch-vm | 55 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 6 deletions(-) (limited to 'setup-arch-vm') diff --git a/setup-arch-vm b/setup-arch-vm index 2314645..4444591 100644 --- a/setup-arch-vm +++ b/setup-arch-vm @@ -4,12 +4,32 @@ set -e newuser="flo" disk=/dev/vda +server=192.168.123.1 die() { echo "$@" exit 1 } +get_url() { + local url=$1 + local default=$2 + wget -q -O - "$url" || echo "$default" +} + +cmdline_arg() { + local name=$1 + local default=$2 + local param + for param in $(< /proc/cmdline); do + case "${param}" in + $name=*) echo "${param##*=}" ; return 0 ;; + esac + done + + echo $default +} + grep -qE '^flags\s+: .* hypervisor( |$)' /proc/cpuinfo || die "Not running in hypervisor. aborting automatic setup" dhcpcd eth0 @@ -22,9 +42,12 @@ cat </etc/pacman.d/mirrorlist Server = http://mirror.server-speed.net/\$repo/os/\$arch EOF -pacstrap /mnt base syslinux sudo openssh haveged htop git zsh screen dnsutils vim +pacstrap /mnt base syslinux sudo openssh haveged htop git zsh screen dnsutils vim net-tools avahi genfstab -p /mnt >> /mnt/etc/fstab -echo "archvm" > /mnt/etc/hostname + +mymac=$(ip addr show dev eth0 | sed -rn 's#^\s+link/ether ([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}).*$#\1#p') + +get_url "http://$server/hostnames/$mymac" "archvm" > /mnt/etc/hostname ln -s /usr/share/zoneinfo/Europe/Athens /mnt/etc/localtime echo "en_US.UTF-8 UTF-8" > /mnt/etc/locale.gen arch-chroot /mnt locale-gen @@ -44,12 +67,32 @@ TIMEOUT 50 LABEL arch MENU LABEL Arch Linux LINUX ../vmlinuz-linux - APPEND root=${disk}1 ro logo.nologo elevator=deadline console=tty0 console=ttyS0 nomodeset + APPEND root=${disk}1 rw logo.nologo elevator=deadline console=tty0 console=ttyS0 nomodeset INITRD ../initramfs-linux.img EOF -cat < /mnt/etc/modprobe.d/modprobe.conf -blacklist cirrus +cat </mnt/etc/avahi/avahi-daemon.conf +[server] +browse-domains= +use-ipv4=yes +use-ipv6=yes +ratelimit-interval-usec=1000000 +ratelimit-burst=1000 + +[wide-area] +enable-wide-area=no + +[publish] + +[reflector] + +[rlimits] +rlimit-core=0 +rlimit-data=4194304 +rlimit-fsize=0 +rlimit-nofile=768 +rlimit-stack=4194304 +rlimit-nproc=3 EOF arch-chroot /mnt mkinitcpio -p linux @@ -73,7 +116,7 @@ arch-chroot /mnt passwd -d $newuser curl https://git.server-speed.net/users/flo/bin/plain/init_new_user.sh | arch-chroot /mnt sudo -u $newuser bash arch-chroot /mnt chsh -s /bin/zsh $newuser -arch-chroot /mnt systemctl enable sshd multi-user.target haveged dhcpcd.service +arch-chroot /mnt systemctl enable multi-user.target sshd haveged dhcpcd avahi-daemon sync systemctl reboot -- cgit v1.2.3-24-g4f1b