Major Release 2412-1

* Replaced salt w. ansible
* Switched os-base to Alpine 3.21
* Reworked Installer
* * Added Installation Targets gaming,proxy,build
* * End-screen now presents options to reboot, poweroff or alpine-shell
This commit is contained in:
LinuxSquare 2024-12-28 14:21:03 +01:00
parent 3f9cd642e0
commit 810c4ff1be
6 changed files with 85 additions and 106 deletions

View file

@ -1,2 +0,0 @@
https://dl-cdn.alpinelinux.org/alpine/v3.20/main
https://dl-cdn.alpinelinux.org/alpine/v3.20/community

View file

@ -1,5 +0,0 @@
state_verbose: False
file_client: local
file_roots:
base:
- /srv/salt

View file

@ -22,10 +22,8 @@ readonly INSTALLATION_ESP_PARTITION_SIZE=4
readonly INSTALLATION_MOUNTPOINT='/mnt'
readonly INSTALLATION_NOVERIA_BIN='/usr/local/noveria/bin'
readonly INSTALLATION_SECRETS_FILE="/root/installation.secrets"
readonly INSTALLATION_SALT_ROOT="srv/salt"
readonly INSTALLATION_SALT_GIT="https://git.noveria.org/Novos/salt-statetree.git"
readonly INSTALLATION_PILLAR_ROOT="srv/pillar"
readonly INSTALLATION_PILLAR_GIT="https://git.noveria.org/Novos/salt-pillartree.git"
readonly INSTALLATION_ANSIBLE_ROOT="srv/ansible"
readonly INSTALLATION_ANSIBLE_GIT="https://git.noveria.org/Novos/ansible-playbooks.git"
readonly INSTALLATION_ALPINE_VERSION=$(cat /etc/os-release | grep VERSION_ID | cut -d= -f2)
# Colors
@ -46,6 +44,14 @@ trap "errorHardExit 'Interrupted with CTRL+C'" SIGINT SIGHUP SIGTERM SIGABRT
## Helper Functions
###
##
# Run commands in chroot
# - $1: command
##
function runInChroot() {
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "$1"
}
##
# Installation subtask title output
# - $1: subtask title
@ -148,12 +154,11 @@ function preChecks() {
function introDialogue() {
local introtext="\n\n\n
Velkommen til
_ _ _
| \ | | _____ _____ _ __(_) __ _
| \| |/ _ \ \ / / _ \ '__| |/ _ |
| |\ | (_) \ V / __/ | | | (_| |
|_| \_|\___/ \_/ \___|_| |_|\__,_|
_ _\n
| \ | | _____ _____ ___\n
| \| |/ _ \ \ / / _ \/ __|\n
| |\ | (_) \ V / (_) \__ \ \n
|_| \_|\___/ \_/ \___/|___/\n\n
OS: Novos
Version: $(date "+%Y%m")
IP: $(ifconfig eth0 | grep "inet addr" | awk '{$1=$1};1' | awk '{print $2}' | cut -d: -f2)
@ -223,9 +228,8 @@ function prepareInstallation() {
INSTALLATION_DOMAIN=$(dialog --clear --title "What's the domain of this device?" --inputbox "Enter domain (leave empty for localhost)" 10 70 3>&1 1>&2 2>&3 3>&-)
[[ -z "$INSTALLATION_DOMAIN" ]] && INSTALLATION_DOMAIN="localhost"
# additional states
ADDITIONAL_STATES=$(dialog --clear --title "Select additional states to execute" --checklist "available states" 10 70 3 podman "" false 3>&1 1>&2 2>&3 3>&-)
IFS=' ' read -ra ADDITIONAL_STATES_ARR <<< "$ADDITIONAL_STATES"
# installation type
INSTALLATION_TYPE=$(dialog --clear --title "Choose the main installation type of this host" --radiolist "Select one" 10 70 3 gaming Game-Server false proxy Proxy-Server false build Build-Server false 3>&1 1>&2 2>&3 3>&-)
# show summary
summary
@ -237,7 +241,8 @@ function prepareInstallation() {
function summary() {
dialog --stdout --clear --title "Summary" --yes-label "Confirm" --no-label "Abort" --yesno "\n
Hostname: ${INSTALLATION_HOSTNAME}.${INSTALLATION_DOMAIN}\n
Disk: $INSTALLATION_DISK
Type: ${INSTALLATION_TYPE}\n
Disk: ${INSTALLATION_DISK}
" 9 60
case $? in
@ -341,7 +346,7 @@ function installation() {
cp /etc/resolv.conf "${INSTALLATION_MOUNTPOINT}/etc/resolv.conf" || installationFailed
installationSubtaskTitle "Setup PATH"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'" || installationFailed
runInChroot "export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'" || installationFailed
installationSubtaskTitle "Mount extra mounts for chroot"
mount -t proc /proc "${INSTALLATION_MOUNTPOINT}/proc" || installationFailed
@ -352,93 +357,73 @@ function installation() {
installationSubtaskTitle "Install base-packages"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "apk add alpine-base --no-cache" || installationFailed
runInChroot "apk add alpine-base tzdata eudev udev-init-scripts --no-cache" || installationFailed
installationSubtaskTitle "Overwrite default repositories"
cp /etc/apk/repositories "${INSTALLATION_MOUNTPOINT}/etc/apk/repositories" || installationFailed
installationSubtaskTitle "Install SaltStack"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "apk add salt-minion envsubst" || installationFailed
installationSubtaskTitle "Install Ansible"
runInChroot "apk add ansible envsubst" || installationFailed
installationSubtaskTitle "Setup keymap"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "setup-keymap ch ch" || installationFailed
runInChroot "setup-keymap ch ch" || installationFailed
installationSubtaskTitle "Setting localtime to Europe/Zurich"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "setup-timezone Europe/Zurich" || installationFailed
runInChroot "ln -s /usr/share/zoneinfo/Europe/Zurich /etc/localtime" || installationFailed
installationSubtaskTitle "Time sync"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "hwclock --systohc" || installationFailed
runInChroot "hwclock --systohc" || installationFailed
installationSubtaskTitle "Setup hostname"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "echo '${INSTALLATION_HOSTNAME}.${INSTALLATION_DOMAIN}' > /etc/hostname" || installationFailed
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "hostname -F /etc/hostname" || installationFailed
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "rc-update add hostname" || installationFailed
runInChroot "echo '${INSTALLATION_HOSTNAME}.${INSTALLATION_DOMAIN}' > /etc/hostname" || installationFailed
runInChroot "hostname -F /etc/hostname" || installationFailed
runInChroot "rc-update add hostname" || installationFailed
installationSubtaskTitle "Setup hosts"
cp /etc/hosts "${INSTALLATION_MOUNTPOINT}/etc/hosts" || installationFailed
installationSubtaskTitle "Set root password"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "echo -e \"${INSTALLATION_ROOT_PW}\n${INSTALLATION_ROOT_PW}\" | passwd" || installationFailed
runInChroot "echo -e \"${INSTALLATION_ROOT_PW}\n${INSTALLATION_ROOT_PW}\" | passwd" || installationFailed
installationSubtaskTitle "Enable btrfs module"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "echo 'btrfs' >> /etc/modules"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "echo 'efivarfs' >> /etc/modules"
runInChroot "echo 'btrfs' >> /etc/modules"
runInChroot "echo 'efivarfs' >> /etc/modules"
installationSubtaskTitle "Enable udev services"
runInChroot "rc-update add udev sysinit"
runInChroot "rc-update add udev-trigger sysinit"
runInChroot "rc-update add udev-settle sysinit"
runInChroot "rc-update add udev-postmount default"
echo ""
echo "┌──────────────────────────────────────────┐"
echo "│ Configure SaltStack and highstate │"
echo "│ Configure Ansible and playbook-run │"
echo "└──────────────────────────────────────────┘"
installationSubtaskTitle "Clone Salt-Repo"
mkdir -p ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_SALT_ROOT}
git clone ${INSTALLATION_SALT_GIT} ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_SALT_ROOT}
installationSubtaskTitle "Clone Playbook-repo"
mkdir -p ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/playbooks
git clone ${INSTALLATION_ANSIBLE_GIT} ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/playbooks
cat >"${INSTALLATION_MOUNTPOINT}/etc/salt/minion" <<EOT || installationFailed
---
state_verbose: False
file_client: local
file_roots:
base:
- /srv/salt
pillar_roots:
base:
- /srv/pillar
...
mkdir -p ${INSTALLATION_MOUNTPOINT}/etc/ansible
cat >"${INSTALLATION_MOUNTPOINT}/etc/ansible/ansible.cfg" <<EOT || installationFailed
[defaults]
inventory=/${INSTALLATION_ANSIBLE_ROOT}/inventory.yml
EOT
cat >"${INSTALLATION_MOUNTPOINT}/etc/salt/grains" <<EOT || installationFailed
os: Alpine
os_family: Alpine
cat >"${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/inventory.yml" <<EOT
ungrouped:
hosts:
localhost
vars:
ansible_connection: local
start_timestamp: ${START_TIMESTAMP}
tmpfs_size: 4G
installation_type: ${INSTALLATION_TYPE}
mysql_root_password: $(randomPasswordGen 32)
EOT
cat >"${INSTALLATION_MOUNTPOINT}/${INSTALLATION_SALT_ROOT}/serverspecific.sls" <<SERVERSPECIFIC || installationFailed
include:
SERVERSPECIFIC
for additional in ${ADDITIONAL_STATES_ARR[@]}; do
echo -e " - $additional" >> "${INSTALLATION_MOUNTPOINT}/${INSTALLATION_SALT_ROOT}/serverspecific.sls"
done
installationSubtaskTitle "Populate Pillars"
mkdir -p ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}
#git clone ${INSTALLATION_PILLAR_GIT} ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}
cat >"${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}/top.sls" << EOT
base:
'*':
EOT
for state in $(find ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_SALT_ROOT} -mindepth 1 -maxdepth 1 -not -path '*/.*' -type d -exec basename {} \;); do
mkdir -p ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}/${state}
touch ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}/${state}/init.sls
echo -e " - $state" >> ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}/top.sls
done
cat >"${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}/system/init.sls" << EOT
system.disks.timestamp: ${START_TIMESTAMP}
system.disks.tmpfs.size: 4G
EOT
installationSubtaskTitle "Salt highstate"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "salt-call state.highstate" || installationFailed
installationSubtaskTitle "Execute Ansible playbooks"
runInChroot "ansible-playbook /${INSTALLATION_ANSIBLE_ROOT}/playbooks/top.ansible.yml" || installationFailed
echo ""
echo "┌──────────────────────────────────────────┐"
@ -447,10 +432,10 @@ EOT
installationSubtaskTitle "Make EFI boot image with mkinitfs"
latest_kernel="$(chroot $INSTALLATION_MOUNTPOINT /bin/ash -c 'echo $(apk search linux-lts | head -n1 | cut -d- -f3- | sed "s|r||")-lts')"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "mkinitfs $latest_kernel" || installationFailed
runInChroot "mkinitfs $latest_kernel" || installationFailed
installationSubtaskTitle "Installing grub to /efi"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=alpine" || installationFailed
runInChroot "grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=alpine" || installationFailed
installationSubtaskTitle "Generating Bootmenu entries"
chroot "${INSTALLATION_MOUNTPOINT}" /bin/bash -c "/usr/local/noveria/bin/noveriablcgen --noconfirm" || installationFailed
@ -480,17 +465,18 @@ EOT
# remove shell histories
rm -f /root/.zsh_history
dialog --stdout --clear --cr-wrap --no-collapse --yes-label "Reboot" --no-label "Alpine shell" --yesno "\n Installation finished" 7 50
case $? in
0) reboot ;;
1)
clear
exit
;;
255)
clear
exit
;;
selected_option=$(dialog --output-fd 1 --menu "What would you like to do?" 10 70 5 reboot "Reboot into your newly installed system" poweroff "Shut down the current live system" alpine-shell "Switch to an interactive shell")
case "$selected_option" in
"reboot")
reboot
;;
"poweroff")
poweroff
;;
"alpine-shell")
clear
exit
;;
esac
}

View file

@ -20,7 +20,7 @@ hwclock --systohc
# Change default shell of root from ash => zsh
sed -i 's~root:/bin/sh~root:/bin/zsh~' /etc/passwd
sed -i 's~/sbin/getty 38400~/sbin/mingetty --autologin root --noclear~' /etc/inittab
sed -i 's~/sbin/getty 38400~/usr/sbin/mingetty --autologin root --noclear~' /etc/inittab
# Add btrfs module
echo "btrfs" | tee -a /etc/modules

View file

@ -1,6 +1,6 @@
linux-lts
linux-firmware-none
salt-minion
linux-firmware
ansible
zsh
vim
btrfs-progs

View file

@ -1,11 +1,11 @@
#!/usr/bin/env bash
# shellcheck disable=SC2034
iso_name="novos"
iso_label="NOVOS_$(date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y%m%d)"
iso_name="novos-ansible"
iso_label="NOVOS_$(date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y%m%d)-ANSIBLE"
iso_publisher="Noveria Network <https://noveria.org>"
iso_application="Alpine-Linux Based Server OS for Noveria"
iso_version="v3.20"
iso_version="v3.21"
airootfs_image_type="squashfs"
airootfs_image_tool_options="-comp gzip"
declare -gA file_permissions=(