summaryrefslogtreecommitdiffstats
path: root/setup-arch-vm
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2014-01-26 16:16:08 +0100
committerFlorian Pritz <bluewind@xinu.at>2014-01-26 16:16:08 +0100
commitf5098b64574bb2b3454d100d1ce6d075aff7580c (patch)
tree61cc05706b0dfe75a42a55d2a6cc56a49c77fe51 /setup-arch-vm
parentcc40f90a5a323758097c99767f24df4dae48fda4 (diff)
downloadbin-f5098b64574bb2b3454d100d1ce6d075aff7580c.tar.gz
bin-f5098b64574bb2b3454d100d1ce6d075aff7580c.tar.xz
setup-arch-vm: use avahi for automatic dns; configure hostname from
libvirt domain Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'setup-arch-vm')
-rw-r--r--setup-arch-vm55
1 files changed, 49 insertions, 6 deletions
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 <<EOF >/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 <<EOF > /mnt/etc/modprobe.d/modprobe.conf
-blacklist cirrus
+cat <<EOF >/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