Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlay management - reverting to previous logic #256

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/json/config.system.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
],
"status": "Stable",
"author": "@viraniac @igorpecovnik",
"condition": "[ -n $OVERLAY_DIR ] && [ -n $BOOT_SOC ]"
"condition": "[ -d /boot/dtb/ ]"
}
]
}
Expand Down
81 changes: 43 additions & 38 deletions tools/modules/system/manage_dtoverlays.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,49 @@ function manage_dtoverlays () {
# check if user agree to enter this area
local changes="false"
local overlayconf="/boot/armbianEnv.txt"
local overlaydir="/boot/dtb/overlay";
[[ "$LINUXFAMILY" == "sunxi64" ]] && overlaydir="/boot/dtb/allwinner/overlay";
[[ "$LINUXFAMILY" == "meson64" ]] && overlaydir="/boot/dtb/amlogic/overlay";
[[ "$LINUXFAMILY" == "rockchip64" || "$LINUXFAMILY" == "rk3399" || "$LINUXFAMILY" == "rockchip-rk3588" || "$LINUXFAMILY" == "rk35xx" ]] && overlaydir="/boot/dtb/rockchip/overlay";

if [[ -z "${OVERLAY_DIR}" ]]; then
show_message <<< "Error: OVERLAY folder not found.\n\nThis feature requires Armbian v24.11.1 or newer!"
else
while true; do
local options=()
j=0
available_overlays=$(ls -1 ${OVERLAY_DIR}/*.dtbo | sed "s#^${OVERLAY_DIR}/##" | sed 's/.dtbo//g' | grep $BOOT_SOC | tr '\n' ' ')
for overlay in ${available_overlays}; do
local status="OFF"
grep '^fdt_overlays' ${overlayconf} | grep -qw ${overlay} && status=ON
options+=( "$overlay" "" "$status")
done
selection=$($DIALOG --title "Manage devicetree overlays" --cancel-button "Back" \
--ok-button "Save" --checklist "\nUse <space> to toggle functions and save them.\nExit when you are done.\n " \
0 0 0 "${options[@]}" 3>&1 1>&2 2>&3)
exit_status=$?
case $exit_status in
0)
changes="true"
newoverlays=$(echo $selection | sed 's/"//g')
sed -i "s/^fdt_overlays=.*/fdt_overlays=$newoverlays/" ${overlayconf}
if ! grep -q "^fdt_overlays" ${overlayconf}; then echo "fdt_overlays=$newoverlays" >> ${overlayconf}; fi
sync
;;
1)
if [[ "$changes" == "true" ]]; then
$DIALOG --title " Reboot required " --yes-button "Reboot" \
--no-button "Cancel" --yesno "A reboot is required to apply the changes. Shall we reboot now?" 7 34
if [[ $? = 0 ]]; then
reboot
fi
fi
break
;;
255)
;;
esac
[[ -f "${overlayconf}" ]] && source "${overlayconf}"
while true; do
local options=()
j=0
if [[ -n "${BOOT_SOC}" ]]; then
available_overlays=$(ls -1 ${overlaydir}/*.dtbo | sed "s#^${overlaydir}/##" | sed 's/.dtbo//g' | grep $BOOT_SOC | tr '\n' ' ')
else
available_overlays=$(ls -1 ${overlaydir}/*.dtbo | sed "s#^${overlaydir}/##" | sed 's/.dtbo//g' | tr '\n' ' ')
fi
for overlay in ${available_overlays}; do
local status="OFF"
grep '^fdt_overlays' ${overlayconf} | grep -qw ${overlay} && status=ON
options+=( "$overlay" "" "$status")
done
fi
selection=$($DIALOG --title "Manage devicetree overlays" --cancel-button "Back" \
--ok-button "Save" --checklist "\nUse <space> to toggle functions and save them.\nExit when you are done.\n " \
0 0 0 "${options[@]}" 3>&1 1>&2 2>&3)
exit_status=$?
case $exit_status in
0)
changes="true"
newoverlays=$(echo $selection | sed 's/"//g')
sed -i "s/^fdt_overlays=.*/fdt_overlays=$newoverlays/" ${overlayconf}
if ! grep -q "^fdt_overlays" ${overlayconf}; then echo "fdt_overlays=$newoverlays" >> ${overlayconf}; fi
sync
;;
1)
if [[ "$changes" == "true" ]]; then
$DIALOG --title " Reboot required " --yes-button "Reboot" \
--no-button "Cancel" --yesno "A reboot is required to apply the changes. Shall we reboot now?" 7 34
if [[ $? = 0 ]]; then
reboot
fi
fi
break
;;
255)
;;
esac
done
}
Loading