aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-08-20 15:26:04 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-08-20 15:26:04 +0200
commit060719c5fd239528be304a0e4ad6e375a20e7599 (patch)
tree486f93431ca70bdb1562d6fbdb27cb1bb554f9be
parent5fce1f627035614091013578c00cf43f38710a49 (diff)
add armtix installer
-rwxr-xr-xarmtixinstall73
-rwxr-xr-xmkarmtix113
2 files changed, 186 insertions, 0 deletions
diff --git a/armtixinstall b/armtixinstall
new file mode 100755
index 0000000..2f61ec0
--- /dev/null
+++ b/armtixinstall
@@ -0,0 +1,73 @@
+#! /bin/bash
+
+set -e
+
+if [ "${UID}" != "0" ]; then
+ echo "armtixinstall: requires root permissions"
+ exit 1
+fi
+
+pacman -Sy
+pacman -S --needed --noconfirm parted fzf
+
+#
+# Config questions
+#
+
+DRIVE=$1
+IMG=$2
+
+if [ -z "${DRIVE}" ]; then
+ DRIVE="/dev/$(lsblk | grep disk | fzf --disabled | awk '{print $1}')"
+fi
+
+if [[ "${DRIVE}" == "/dev/mmcblk"* ]] | [[ "${DRIVE}" == "/dev/nvme"* ]]; then
+ PART_PREFIX="${DRIVE}p"
+else
+ PART_PREFIX="${DRIVE}"
+fi
+
+if [ -z "${IMG}" ]; then
+ IMG=$(echo "Enter image path (download from armtixlinux.org, OpenRC): " | fzf --disabled --print-query | sed -n '1 p')
+fi
+
+# Needed because otherwise there is no system to operate on.
+if [ -z "${IMG}" ]; then
+ echo -e "\e[1m\e[1;31mImage path must not be empty.\e[0m"
+ exit 1
+fi
+
+parted -s ${DRIVE} mklabel msdos
+parted -s -a optimal ${DRIVE} mkpart primary fat32 0% 256MiB
+parted -s -a optimal ${DRIVE} mkpart primary btrfs 256MiB 100%
+
+mkfs.fat -F 32 ${PART_PREFIX}1
+mkfs.btrfs -f ${PART_PREFIX}2
+
+fatlabel ${PART_PREFIX}1 BOOT
+
+mkdir /btrfs
+mount -o compress=zstd ${PART_PREFIX}2 /btrfs
+btrfs subvolume create /btrfs/root
+umount /btrfs
+
+mount -o compress=zstd,subvol=/root ${PART_PREFIX}2 /mnt
+mkdir /mnt/boot
+mount ${PART_PREFIX}1 /mnt/boot
+
+(cd /mnt && tar -xvJf ${IMG})
+
+artix-chroot /mnt bash -c "curl -fsSL https://raw.githubusercontent.com/HimbeerserverDE/artixinstall/main/mkarmtix | sh -s -- ${DRIVE} ${PART_PREFIX}"
+
+fstabgen -U /mnt >> /mnt/etc/fstab
+
+umount -R /mnt
+sync
+
+rm -d /btrfs
+
+echo -e "\n\e[1m\e[1;32mArmtix has been successfully installed! It is now safe to remove the drive."
+echo -e "\e[1m\e[1;32mDon't forget to change the root password and hostname."
+echo -e "\e[1m\e[1;32mYou should synchronize the system clock to hardware yourself."
+echo -e "\e[1m\e[1;32mSetting up networking is left to you, dhcpcd and wpa_supplicant are installed."
+echo -en "\e[0m"
diff --git a/mkarmtix b/mkarmtix
new file mode 100755
index 0000000..f25b39d
--- /dev/null
+++ b/mkarmtix
@@ -0,0 +1,113 @@
+#! /bin/bash
+
+set -e
+
+function get_cmdline {
+ sed -r 's/[[:alnum:]]+=/\n&/g' /proc/cmdline | awk -F= "\$1==\"$1\"{print \$2}" | sed 's/.\{1\}$//'
+}
+
+# cmdline options
+TIMEZONE=$(get_cmdline tz)
+KEYMAP=$(get_cmdline keytable)
+
+DRIVE=$1
+PART_PREFIX=$2
+
+if [[ -z "${DRIVE}" ]] | [[ -z "${PART_PREFIX}" ]]; then
+ echo -e "\e[1m\e[1;31mUsage: mkarmtix <drive> <partition prefix>\e[0m"
+ exit 1
+fi
+
+ln -sf "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime
+
+sed -i "s/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/" /etc/locale.gen
+locale-gen
+
+cat <<EOT > /etc/locale.conf
+export LANG="en_US.UTF-8"
+export LC_COLLATE="C"
+EOT
+
+sed -i "s/keymap=\"us\"/keymap=\"${KEYMAP}\"/" /etc/conf.d/keymaps
+
+pacman -S -needed --noconfirm btrfs-progs
+
+sed -i "s/MODULES=()/MODULES=(pcie_brcmstb)/" /etc/mkinitcpio.conf
+
+echo -en 'armtix\narmtix' | passwd
+userdel -r armtix
+pacman -Rns --noconfirm sudo
+
+# Network
+## Hostname
+echo armtix > /etc/hostname
+
+cat <<EOT > /etc/hosts
+# Static table lookup for hostnames.
+# See hosts(5) for details.
+
+127.0.0.1 localhost
+127.0.1.1 armtix.local armtix
+
+# IPv6
+::1 localhost ip6-localhost ip6-loopback
+ff02::1 ip6-allnodes
+ff02::2 ip6-allrouters
+EOT
+
+sed -i 's/hostname="localhost"/hostname="armtix"/' /etc/conf.d/hostname
+
+## Networking essentials
+pacman -S --noconfirm dhcpcd wpa_supplicant
+
+# Repositories
+## Artix
+cat <<EOT >> /etc/pacman.conf
+
+#
+# Custom
+#
+
+# Artix
+
+[universe]
+Server = https://universe.artixlinux.org/\$arch
+Server = https://mirror1.artixlinux.org/universe/\$arch
+Server = https://mirror.pascalpuffke.de/artix-universe/\$arch
+Server = https://artixlinux.qontinuum.space/artixlinux/universe/os/\$arch
+Server = https://mirror1.cl.netactuate.com/artix/universe/\$arch
+Server = https://ftp.crifo.org/artix-universe/
+EOT
+
+## Arch
+pacman -Sy --needed --noconfirm artix-archlinux-support
+
+cat <<EOT >> /etc/pacman.conf
+
+# Arch
+
+#[testing]
+#Include = /etc/pacman.d/mirrorlist-arch
+
+[extra]
+Include = /etc/pacman.d/mirrorlist-arch
+
+#[community-testing]
+#Include = /etc/pacman.d/mirrorlist-arch
+
+[community]
+Include = /etc/pacman.d/mirrorlist-arch
+
+#[multilib-testing]
+#Include = /etc/pacman.d/mirrorlist-arch
+
+#[multilib]
+#Include = /etc/pacman.d/mirrorlist-arch
+EOT
+
+pacman-key --populate archlinux
+pacman -Sy
+
+rc-update add ntpd default
+
+exit 0