archboot/usr/bin/archboot-update-installer.sh

174 lines
6.5 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# created by Tobias Powalowski <tpowa@archlinux.org>
. /etc/archboot/defaults
2022-03-21 22:25:15 +01:00
. /usr/lib/archboot/common.sh
2022-05-03 15:36:34 +02:00
. /usr/lib/archboot/container.sh
2022-04-25 15:11:54 +02:00
. /usr/lib/archboot/update-installer.sh
2022-05-20 10:32:26 +02:00
. /usr/lib/archboot/xfce.sh
2022-05-23 10:04:50 +02:00
. /usr/lib/archboot/gnome.sh
2022-05-28 11:19:22 +02:00
. /usr/lib/archboot/gnome-wayland.sh
2022-05-20 10:32:26 +02:00
. /usr/lib/archboot/kde.sh
. /usr/lib/archboot/kde-wayland.sh
2021-09-22 09:02:56 +02:00
[[ -z "${1}" ]] && usage
2022-06-01 19:42:15 +02:00
_RUN_OPTION="$1"
2021-09-22 09:02:56 +02:00
while [ $# -gt 0 ]; do
2022-04-30 08:47:58 +02:00
case ${1} in
-u|--u) _D_SCRIPTS="1" ;;
-latest|--latest) _L_COMPLETE="1" ;;
-latest-install|--latest-install) _L_INSTALL_COMPLETE="1";;
-latest-image|--latest-image) _G_RELEASE="1" ;;
-launch-xfce|--launch-xfce) _L_XFCE="1" ;;
2022-05-23 10:00:01 +02:00
-launch-gnome|--launch-gnome) _L_GNOME="1";;
-gnome-wayland|--gnome-wayland) _L_GNOME_WAYLAND="1";;
2022-05-20 10:32:26 +02:00
-launch-kde|--launch-kde) _L_KDE="1" ;;
-kde-wayland|--kde-wayland) _L_KDE_WAYLAND="1" ;;
2022-05-22 14:13:58 +02:00
-custom-xorg|--custom-xorg) _CUSTOM_X="1" ;;
-custom-wayland|--custom-wayland) _CUSTOM_WAYLAND="1" ;;
2022-04-30 08:47:58 +02:00
-h|--h|?) usage ;;
*) usage ;;
esac
shift
2021-09-22 09:02:56 +02:00
done
2022-04-25 15:11:54 +02:00
_archboot_check
_download_latest
2022-03-27 13:16:20 +02:00
echo -e "\033[1mInformation:\033[0m Logging is done on \033[1m/dev/tty7\033[0m ..."
2022-06-01 21:02:51 +02:00
_gpg_check
# remove pacman-key init service
2022-06-01 21:09:42 +02:00
systemctl disable pacman-init.service
2022-06-01 19:42:15 +02:00
_zram_initialize
2021-09-22 09:02:56 +02:00
# Generate new environment and launch it with kexec
2022-01-13 17:21:39 +01:00
if [[ "${_L_COMPLETE}" == "1" || "${_L_INSTALL_COMPLETE}" == "1" ]]; then
2022-04-25 15:11:54 +02:00
_update_installer_check
touch /.update-installer
#_umount_w_dir
#_zram_w_dir "${_ZRAM_SIZE}"
echo -e "\033[1mStep 1/9:\033[0m Waiting for gpg pacman keyring import to finish ..."
2022-04-25 15:11:54 +02:00
_gpg_check
echo -e "\033[1mStep 2/9:\033[0m Removing not necessary files from / ..."
_clean_archboot
2022-05-17 20:26:48 +02:00
_zram_usr "300M"
2022-03-27 13:16:20 +02:00
echo -e "\033[1mStep 3/9:\033[0m Generating archboot container in ${_W_DIR} ..."
echo " This will need some time ..."
2022-04-25 15:11:54 +02:00
_create_container || exit 1
# 10 seconds for getting free RAM
sleep 10
2022-03-27 13:16:20 +02:00
echo -e "\033[1mStep 4/9:\033[0m Moving kernel ${VMLINUZ} to /${VMLINUZ} ..."
2022-03-25 09:14:25 +01:00
mv "${_W_DIR}"/boot/${VMLINUZ} / || exit 1
2022-04-26 07:17:03 +02:00
[[ ${_RUNNING_ARCH} == "x86_64" ]] && _kver_x86
[[ ${_RUNNING_ARCH} == "aarch64" ]] && _kver_generic
2022-03-27 13:16:20 +02:00
echo -e "\033[1mStep 5/9:\033[0m Collect initramfs files in ${_W_DIR} ..."
echo " This will need some time ..."
# add fix for mkinitcpio 31, remove when 32 is released
cp "${_W_DIR}"/usr/share/archboot/patches/31-mkinitcpio.fixed "${_W_DIR}"/usr/bin/mkinitcpio
2022-03-21 22:28:08 +01:00
cp "${_W_DIR}"/usr/share/archboot/patches/31-initcpio.functions.fixed "${_W_DIR}"/usr/lib/initcpio/functions
# write initramfs to "${_W_DIR}"/tmp
systemd-nspawn -D "${_W_DIR}" /bin/bash -c "umount tmp;mkinitcpio -k ${_HWKVER} -c ${_CONFIG} -d /tmp" >/dev/tty7 2>&1 || exit 1
rm -f "${_W_DIR}"/tmp/etc/initrd-release
2022-03-27 13:16:20 +02:00
echo -e "\033[1mStep 6/9:\033[0m Cleanup ${_W_DIR} ..."
find "${_W_DIR}"/. -mindepth 1 -maxdepth 1 ! -name 'tmp' ! -name "${VMLINUZ}" -exec rm -rf {} \;
2022-03-25 09:14:25 +01:00
# 10 seconds for getting free RAM
sleep 10
2022-03-27 13:16:20 +02:00
echo -e "\033[1mStep 7/9:\033[0m Create initramfs /initrd.img ..."
2022-02-03 09:25:48 +01:00
echo " This will need some time ..."
2022-04-25 15:11:54 +02:00
_create_initramfs
2022-03-27 13:16:20 +02:00
echo -e "\033[1mStep 8/9:\033[0m Cleanup ${_W_DIR} ..."
2022-03-25 09:14:25 +01:00
cd /
2022-04-25 15:11:54 +02:00
_umount_w_dir
# unload virtio-net to avoid none functional network device on aarch64
2022-05-17 20:26:48 +02:00
grep -qw virtio_net /proc/modules && rmmod virtio_net
2022-03-27 13:16:20 +02:00
echo -e "\033[1mStep 9/9:\033[0m Loading files through kexec into kernel now ..."
2022-05-18 07:41:35 +02:00
echo " This will need some time ..."
_kexec
2021-09-22 09:02:56 +02:00
fi
2021-09-22 09:02:56 +02:00
# Generate new images
2022-01-13 17:21:39 +01:00
if [[ "${_G_RELEASE}" == "1" ]]; then
2022-05-21 15:11:44 +02:00
_zram_w_dir "${_ZRAM_SIZE}"
2022-03-27 13:16:20 +02:00
echo -e "\033[1mStep 1/2:\033[0m Removing not necessary files from / ..."
2022-04-25 15:11:54 +02:00
_clean_archboot
2022-05-17 20:26:48 +02:00
_zram_usr "300M"
2022-03-27 13:37:39 +02:00
echo -e "\033[1mStep 2/2:\033[0m Generating new iso files in ${_W_DIR} now ..."
2021-10-07 07:22:05 +02:00
echo " This will need some time ..."
2022-01-21 11:54:13 +01:00
"archboot-${_RUNNING_ARCH}-release.sh" "${_W_DIR}" >/dev/tty7 2>&1 || exit 1
2022-03-27 13:16:20 +02:00
echo -e "\033[1mFinished:\033[0m New isofiles are located in ${_W_DIR}"
2021-09-22 09:02:56 +02:00
fi
# install custom xorg or wayland
if [[ "${_CUSTOM_X}" == "1" || "${_CUSTOM_WAYLAND}" == "1" ]]; then
if ! [[ -d /usr.zram ]]; then
echo -e "\033[1mStep 1/3:\033[0m Move /usr to /usr.zram ..."
_zram_usr "${_ZRAM_SIZE}"
else
echo -e "\033[1mStep 1/3:\033[0m Move /usr to /usr.zram already done ..."
fi
echo -e "\033[1mStep 2/3:\033[0m Waiting for gpg pacman keyring import to finish ..."
_gpg_check
if [[ "${_CUSTOM_WAYLAND}" == "1" ]]; then
echo -e "\033[1mStep 3/3:\033[0m Installing custom wayland ..."
echo " This will need some time ..."
_prepare_graphic "${_WAYLAND_PACKAGE} ${_CUSTOM_WAYLAND}" > /dev/tty7 2>&1
fi
if [[ "${_CUSTOM_X}" == "1" ]]; then
echo -e "\033[1mStep 3/3:\033[0m Installing custom xorg ..."
echo " This will need some time ..."
_prepare_graphic "${_XORG_PACKAGE} ${_CUSTOM_XORG}" > /dev/tty7 2>&1
fi
2022-05-23 07:39:14 +02:00
systemctl start avahi-daemon.service
_chromium_flags
fi
# Gnome, KDE/PLASMA or XFCE launch
if [[ "${_L_XFCE}" == "1" || "${_L_KDE}" == "1" || "${_L_GNOME}" == "1" || "${_L_GNOME_WAYLAND}" == "1" || "${_L_KDE_WAYLAND}" == "1" ]]; then
2022-05-20 10:32:26 +02:00
if ! [[ -d /usr.zram ]]; then
echo -e "\033[1mStep 1/5:\033[0m Move /usr to /usr.zram ..."
2022-05-20 21:08:45 +02:00
_zram_usr "${_ZRAM_SIZE}"
2022-05-20 10:32:26 +02:00
else
echo -e "\033[1mStep 1/5:\033[0m Move /usr to /usr.zram already done ..."
fi
echo -e "\033[1mStep 2/5:\033[0m Waiting for gpg pacman keyring import to finish ..."
_gpg_check
# Launch xfce
if [[ "${_L_XFCE}" == "1" ]]; then
_install_xfce
fi
2022-05-23 10:00:01 +02:00
if [[ "${_L_GNOME}" == "1" ]]; then
_install_gnome
fi
2022-05-28 11:19:22 +02:00
if [[ "${_L_GNOME_WAYLAND}" == "1" ]]; then
_install_gnome_wayland
fi
2022-05-20 10:32:26 +02:00
if [[ "${_L_KDE}" == "1" ]]; then
_install_kde
fi
if [[ "${_L_KDE_WAYLAND}" == "1" ]]; then
_install_kde_wayland
fi
2022-05-20 10:32:26 +02:00
echo -e "\033[1mStep 5/5:\033[0m Starting avahi-daemon ..."
systemctl start avahi-daemon.service
2022-05-29 18:48:43 +02:00
# only start vnc on xorg environment
if [[ "${_L_XFCE}" == "1" || "${_L_KDE}" == "1" || "${_L_GNOME}" == "1" ]]; then
_autostart_vnc
fi
2022-05-20 21:53:27 +02:00
_chromium_flags
2022-05-20 10:32:26 +02:00
if [[ "${_L_XFCE}" == "1" ]]; then
_start_xfce
fi
2022-05-23 10:00:01 +02:00
if [[ "${_L_GNOME}" == "1" ]]; then
_start_gnome
fi
2022-05-28 11:19:22 +02:00
if [[ "${_L_GNOME_WAYLAND}" == "1" ]]; then
_start_gnome_wayland
fi
2022-05-20 10:32:26 +02:00
if [[ "${_L_KDE}" == "1" ]]; then
_start_kde
2022-05-12 08:10:44 +02:00
fi
if [[ "${_L_KDE_WAYLAND}" == "1" ]]; then
_start_kde_wayland
fi
fi
2022-05-20 10:32:26 +02:00