Skip to content

Commit

Permalink
Add support for AlmaLinux Rocky Linux and Proxmox 7
Browse files Browse the repository at this point in the history
  • Loading branch information
asciiprod committed Dec 13, 2021
1 parent ba4f0cb commit 6358b0d
Show file tree
Hide file tree
Showing 23 changed files with 590 additions and 320 deletions.
147 changes: 147 additions & 0 deletions almalinux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/bin/bash

#
# AlmaLinux specific functions
#
# (c) 2021, Hetzner Online GmbH
#


# generate_config_mdadm "NIL"
generate_config_mdadm() {
if [ -n "$1" ]; then
local mdadmconf="/etc/mdadm.conf"
{
echo "DEVICE partitions"
echo "MAILADDR root"
} > "$FOLD/hdd$mdadmconf"
execute_chroot_command "mdadm --examine --scan >> $mdadmconf"; declare -i EXITCODE=$?
return $EXITCODE
fi
}

# generate_new_ramdisk "NIL"
generate_new_ramdisk() {
if [ -n "$1" ]; then

# pick the latest kernel
VERSION="$(find "$FOLD/hdd/boot/" -name "vmlinuz-*" | cut -d '-' -f 2- | sort -V | tail -1)"

# blacklist some kernel modules due to bugs and/or stability issues or annoyance
local blacklist_conf="$FOLD/hdd/etc/modprobe.d/blacklist-$C_SHORT.conf"
{
echo "### $COMPANY - installimage"
echo "### silence any onboard speaker"
echo "blacklist pcspkr"
echo "### i915 driver blacklisted due to various bugs"
echo "### especially in combination with nomodeset"
echo "blacklist i915"
echo "blacklist sm750fb"
} > "$blacklist_conf"

local dracutfile="$FOLD/hdd/etc/dracut.conf.d/99-$C_SHORT.conf"
{
echo "### $COMPANY - installimage"
echo 'add_dracutmodules+="lvm mdraid"'
echo 'add_drivers+="raid0 raid1 raid10 raid456"'
#echo 'early_microcode="no"'
echo 'hostonly="no"'
echo 'hostonly_cmdline="no"'
echo 'lvmconf="yes"'
echo 'mdadmconf="yes"'
echo 'persistent_policy="by-uuid"'
} > "$dracutfile"

execute_chroot_command "dracut -f --kver $VERSION"
declare -i EXITCODE=$?
return "$EXITCODE"
fi
}

#
# generate_config_grub <version>
#
# Generate the GRUB bootloader configuration.
#
generate_config_grub() {
[ -n "$1" ] || return
# we should not have to do anything, as grubby (new-kernel-pkg) should have
# already generated a grub.conf
# even though grub2-mkconfig will generate a device.map on the fly, the
# anaconda installer still creates this
DMAPFILE="$FOLD/hdd/boot/grub2/device.map"
[ -f "$DMAPFILE" ] && rm "$DMAPFILE"

local -i i=0
for ((i=1; i<=COUNT_DRIVES; i++)); do
local j; j="$((i - 1))"
local disk; disk="$(eval echo "\$DRIVE$i")"
echo "(hd$j) $disk" >> "$DMAPFILE"
done
debug '# device map:'
cat "$DMAPFILE" | debugoutput

local elevator=''
if is_virtual_machine; then
elevator='elevator=noop'
fi

local grub_cmdline_linux='biosdevname=0 crashkernel=auto'
is_virtual_machine && grub_cmdline_linux+=' elevator=noop'
grub_cmdline_linux+=' nomodeset rd.auto=1 consoleblank=0'

if has_threadripper_cpu; then
grub_cmdline_linux+=' pci=nommconf'
fi

if is_dell_r6415; then
grub_cmdline_linux=${grub_cmdline_linux/nomodeset }
fi

sed -i "s/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"$grub_cmdline_linux\"/" "$FOLD/hdd/etc/default/grub"

rm -f "$FOLD/hdd/boot/grub2/grub.cfg"
if [ "$UEFI" -eq 1 ]; then
execute_chroot_command "grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg 2>&1"; declare -i EXITCODE="$?"
else
execute_chroot_command "grub2-mkconfig -o /boot/grub2/grub.cfg 2>&1"; declare -i EXITCODE="$?"
fi
uuid_bugfix
return "$EXITCODE"
}

write_grub() {
if [ "$UEFI" -eq 1 ]; then
# we must NOT use grub2-install here. This will replace the prebaked
# grubx64.efi (which looks for grub.cfg in ESP) with a new one, which
# looks for in in /boot/grub2 (which may be more difficult to read)
rm -f "$FOLD/hdd/boot/grub2/grubenv"
execute_chroot_command "ln -s /boot/efi/EFI/almalinux/grubenv /boot/grub2/grubenv"
declare -i EXITCODE=$?
else
# only install grub2 in mbr of all other drives if we use swraid
for ((i=1; i<=COUNT_DRIVES; i++)); do
if [ "$SWRAID" -eq 1 ] || [ "$i" -eq 1 ] ; then
local disk; disk="$(eval echo "\$DRIVE"$i)"
execute_chroot_command "grub2-install --no-floppy --recheck $disk 2>&1"
declare -i EXITCODE=$?
fi
done
fi

return "$EXITCODE"
}

#
# os specific functions
# for purpose of e.g. debian-sys-maint mysql user password in debian/ubuntu LAMP
#
run_os_specific_functions() {
# selinux autorelabel if enabled
egrep -q "SELINUX=enforcing" "$FOLD/hdd/etc/sysconfig/selinux" &&
touch "$FOLD/hdd/.autorelabel"

return 0
}

# vim: ai:ts=2:sw=2:et
4 changes: 1 addition & 3 deletions archlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# archlinux functions
#
# (c) 2013-2020, Hetzner Online GmbH
# (c) 2013-2021, Hetzner Online GmbH
#

validate_image() { return 2; }
Expand Down Expand Up @@ -225,8 +225,6 @@ generate_new_ramdisk() {
execute_chroot_command 'mkinitcpio -p linux'
}

setup_cpufreq() { return; }

generate_config_grub() {
debug "# setup /etc/default/grub"
local grub_file="$FOLD/hdd/etc/default/grub"
Expand Down
14 changes: 4 additions & 10 deletions centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ generate_new_ramdisk() {
fi
}


setup_cpufreq() {
if [ -n "$1" ]; then
return 0
fi
}

#
# generate_config_grub <version>
#
Expand All @@ -85,15 +78,16 @@ generate_config_grub() {
local disk; disk="$(eval echo "\$DRIVE$i")"
echo "(hd$j) $disk" >> "$DMAPFILE"
done
cat "$DMAPFILE" >> "$DEBUGFILE"
debug '# device map:'
cat "$DMAPFILE" | debugoutput

local elevator=''
if isVServer; then
if is_virtual_machine; then
elevator='elevator=noop'
fi

local grub_cmdline_linux='biosdevname=0 crashkernel=auto'
isVServer && grub_cmdline_linux+=' elevator=noop'
is_virtual_machine && grub_cmdline_linux+=' elevator=noop'
grub_cmdline_linux+=' nomodeset rd.auto=1 consoleblank=0'

if has_threadripper_cpu; then
Expand Down
29 changes: 20 additions & 9 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# set all necessary vars and functions
#
# (c) 2007-2018, Hetzner Online GmbH
# (c) 2007-2021, Hetzner Online GmbH
#


Expand Down Expand Up @@ -68,13 +68,24 @@ declare -x -i BTRFS=0
# dialog settings
export DIATITLE="$COMPANY"
export OSMENULIST=(
"Debian" "(Official)"
"Ubuntu" "(Official)"
"CentOS" "(Official)"
"Arch Linux" "(Official)"
"Other" "(!!NO SUPPORT!!)"
"Old images" "(!!NO SUPPORT!!)"
"Custom image" "(Blanco config for user images)"
"Debian" "(Official)"
"Ubuntu" "(Official)"
"CentOS" "(Official)"
"Arch Linux" "(Official)"
)
if (($(find "$IMAGESPATH" -type f -iname '*centos*stream*' -printf '.' | wc -c) > 0)); then
export OSMENULIST+=("CentOS Stream" "(!!BETA, NO SUPPORT!!)")
fi
if (($(find "$IMAGESPATH" -type f -iname '*alma*' -printf '.' | wc -c) > 0)); then
export OSMENULIST+=("AlmaLinux" "(!!BETA, NO SUPPORT!!)")
fi
if (($(find "$IMAGESPATH" -type f -iname '*rocky*' -printf '.' | wc -c) > 0)); then
export OSMENULIST+=("Rocky Linux" "(!!BETA, NO SUPPORT!!)")
fi
export OSMENULIST+=(
"Other" "(!!NO SUPPORT!!)"
"Old images" "(!!NO SUPPORT!!)"
"Custom image" "(Blanco config for user images)"
)

export PROXMOX4_BASE_IMAGE="Debian-811-jessie-64-minimal"
Expand All @@ -85,7 +96,7 @@ export CPANEL_INSTALLER_SRC=http://mirror.hetzner.com/tools/cpanelinc/cpanel

export PLESK_INSTALLER_SRC=http://mirror.hetzner.com/tools/parallels/plesk
export PLESK_MIRROR=http://mirror.hetzner.com/plesk
export PLESK_STD_VERSION=PLESK_18_0_33
export PLESK_STD_VERSION=PLESK_18_0_40
export PLESK_DOWNLOAD_RETRY_COUNT=999
export PLESK_COMPONENTS=(
awstats
Expand Down
20 changes: 20 additions & 0 deletions configs/proxmox7
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## ===================================================
## Hetzner Online GmbH - installimage - Proxmox-VE
## ===================================================

DRIVE1 /dev/sda
DRIVE2 /dev/sdb

SWRAID 1
SWRAIDLEVEL 1

BOOTLOADER grub

HOSTNAME Proxmox-VE.localdomain

PART /boot ext3 512M
PART lvm vg0 all
LV vg0 root / ext4 15G
LV vg0 swap swap swap 6G

IMAGE /root/images/Debian-1101-bullseye-amd64-base.tar.gz
4 changes: 2 additions & 2 deletions configs/simple-debian64-noraid
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ SWRAIDLEVEL 1

BOOTLOADER grub

HOSTNAME Debian-1100-bullseye-amd64-base
HOSTNAME Debian-1101-bullseye-amd64-base

PART swap swap 8G
PART /boot ext3 512M
PART / ext4 all

IMAGE /root/images/Debian-1100-bullseye-amd64-base.tar.gz
IMAGE /root/images/Debian-1101-bullseye-amd64-base.tar.gz
4 changes: 2 additions & 2 deletions configs/simple-debian64-raid
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ SWRAIDLEVEL 1

BOOTLOADER grub

HOSTNAME Debian-1100-bullseye-amd64-base
HOSTNAME Debian-1101-bullseye-amd64-base

PART swap swap 2G
PART /boot ext3 512M
PART / ext4 all

IMAGE /root/images/Debian-1100-bullseye-amd64-base.tar.gz
IMAGE /root/images/Debian-1101-bullseye-amd64-base.tar.gz
4 changes: 2 additions & 2 deletions configs/simple-debian64-raid-lvm
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ SWRAIDLEVEL 1

BOOTLOADER grub

HOSTNAME Debian-1100-bullseye-amd64-base
HOSTNAME Debian-1101-bullseye-amd64-base

PART /boot ext3 512M
PART lvm vg0 all

LV vg0 root / ext4 20G
LV vg0 swap swap swap 4G

IMAGE /root/images/Debian-1100-bullseye-amd64-base.tar.gz
IMAGE /root/images/Debian-1101-bullseye-amd64-base.tar.gz
25 changes: 1 addition & 24 deletions debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,6 @@ generate_new_ramdisk() {
fi
}

setup_cpufreq() {
if [ -n "$1" ]; then
local loadcpufreqconf="$FOLD/hdd/etc/default/loadcpufreq"
local cpufreqconf="$FOLD/hdd/etc/default/cpufrequtils"
{
echo "### $COMPANY - installimage"
echo "# cpu frequency scaling"
} > "$cpufreqconf"
if isVServer; then
echo 'ENABLE="false"' > "$loadcpufreqconf"
echo 'ENABLE="false"' >> "$cpufreqconf"
else
{
echo 'ENABLE="true"'
echo "GOVERNOR=\"$1\""
echo 'MAX_SPEED="0"'
echo 'MIN_SPEED="0"'
} >> "$cpufreqconf"
fi
return 0
fi
}

#
# Generate the GRUB bootloader configuration.
#
Expand All @@ -110,7 +87,7 @@ generate_config_grub() {

# set linux_default in grub
local grub_linux_default="nomodeset consoleblank=0"
if isVServer; then
if is_virtual_machine; then
grub_linux_default="${grub_linux_default} elevator=noop"
fi

Expand Down
Loading

0 comments on commit 6358b0d

Please sign in to comment.