1#!/usr/bin/env bash 2 3###################################################################### 4# 3) install dependencies for compiling and loading 5###################################################################### 6 7set -eu 8 9function archlinux() { 10 echo "##[group]Running pacman -Syu" 11 sudo btrfs filesystem resize max / 12 sudo pacman -Syu --noconfirm 13 echo "##[endgroup]" 14 15 echo "##[group]Install Development Tools" 16 sudo pacman -Sy --noconfirm base-devel bc cpio cryptsetup dhclient dkms \ 17 fakeroot fio gdb inetutils jq less linux linux-headers lsscsi nfs-utils \ 18 parted pax perf python-packaging python-setuptools qemu-guest-agent ksh \ 19 samba sysstat rng-tools rsync wget xxhash 20 echo "##[endgroup]" 21} 22 23function debian() { 24 export DEBIAN_FRONTEND="noninteractive" 25 26 echo "##[group]Running apt-get update+upgrade" 27 sudo apt-get update -y 28 sudo apt-get upgrade -y 29 echo "##[endgroup]" 30 31 echo "##[group]Install Development Tools" 32 sudo apt-get install -y \ 33 acl alien attr autoconf bc cpio cryptsetup curl dbench dh-python dkms \ 34 fakeroot fio gdb gdebi git ksh lcov isc-dhcp-client jq libacl1-dev \ 35 libaio-dev libattr1-dev libblkid-dev libcurl4-openssl-dev libdevmapper-dev \ 36 libelf-dev libffi-dev libmount-dev libpam0g-dev libselinux-dev libssl-dev \ 37 libtool libtool-bin libudev-dev libunwind-dev linux-headers-$(uname -r) \ 38 lsscsi nfs-kernel-server pamtester parted python3 python3-all-dev \ 39 python3-cffi python3-dev python3-distlib python3-packaging \ 40 python3-setuptools python3-sphinx qemu-guest-agent rng-tools rpm2cpio \ 41 rsync samba sysstat uuid-dev watchdog wget xfslibs-dev xxhash zlib1g-dev 42 echo "##[endgroup]" 43} 44 45function freebsd() { 46 export ASSUME_ALWAYS_YES="YES" 47 48 echo "##[group]Install Development Tools" 49 sudo pkg install -y autoconf automake autotools base64 checkbashisms fio \ 50 gdb gettext gettext-runtime git gmake gsed jq ksh93 lcov libtool lscpu \ 51 pkgconf python python3 pamtester pamtester qemu-guest-agent rsync xxhash 52 sudo pkg install -xy \ 53 '^samba4[[:digit:]]+$' \ 54 '^py3[[:digit:]]+-cffi$' \ 55 '^py3[[:digit:]]+-sysctl$' \ 56 '^py3[[:digit:]]+-packaging$' 57 echo "##[endgroup]" 58} 59 60# common packages for: almalinux, centos, redhat 61function rhel() { 62 echo "##[group]Running dnf update" 63 echo "max_parallel_downloads=10" | sudo -E tee -a /etc/dnf/dnf.conf 64 sudo dnf clean all 65 sudo dnf update -y --setopt=fastestmirror=1 --refresh 66 echo "##[endgroup]" 67 68 echo "##[group]Install Development Tools" 69 70 # Alma wants "Development Tools", Fedora 41 wants "development-tools" 71 if ! sudo dnf group install -y "Development Tools" ; then 72 echo "Trying 'development-tools' instead of 'Development Tools'" 73 sudo dnf group install -y development-tools 74 fi 75 76 sudo dnf install -y \ 77 acl attr bc bzip2 cryptsetup curl dbench dkms elfutils-libelf-devel fio \ 78 gdb git jq kernel-rpm-macros ksh libacl-devel libaio-devel \ 79 libargon2-devel libattr-devel libblkid-devel libcurl-devel libffi-devel \ 80 ncompress libselinux-devel libtirpc-devel libtool libudev-devel \ 81 libuuid-devel lsscsi mdadm nfs-utils openssl-devel pam-devel pamtester \ 82 parted perf python3 python3-cffi python3-devel python3-packaging \ 83 kernel-devel python3-setuptools qemu-guest-agent rng-tools rpcgen \ 84 rpm-build rsync samba sysstat systemd watchdog wget xfsprogs-devel xxhash \ 85 zlib-devel 86 echo "##[endgroup]" 87} 88 89function tumbleweed() { 90 echo "##[group]Running zypper is TODO!" 91 sleep 23456 92 echo "##[endgroup]" 93} 94 95# Install dependencies 96case "$1" in 97 almalinux8) 98 echo "##[group]Enable epel and powertools repositories" 99 sudo dnf config-manager -y --set-enabled powertools 100 sudo dnf install -y epel-release 101 echo "##[endgroup]" 102 rhel 103 echo "##[group]Install kernel-abi-whitelists" 104 sudo dnf install -y kernel-abi-whitelists 105 echo "##[endgroup]" 106 ;; 107 almalinux9|centos-stream9) 108 echo "##[group]Enable epel and crb repositories" 109 sudo dnf config-manager -y --set-enabled crb 110 sudo dnf install -y epel-release 111 echo "##[endgroup]" 112 rhel 113 echo "##[group]Install kernel-abi-stablelists" 114 sudo dnf install -y kernel-abi-stablelists 115 echo "##[endgroup]" 116 ;; 117 archlinux) 118 archlinux 119 ;; 120 debian*) 121 echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections 122 debian 123 echo "##[group]Install Debian specific" 124 sudo apt-get install -yq linux-perf dh-sequence-dkms 125 echo "##[endgroup]" 126 ;; 127 fedora*) 128 rhel 129 ;; 130 freebsd*) 131 freebsd 132 ;; 133 tumbleweed) 134 tumbleweed 135 ;; 136 ubuntu*) 137 debian 138 echo "##[group]Install Ubuntu specific" 139 sudo apt-get install -yq linux-tools-common libtirpc-dev \ 140 linux-modules-extra-$(uname -r) 141 if [ "$1" != "ubuntu20" ]; then 142 sudo apt-get install -yq dh-sequence-dkms 143 fi 144 echo "##[endgroup]" 145 echo "##[group]Delete Ubuntu OpenZFS modules" 146 for i in $(find /lib/modules -name zfs -type d); do sudo rm -rvf $i; done 147 echo "##[endgroup]" 148 ;; 149esac 150 151# This script is used for checkstyle + zloop deps also. 152# Install only the needed packages and exit - when used this way. 153test -z "${ONLY_DEPS:-}" || exit 0 154 155# Start services 156echo "##[group]Enable services" 157case "$1" in 158 freebsd*) 159 # add virtio things 160 echo 'virtio_load="YES"' | sudo -E tee -a /boot/loader.conf 161 for i in balloon blk console random scsi; do 162 echo "virtio_${i}_load=\"YES\"" | sudo -E tee -a /boot/loader.conf 163 done 164 echo "fdescfs /dev/fd fdescfs rw 0 0" | sudo -E tee -a /etc/fstab 165 sudo -E mount /dev/fd 166 sudo -E touch /etc/zfs/exports 167 sudo -E sysrc mountd_flags="/etc/zfs/exports" 168 echo '[global]' | sudo -E tee /usr/local/etc/smb4.conf >/dev/null 169 sudo -E service nfsd enable 170 sudo -E service qemu-guest-agent enable 171 sudo -E service samba_server enable 172 ;; 173 debian*|ubuntu*) 174 sudo -E systemctl enable nfs-kernel-server 175 sudo -E systemctl enable qemu-guest-agent 176 sudo -E systemctl enable smbd 177 ;; 178 *) 179 # All other linux distros 180 sudo -E systemctl enable nfs-server 181 sudo -E systemctl enable qemu-guest-agent 182 sudo -E systemctl enable smb 183 ;; 184esac 185echo "##[endgroup]" 186 187# Setup Kernel cmdline 188CMDLINE="console=tty0 console=ttyS0,115200n8" 189CMDLINE="$CMDLINE selinux=0" 190CMDLINE="$CMDLINE random.trust_cpu=on" 191CMDLINE="$CMDLINE no_timer_check" 192case "$1" in 193 almalinux*|centos*|fedora*) 194 GRUB_CFG="/boot/grub2/grub.cfg" 195 GRUB_MKCONFIG="grub2-mkconfig" 196 CMDLINE="$CMDLINE biosdevname=0 net.ifnames=0" 197 echo 'GRUB_SERIAL_COMMAND="serial --speed=115200"' \ 198 | sudo tee -a /etc/default/grub >/dev/null 199 ;; 200 ubuntu24) 201 GRUB_CFG="/boot/grub/grub.cfg" 202 GRUB_MKCONFIG="grub-mkconfig" 203 echo 'GRUB_DISABLE_OS_PROBER="false"' \ 204 | sudo tee -a /etc/default/grub >/dev/null 205 ;; 206 *) 207 GRUB_CFG="/boot/grub/grub.cfg" 208 GRUB_MKCONFIG="grub-mkconfig" 209 ;; 210esac 211 212case "$1" in 213 archlinux|freebsd*) 214 true 215 ;; 216 *) 217 echo "##[group]Edit kernel cmdline" 218 sudo sed -i -e '/^GRUB_CMDLINE_LINUX/d' /etc/default/grub || true 219 echo "GRUB_CMDLINE_LINUX=\"$CMDLINE\"" \ 220 | sudo tee -a /etc/default/grub >/dev/null 221 sudo $GRUB_MKCONFIG -o $GRUB_CFG 222 echo "##[endgroup]" 223 ;; 224esac 225 226# reset cloud-init configuration and poweroff 227sudo cloud-init clean --logs 228sleep 2 && sudo poweroff & 229exit 0 230