diff --git a/config/boot/systemd/entries b/config/boot/systemd/entries new file mode 100644 index 0000000..68b0a59 --- /dev/null +++ b/config/boot/systemd/entries @@ -0,0 +1,99 @@ +#!/bin/bash +. ./lib + +options=() +options+=("Edit entry" "") +options+=("" "") +options+=("Update ucode" "") +options+=("" "") +options+=("Create entry" "") +options+=("Delete entry" "") + +defaultitem="Edit entry" +sel=$(whiptail --backtitle "$apptitle" --title "Systemd Entries Menu :" --menu "" --default-item "$defaultitem" --cancel-button "Back" 0 0 0 \ + "${options[@]}" \ + 3>&1 1>&2 2>&3) +if [ ! "$?" = "0" ]; then + exit 1 +fi +sed -i "/^defaultitem=/c\defaultitem=\"$sel\"" $0 + +case $sel in + 'Edit entry') + entries=$(ls /boot/loader/entries) + entrylist=() + for itm in $entries; do + entrylist+=("${itm::-5}" "") + done + sel=$(whiptail --backtitle "$apptitle" --title "Edit entry :" --menu "" --cancel-button "Cancel" 0 0 0 \ + "${entrylist[@]}" \ + 3>&1 1>&2 2>&3) + if [ "$?" = "0" ]; then + editfile /boot/loader/entries/$sel.conf + fi + ;; + 'Create entry') + entry=$(whiptail --backtitle "$apptitle" --title "Create entry" --inputbox "Enter the new entry name :" 0 0 3>&1 1>&2 2>&3) + if [ "$?" = "0" ]; then + cp /usr/share/systemd/bootctl/arch.conf /boot/loader/entries/$entry.conf + sed -i "s/Arch Linux/$entry/" /boot/loader/entries/$entry.conf + editfile /boot/loader/entries/$entry.conf + fi + ;; + 'Delete entry') + entries=$(ls /boot/loader/entries) + entrylist=() + for itm in $entries; do + entrylist+=("${itm::-5}" "") + done + sel=$(whiptail --backtitle "$apptitle" --title "Delete entry :" --menu "" --cancel-button "Cancel" 0 0 0 \ + "${entrylist[@]}" \ + 3>&1 1>&2 2>&3) + if [ "$?" = "0" ]; then + if (confirm "Delete $sel entry ?") then + rm /boot/loader/entries/$sel.conf + fi + fi + ;; + 'Update ucode') + entries=$(ls /boot/loader/entries) + entrylist=() + for itm in $entries; do + entrylist+=("${itm::-5}" "" on) + done + sel=$(whiptail --backtitle "$apptitle" --title "Update ucode of :" --checklist "" --cancel-button "Cancel" 0 0 0 \ + "${entrylist[@]}" \ + 3>&1 1>&2 2>&3) + if [ "$?" = "0" ]; then + clear + for itm in $sel; do + itm=${itm//\"/} + if [ -f /boot/amd-ucode.img ]; then + if [ ! "$(cat /boot/loader/entries/$itm.conf | grep amd-ucode.img)" ]; then + echo "Add amd-ucode to $itm" + sed -i "/vmlinuz/a initrd /amd-ucode.img" /boot/loader/entries/$itm.conf + fi + else + if [ "$(cat /boot/loader/entries/$itm.conf | grep amd-ucode.img)" ]; then + echo "Remove amd-ucode from $itm" + sed -i "/amd-ucode.img/d" /boot/loader/entries/$itm.conf + fi + fi + if [ -f /boot/intel-ucode.img ]; then + if [ ! "$(cat /boot/loader/entries/$itm.conf | grep intel-ucode.img)" ]; then + echo "Add intel-ucode to $itm" + sed -i "/vmlinuz/a initrd /intel-ucode.img" /boot/loader/entries/$itm.conf + fi + else + if [ "$(cat /boot/loader/entries/$itm.conf | grep intel-ucode.img)" ]; then + echo "Remove intel-ucode from $itm" + sed -i "/intel-ucode.img/d" /boot/loader/entries/$itm.conf + fi + fi + done + pressanykey + fi + ;; +esac + +exit 0 diff --git a/config/boot/systemd/menu b/config/boot/systemd/menu index 9ea2415..2814bed 100644 --- a/config/boot/systemd/menu +++ b/config/boot/systemd/menu @@ -2,10 +2,18 @@ . ./lib options=() -options+=("config" "/boot/loader/loader.conf") -#/boot/loader/entries/* +options+=("Config" "/boot/loader/loader.conf") +options+=("Entries" "/boot/loader/entries") +options+=("" "") +options+=("Update" "bootctl update") +options+=("" "") +if [ ! -f /etc/pacman.d/hooks/systemd-boot.hook ]; then + options+=("Create pacman hook" "/etc/pacman.d/hooks/systemd-boot.hook") +else + options+=("Delete pacman hook" "/etc/pacman.d/hooks/systemd-boot.hook") +fi -defaultitem="" +defaultitem="Config" sel=$(whiptail --backtitle "$apptitle" --title "Systemd Config Menu :" --menu "" --default-item "$defaultitem" --cancel-button "Back" 0 0 0 \ "${options[@]}" \ 3>&1 1>&2 2>&3) @@ -15,7 +23,39 @@ fi sed -i "/^defaultitem=/c\defaultitem=\"$sel\"" $0 case $sel in - 'config') editfile /boot/loader/loader.conf;; + 'Config') + defaultitem="Config" + editfile /boot/loader/loader.conf + ;; + 'Entries') + defaultitem="Entries" + menu config/boot/systemd/entries + ;; + 'Update') + defaultitem="Update" + clear + bootctl update + pressanykey + ;; + 'Create pacman hook') + defaultitem="Update" + mkdir -p /etc/pacman.d/hooks + cat < /etc/pacman.d/hooks/systemd-boot.hook +[Trigger] +Type = Package +Operation = Upgrade +Target = systemd + +[Action] +Description = Updating systemd-boot +When = PostTransaction +Exec = /usr/bin/bootctl update +EOF + ;; + 'Delete pacman hook') + defaultitem="Update" + rm /etc/pacman.d/hooks/systemd-boot.hook + ;; esac exit 0