summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-12-13 15:07:54 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2015-12-13 15:07:54 +0100
commit1d89ad1c02fd26642106783e2ebf9fa6858d5157 (patch)
treefcb8b8233cdbbc36d6315131853cc108797d96d8
parentbd716eb2737a7bb9de4a595319fa37efddd1b58d (diff)
downloadbiruda-1d89ad1c02fd26642106783e2ebf9fa6858d5157.tar.gz
biruda-1d89ad1c02fd26642106783e2ebf9fa6858d5157.tar.bz2
added automatic archlinux installation (unsorted)
-rw-r--r--unsorted/archauto/BUGS0
-rw-r--r--unsorted/archauto/LINKS23
-rw-r--r--unsorted/archauto/README116
-rw-r--r--unsorted/archauto/TODOS10
-rwxr-xr-xunsorted/archauto/archauto.sh126
-rw-r--r--unsorted/archauto/clean.sh30
-rwxr-xr-xunsorted/archauto/copy_local_packages.sh35
-rw-r--r--unsorted/archauto/tftproot/README1
-rw-r--r--unsorted/archauto/tftproot/boot/x86_64/.placeholder0
-rw-r--r--unsorted/archauto/tftproot/pxelinux.cfg/01-52-54-00-12-34-5617
10 files changed, 358 insertions, 0 deletions
diff --git a/unsorted/archauto/BUGS b/unsorted/archauto/BUGS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/unsorted/archauto/BUGS
diff --git a/unsorted/archauto/LINKS b/unsorted/archauto/LINKS
new file mode 100644
index 0000000..7b0df12
--- /dev/null
+++ b/unsorted/archauto/LINKS
@@ -0,0 +1,23 @@
+Links
+-----
+
+https://wiki.archlinux.org/index.php/Archiso
+https://wiki.archlinux.org/index.php/PXE
+https://wiki.archlinux.org/index.php/Archiso_as_pxe_server
+https://kroweer.wordpress.com/2011/09/07/creating-a-custom-arch-linux-live-usb/
+http://pxeknife.erebor.org/
+https://github.com/altercation/archblocks
+https://bbs.archlinux.org/viewtopic.php?id=149597
+https://github.com/jdodds/aif
+https://wiki.archlinux.org/index.php/Autostarting
+https://wiki.archlinux.org/index.php/Automatic_login_to_virtual_console
+https://wiki.archlinux.org/index.php/Official_Arch_Linux_Install_Guide
+https://bbs.archlinux.org/viewtopic.php?id=148790 (text mode boot from archiso)
+http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=How_to_run_OVMF (UEFI BIOS)
+https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/X64/Shell_Full.efi
+https://wiki.archlinux.org/index.php/GRUB2
+http://www.brianparsons.net/Best-Practices-For-Using-Arch-Linux-on-Servers/
+
+Other projects
+--------------
+https://github.com/roman-neuhauser/anarchinst
diff --git a/unsorted/archauto/README b/unsorted/archauto/README
new file mode 100644
index 0000000..e81df79
--- /dev/null
+++ b/unsorted/archauto/README
@@ -0,0 +1,116 @@
+Requirements
+------------
+
+pacman -S archiso qemu syslinux darkhttpd
+
+ArchISO and optional local cache
+--------------------------------
+
+# We build a live Arch boot CD.
+
+export http_proxy=http://192.168.1.12:3128
+mkdir archlive
+cp -r /usr/share/archiso/configs/releng/* archlive/.
+cd archlive
+
+# always had problem with keys, switch of signing (not good, I know)
+sed -i 's/^SigLevel.*/SigLevel = Never/g' pacman.conf
+
+# build the live CDs, this take quite a while
+./build.sh -v build single
+
+cd ..
+
+# We mount it and make it accessible over a webserver:
+
+mount -o loop,ro archlive/out/archlinux-2014.05.18-dual.iso archiso
+darkhttpd . --port 8080 &
+
+# copy packages from host system (there is no need to build a full-fledged
+# mirror now)
+./copy_local_packages.sh
+
+TFTP root
+--------
+
+Copy PXE bootstrap files to a TFTP root:
+
+cp archiso/arch/boot/x86_64/vmlinuz tftproot/boot/x86_64/
+cp archiso/arch/boot/x86_64/archiso.img tftproot/boot/x86_64/
+
+cp /usr/lib/syslinux/bios/pxelinux.0 tftproot
+cp /usr/lib/syslinux/bios/ldlinux.c32 tftproot
+
+Custom software from AUR
+------------------------
+
+Build the following packages from AUR:
+
+rm -rf INSTALL
+mkdir INSTALL
+cd install
+yaourt -G qdbm
+cd qdbm
+makepkg --asroot -if
+cd ..
+yaourt -G cfengine
+cd cfengine
+makepkg --asroot -if
+cd ..
+
+Put them into a local repository 'aba':
+
+mkdir -p aba/os/x86_64/
+cp INSTALL/*/*pkg.tar.xz aba/os/x86_64/.
+
+mkdir -p aba/os/x86_64/
+repo-add aba/os/x86_64/aba.db.tar.gz aba/os/x86_64/*
+
+Install Archlinux
+-----------------
+
+Create a Qemu image with Archlinux (automatically). The main
+work is done by the 'archauto.sh' script which is given to
+the archiso kernel as script to execute after auto-login:
+
+qemu-img create arch.img 4G
+
+qemu-system-x86_64 -hda arch.img -net nic \
+ -net user,tftp=$PWD/tftproot,bootfile=pxelinux.0 \
+ -m 386 \
+ -machine accel=kvm -redir tcp:222::22 \
+ -display curses
+# -nographic
+
+# remote install (manually), then follow docu
+# (this gives a rough idea of what should be automatized)
+passwd
+systemctl start sshd
+
+# automatic installation frameworks for ArchLinux
+# - AIF
+# - ArchBlocks
+# - ArchBang
+# - backpac: snapshots, not really the cfengine philosophy
+# load them after boot of base system or customize the installation medium?
+
+# EFI, later
+# wget 'http://wiki.qemu.org/download/efi-bios.tar.bz2'
+# qemu with efi
+# efi partition etc
+
+# manual minimal installation or "what's needed in a CFengine bootstrap
+# script"?
+# - boot loader
+# - grub2
+# - virtio ramdisk hooks
+# - partitioning
+# - sgdisk scripting (ArchBlocks does it nicely)
+# - RAID, LVM, LUKS and friends
+# - size, swap, filesystem, chunking
+# - file system layout
+
+# via cfengine
+
+# packages net-tools gdisk
+
diff --git a/unsorted/archauto/TODOS b/unsorted/archauto/TODOS
new file mode 100644
index 0000000..c372ef7
--- /dev/null
+++ b/unsorted/archauto/TODOS
@@ -0,0 +1,10 @@
+- SigLevel = Newer, because we have a problem to distribute AUR
+ packages signed (own server for software distribution, but
+ then we hav to fiddle with the keyring of pacman)
+- minimal set of cfengine rules, in a readonly/protected git server,
+ the main point of administration
+- local mirrors, not for speed, but for controlled update
+ => script to keep only the necessary files in sync, not more
+- libvirt or qemu
+- how to change names of machines?
+- how to make clones?
diff --git a/unsorted/archauto/archauto.sh b/unsorted/archauto/archauto.sh
new file mode 100755
index 0000000..6a247af
--- /dev/null
+++ b/unsorted/archauto/archauto.sh
@@ -0,0 +1,126 @@
+#!/bin/sh
+
+INSTALL_DRIVE=/dev/sda
+PARTITION_BOOT=1
+PARTITION_SWAP=2
+PARTITION_ROOT=3
+LABEL_BOOT=BOOT
+LABEL_SWAP=SWAP
+LABEL_ROOT=ROOT
+MOUNT_PATH=/mnt
+GIT_REPO=git://andreasbaumann.dyndns.org/cfenginetests.git
+
+echo "Installing minimalistic base system.."
+
+sgdisk -Z ${INSTALL_DRIVE}
+sgdisk -a 2048 -o ${INSTALL_DRIVE}
+
+sgdisk -n ${PARTITION_BOOT}:0:+100M ${INSTALL_DRIVE}
+sgdisk -t ${PARTITION_BOOT}:ef02 ${INSTALL_DRIVE}
+sgdisk -c ${PARTITION_BOOT}:"${LABEL_BOOT}" ${INSTALL_DRIVE}
+
+sgdisk -n ${PARTITION_SWAP}:0:+900M ${INSTALL_DRIVE}
+sgdisk -t ${PARTITION_SWAP}:8200 ${INSTALL_DRIVE}
+sgdisk -c ${PARTITION_SWAP}:"${LABEL_SWAP}" ${INSTALL_DRIVE}
+
+sgdisk -n ${PARTITION_ROOT}:0:0 ${INSTALL_DRIVE}
+sgdisk -t ${PARTITION_ROOT}:8300 ${INSTALL_DRIVE}
+sgdisk -c ${PARTITION_ROOT}:"${LABEL_ROOT}" ${INSTALL_DRIVE}
+
+sgdisk -G ${INSTALL_DRIVE}
+
+mkswap ${INSTALL_DRIVE}${PARTITION_SWAP}
+swapon ${INSTALL_DRIVE}${PARTITION_SWAP}
+mkfs.ext4 ${INSTALL_DRIVE}${PARTITION_ROOT}
+
+mkdir -p ${MOUNT_PATH}
+mount ${INSTALL_DRIVE}${PARTITION_ROOT} ${MOUNT_PATH}
+
+#export http_proxy=http://192.168.1.12:3128
+export no_proxy=localhost,10.0.2.2
+
+# use our local cache
+sed -i '/\[core\]/aServer = http://10.0.2.2:8080/$repo/os/$arch' /etc/pacman.conf
+sed -i '/\[extra\]/aServer = http://10.0.2.2:8080/$repo/os/$arch' /etc/pacman.conf
+sed -i '/\[community\]/aServer = http://10.0.2.2:8080/$repo/os/$arch' /etc/pacman.conf
+
+# switch off signature for now
+sed -i 's/^SigLevel.*/SigLevel = Never/g' /etc/pacman.conf
+
+pacstrap ${MOUNT_PATH} filesystem grep findutils coreutils glibc bash pacman mkinitcpio kernel26 dhcpcd
+
+# use our local cache in installed pacman
+sed -i '/\[core\]/aServer = http://10.0.2.2:8080/$repo/os/$arch' ${MOUNT_PATH}/etc/pacman.conf
+sed -i '/\[extra\]/aServer = http://10.0.2.2:8080/$repo/os/$arch' ${MOUNT_PATH}/etc/pacman.conf
+sed -i '/\[community\]/aServer = http://10.0.2.2:8080/$repo/os/$arch' ${MOUNT_PATH}/etc/pacman.conf
+
+# add our local packages into a separate repository
+printf "\n[aba]\nServer = http://10.0.2.2:8080/\044repo/os/\044arch\n" >> ${MOUNT_PATH}/etc/pacman.conf
+
+# synchronize package databases for installed pacman
+arch-chroot ${MOUNT_PATH} pacman -Sy
+
+# switch off signature for now in installed pacman
+sed -i 's/^SigLevel.*/SigLevel = Never/g' ${MOUNT_PATH}/etc/pacman.conf
+
+arch-chroot ${MOUNT_PATH} pacman --noconfirm -S grub-bios
+arch-chroot ${MOUNT_PATH} grub-install --target=i386-pc --recheck ${INSTALL_DRIVE}
+cp ${MOUNT_PATH}/usr/share/locale/en@quot/LC_MESSAGES/grub.mo ${MOUNT_PATH}/boot/grub/locale/en.mo
+# disable quiet mode, set text mode instead of graphical mode
+# also ban cirrus KVM
+# set correct path of systemd binary (symlink /sbin/init has gone)
+sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="quiet"/GRUB_CMDLINE_LINUX_DEFAULT="modprobe.blacklist=cirrus init=\/usr\/lib\/systemd\/systemd"/g' ${MOUNT_PATH}/etc/default/grub
+sed -i 's/GRUB_GFXMODE=auto/GRUB_GFXMODE=text/g' ${MOUNT_PATH}/etc/default/grub
+sed -i 's/#GRUB_TERMINAL_OUTPUT=console/GRUB_TERMINAL_OUTPUT=console/g' ${MOUNT_PATH}/etc/default/grub
+
+arch-chroot ${MOUNT_PATH} grub-mkconfig -o /boot/grub/grub.cfg
+
+genfstab -p ${MOUNT_PATH} >> ${MOUNT_PATH}/etc/fstab
+
+sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' ${MOUNT_PATH}/etc/locale.gen
+arch-chroot ${MOUNT_PATH} locale-gen
+echo LANG=en_US.UTF-8 > ${MOUNT_PATH}/etc/locale.conf
+
+ln -s /usr/share/zoneinfo/Europe/Zurich ${MOUNT_PATH}/etc/localtime
+arch-chroot ${MOUNT_PATH} hwclock --systohc --utc
+
+echo "archiso" > ${MOUNT_PATH}/etc/hostname
+
+arch-chroot ${MOUNT_PATH} systemctl enable dhcpcd@ens3.service
+
+arch-chroot ${MOUNT_PATH} sh -c "echo 'root:123qwe' | chpasswd"
+
+# synchronized time is a requirement, install and configure ntp
+# we use a standard NTP server, later we can change that via cfengine
+# we don't have a network here (yet, still chrooted)
+arch-chroot ${MOUNT_PATH} pacman --noconfirm -S ntp
+#while ! ping -c1 0.pool.ntp.org &>/dev/null; do :; done
+#arch-chroot ${MOUNT_PATH} ntpdate 0.pool.ntp.org
+arch-chroot ${MOUNT_PATH} systemctl enable ntpd.service
+
+# monitord needs netstat
+arch-chroot ${MOUNT_PATH} pacman --noconfirm -S net-tools
+
+# we use 'git' to manage our promises
+arch-chroot ${MOUNT_PATH} pacman --noconfirm -S git
+
+arch-chroot ${MOUNT_PATH} pacman --noconfirm -S cfengine
+
+# install rules for the machine from git
+# no net, must be done as cfengine rule, anyway, rule distribution should
+# happen only on generated cfengine masters
+#arch-chroot ${MOUNT_PATH} git clone ${GIT_REPO} /srv/cfengine/masterfiles
+
+# enable cfengine
+arch-chroot ${MOUNT_PATH} systemctl enable cf-execd.service
+arch-chroot ${MOUNT_PATH} systemctl enable cf-monitord.service
+arch-chroot ${MOUNT_PATH} systemctl enable cf-serverd.service
+
+# for debugging
+#echo "Installation.. press any key to reboot."
+#read
+
+echo "Done.. Rebooting system.."
+sleep 3
+
+systemctl reboot
diff --git a/unsorted/archauto/clean.sh b/unsorted/archauto/clean.sh
new file mode 100644
index 0000000..27dac5f
--- /dev/null
+++ b/unsorted/archauto/clean.sh
@@ -0,0 +1,30 @@
+# This can be done in cfengine as rule as "must-be-absent" packages
+
+# pacstrap ${MOUNT_PATH} base
+# leaves us with 111 packages, 715 MB
+
+# 173M package cache, not needed, /var/cache/pacman/pkg/
+pacman --noconfirm -Scc
+rm -rf /var/cache/pacman/pkg/*.tar.xz
+
+# note, those things may be needed, I personally don't need them.
+pacman --noconfirm -Rs \
+ man-pages libpipeline groff man-db \
+ jfsutils reiserfsprogs xfsprogs \
+ cryptsetup lvm2
+
+# TODOS:
+
+# big dirs
+#
+# 72612 /usr/lib/python2.7 (libvirt again)
+#
+# locales, we don't need them on a server
+# 48208 ./locale
+# problematic, as we remove files belonging to a package
+#
+# non-modular compiler with only drivers/firmware needed could be an
+# idea here:
+# 49240 ./usr/lib/modules/3.7.9-1-ARCH
+# 33620 ./usr/lib/modules/3.7.9-1-ARCH/kernel/drivers
+# 47184 ./usr/lib/firmware
diff --git a/unsorted/archauto/copy_local_packages.sh b/unsorted/archauto/copy_local_packages.sh
new file mode 100755
index 0000000..99609db
--- /dev/null
+++ b/unsorted/archauto/copy_local_packages.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+rm -rf core/os/x86_64/
+mkdir -p core/os/x86_64/
+
+for p in `cat archiso/arch/pkglist.x86_64.txt`; do
+ case $p in
+ core/*)
+ pkgname=`echo $p | cut -f 2 -d /`
+ if test -f /var/cache/pacman/pkg/$pkgname*x86_64.pkg.tar.xz; then
+ cp /var/cache/pacman/pkg/$pkgname*x86_64.pkg.tar.xz core/os/x86_64/.
+ fi
+ if test -f /var/cache/pacman/pkg/$pkgname*any.pkg.tar.xz; then
+ cp /var/cache/pacman/pkg/$pkgname*any.pkg.tar.xz core/os/x86_64/.
+ fi
+ ;;
+ esac
+done
+
+ADDITIONAL_PKGS="libunistring-0.9.3-6 ntp-4.2.7.p441-1 joe-3.7-4 git-1.9.2-1 perl-error-0.17022-1 libxml2-2.9.1-5"
+for pkgname in $ADDITIONAL_PKGS; do
+ if test -f /var/cache/pacman/pkg/$pkgname*x86_64.pkg.tar.xz; then
+ cp /var/cache/pacman/pkg/$pkgname*x86_64.pkg.tar.xz core/os/x86_64/.
+ fi
+ if test -f /var/cache/pacman/pkg/$pkgname*any.pkg.tar.xz; then
+ cp /var/cache/pacman/pkg/$pkgname*any.pkg.tar.xz core/os/x86_64/.
+ fi
+done
+
+repo-add -n core/os/x86_64/core.db.tar.gz core/os/x86_64/*
+ln -fs core.db.tar.gz core/os/x86_64/core.db
+tar zcvfT extra/os/x86_64/extra.db.tar.gz /dev/null
+ln -fs extra.db.tar.gz extra/os/x86_64/extra.db
+tar zcvfT community/os/x86_64/community.db.tar.gz /dev/null
+ln -fs community.db.tar.gz community/os/x86_64/community.db
diff --git a/unsorted/archauto/tftproot/README b/unsorted/archauto/tftproot/README
new file mode 100644
index 0000000..da0f89a
--- /dev/null
+++ b/unsorted/archauto/tftproot/README
@@ -0,0 +1 @@
+The root of the TFTP server (embedded or real/standalone)
diff --git a/unsorted/archauto/tftproot/boot/x86_64/.placeholder b/unsorted/archauto/tftproot/boot/x86_64/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/unsorted/archauto/tftproot/boot/x86_64/.placeholder
diff --git a/unsorted/archauto/tftproot/pxelinux.cfg/01-52-54-00-12-34-56 b/unsorted/archauto/tftproot/pxelinux.cfg/01-52-54-00-12-34-56
new file mode 100644
index 0000000..9401dd8
--- /dev/null
+++ b/unsorted/archauto/tftproot/pxelinux.cfg/01-52-54-00-12-34-56
@@ -0,0 +1,17 @@
+SAY Cfengine automatic installation..
+TIMEOUT 10
+
+DEFAULT arch64_http_cfengine
+
+#SERIAL 0 9600 0x303
+
+LABEL arch64_http_cfengine
+TEXT HELP
+Boot the Arch Linux (x86_64) CFEngine installation medium (Using HTTP). It allows you
+to bootstrap an Arch Linux via CFEngine.
+ENDTEXT
+MENU LABEL Boot Arch Linux (x86_64) (HTTP)
+LINUX boot/x86_64/vmlinuz
+INITRD boot/x86_64/archiso.img
+APPEND archisobasedir=archiso/arch archiso_http_srv=http://10.0.2.2:8080/ ip=dhcp modprobe.blacklist=cirrus script=http://10.0.2.2:8080/archauto.sh
+IPAPPEND 3