2019-01-03 16:07:39 -07:00
|
|
|
#!/bin/bash
|
|
|
|
. ./lib
|
|
|
|
|
|
|
|
options=()
|
|
|
|
options+=("Edit entry" "")
|
|
|
|
options+=("" "")
|
|
|
|
options+=("Update ucode" "")
|
|
|
|
options+=("" "")
|
|
|
|
options+=("Create entry" "")
|
|
|
|
options+=("Delete entry" "")
|
|
|
|
|
|
|
|
defaultitem="Edit entry"
|
2022-11-10 14:27:23 -07:00
|
|
|
sel=$(dialog --backtitle "$apptitle" --title "Systemd Entries Menu :" --default-item "$defaultitem" --cancel-button "Back" --menu "" 0 0 0 \
|
2019-01-03 16:07:39 -07:00
|
|
|
"${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
|
2022-11-10 14:27:23 -07:00
|
|
|
sel=$(dialog --backtitle "$apptitle" --title "Edit entry :" --cancel-button "Cancel" --menu "" 0 0 0 \
|
2019-01-03 16:07:39 -07:00
|
|
|
"${entrylist[@]}" \
|
|
|
|
3>&1 1>&2 2>&3)
|
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
editfile /boot/loader/entries/$sel.conf
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
'Create entry')
|
2022-11-10 14:27:23 -07:00
|
|
|
entry=$(dialog --backtitle "$apptitle" --title "Create entry" --inputbox "Enter the new entry name :" 0 0 3>&1 1>&2 2>&3)
|
2019-01-03 16:07:39 -07:00
|
|
|
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
|
2022-11-10 14:27:23 -07:00
|
|
|
sel=$(dialog --backtitle "$apptitle" --title "Delete entry :" --cancel-button "Cancel" --menu "" 0 0 0 \
|
2019-01-03 16:07:39 -07:00
|
|
|
"${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
|
2022-11-10 14:27:23 -07:00
|
|
|
sel=$(dialog --backtitle "$apptitle" --title "Update ucode of :" --cancel-button "Cancel" --checklist "" 0 0 0 \
|
2019-01-03 16:07:39 -07:00
|
|
|
"${entrylist[@]}" \
|
|
|
|
3>&1 1>&2 2>&3)
|
|
|
|
if [ "$?" = "0" ]; then
|
2019-01-03 16:17:03 -07:00
|
|
|
endmsg="Nothing to do !"
|
2019-01-03 16:07:39 -07:00
|
|
|
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
|
2019-01-03 16:17:03 -07:00
|
|
|
endmsg=""
|
2019-01-03 16:07:39 -07:00
|
|
|
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
|
2019-01-03 16:17:03 -07:00
|
|
|
endmsg=""
|
2019-01-03 16:07:39 -07:00
|
|
|
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
|
2019-01-03 16:17:03 -07:00
|
|
|
endmsg=""
|
2019-01-03 16:07:39 -07:00
|
|
|
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
|
2019-01-03 16:17:03 -07:00
|
|
|
endmsg=""
|
2019-01-03 16:07:39 -07:00
|
|
|
echo "Remove intel-ucode from $itm"
|
|
|
|
sed -i "/intel-ucode.img/d" /boot/loader/entries/$itm.conf
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2019-01-03 16:17:03 -07:00
|
|
|
echo "$endmsg"
|
2019-01-03 16:07:39 -07:00
|
|
|
pressanykey
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|