dotfiles

Dash Eclipse's dotfiles
git clone git://ezup.dev/dotfiles.git
Log | Files | Refs | README | LICENSE

archlinux-installer-base.sh (2367B)


      1#!/bin/sh
      2
      3# a shell script to perform to a very basic installation of Arch Linux
      4
      5[ "$(id -u)" -ne 0 ] && { echo "This script must be run as root"; exit 1; }
      6
      7: "${progname:="${0##*/}"}"
      8usage() {
      9	cat <<_EOF
     10Usage: $progname [glibc]
     11_EOF
     12}
     13
     14step1_partition() {
     15	umount /dev/sda*
     16	umount -R /mnt
     17	wipefs -a /dev/sda
     18	dd if=/dev/zero of=/dev/sda bs=8M count=80 status=progress
     19	(
     20	echo o		# create a new empty DOS partition table
     21	echo n		# partition 1, primary, 200M
     22	echo p
     23	echo 1
     24	echo
     25	echo +200M
     26	echo n		# partition 2, primary
     27	echo p
     28	echo 2
     29	echo
     30	echo
     31	echo a		# bootable: partition 1
     32	echo 1
     33	echo w
     34	) | fdisk /dev/sda
     35	sync
     36	mkfs.vfat -F32 /dev/sda1
     37	mkfs.xfs -f /dev/sda2
     38	sync
     39}
     40
     41step2_bootstrap() {
     42	mount /dev/sda2 /mnt
     43	mkdir /mnt/boot
     44	mount /dev/sda1 /mnt/boot
     45	echo "Server = https://mirrors.kernel.org/archlinux/\$repo/os/\$arch" >/etc/pacman.d/mirrorlist
     46	pacstrap /mnt base linux linux-firmware xfsprogs syslinux
     47	genfstab -U /mnt >>/mnt/etc/fstab
     48}
     49
     50step3_chroot() {
     51	cat >/mnt/home/chroot_script.sh <<- _CHROOT_SCRIPT_EOF
     52# configuration
     53ln -sf /usr/share/zoneinfo/UTC /etc/localtime
     54hwclock --systohc
     55locale-gen
     56echo "LANG=en_US.UTF-8" >/etc/locale.conf
     57echo "KEYMAP=dvorak-programmer" >/etc/vconsole.conf
     58echo "arch-basic" >/etc/hostname
     59cat <<_END_OF_HOSTS >>/etc/hosts
     60127.0.0.1	localhost
     61::1		localhost
     62_END_OF_HOSTS
     63
     64# tty1 autologin
     65mkdir /etc/systemd/system/getty\@tty1.service.d
     66cat <<_END_OF_GETTY_TTY1_CONF >/etc/systemd/system/getty\@tty1.service.d/override.conf
     67[Service]
     68ExecStart=
     69ExecStart=-/usr/bin/agetty --autologin root --noclear %I \\\$TERM
     70_END_OF_GETTY_TTY1_CONF
     71echo 'cat /proc/uptime >/tmp/uptime' >>/root/.bash_profile
     72
     73# syslinux
     74mkinitcpio -P
     75echo 'root:password' | chpasswd
     76syslinux-install_update -i -m
     77sed -i 's#APPEND root=/dev/sda3 rw\$#APPEND root=/dev/sda2 rw#' /boot/syslinux/syslinux.cfg
     78_CHROOT_SCRIPT_EOF
     79	arch-chroot /mnt /bin/sh /home/chroot_script.sh
     80	rm /mnt/home/chroot_script.sh
     81}
     82
     83read -p "Press Enter to continue... " reply
     84[ "$reply" != "" ] && { echo "Stopped."; exit 0; }
     85
     86timedatectl set-ntp true
     87step1_partition
     88step2_bootstrap
     89step3_chroot
     90umount -R /mnt
     91
     92# get uptime/memory_usage/systemd_analyze
     93#BT=$(cut -d' ' -f1 /tmp/uptime)
     94#MEM=$(free -h | grep '^Mem:' | awk '{print $3}')
     95#SA=$(systemd-analyze | cut -d' ' -f4,7,10 | paste -d' ' -s)
     96#echo -e "$BT\n$MEM\n$SA" >$(date -u +%s).txt