mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-20 21:43:11 +00:00
87eff7b775
Blob jail provides device firmware blobs to the OS, so the OS does not have to ship them. The firmware is passed through the initrd to /run/firmware, so it works with both installed and live OSes, and there are no race conditions between firmware load and firmware availability. The injection method in the initrd is specific to the style of init script used by PureOS, since it must add a copy command to copy the firmware from the initrd to /run. If the init script is not of this type, boot proceeds without device firmware. This feature can be enabled or disabled from the config GUI. Blob jail is enabled automatically if the Intel AX200 Wi-Fi module is installed and the feature hasn't been explicitly configured. Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
124 lines
3.6 KiB
Bash
Executable File
124 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Shell functions for common operations using fbwhiptail
|
|
. /etc/functions
|
|
|
|
# Pause for the configured timeout before booting automatically. Returns 0 to
|
|
# continue with automatic boot, nonzero if user interrupted.
|
|
pause_automatic_boot()
|
|
{
|
|
if IFS= read -t "$CONFIG_AUTO_BOOT_TIMEOUT" -s -n 1 -p \
|
|
"Automatic boot in $CONFIG_AUTO_BOOT_TIMEOUT seconds unless interrupted by keypress... "; then
|
|
return 1 # Interrupt automatic boot
|
|
fi
|
|
return 0 # Continue with automatic boot
|
|
}
|
|
|
|
mount_usb()
|
|
{
|
|
TRACE "under gui_functions:mount_usb"
|
|
# Unmount any previous USB device
|
|
if grep -q /media /proc/mounts ; then
|
|
umount /media || die "Unable to unmount /media"
|
|
fi
|
|
# Mount the USB boot device
|
|
mount-usb && USB_FAILED=0 || ( [ $? -eq 5 ] && exit 1 || USB_FAILED=1 )
|
|
if [ $USB_FAILED -ne 0 ]; then
|
|
whiptail $BG_COLOR_ERROR --title 'USB Drive Missing' \
|
|
--msgbox "Insert your USB drive and press Enter to continue." 16 60
|
|
mount-usb && USB_FAILED=0 || ( [ $? -eq 5 ] && exit 1 || USB_FAILED=1 )
|
|
if [ $USB_FAILED -ne 0 ]; then
|
|
whiptail $BG_COLOR_ERROR --title 'ERROR: Mounting /media Failed' \
|
|
--msgbox "Unable to mount USB device" 16 60
|
|
exit 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
file_selector()
|
|
{
|
|
TRACE "under gui_functions:file_selector"
|
|
FILE=""
|
|
FILE_LIST=$1
|
|
MENU_MSG=${2:-"Choose the file"}
|
|
MENU_TITLE=${3:-"Select your File"}
|
|
|
|
# create file menu options
|
|
if [ `cat "$FILE_LIST" | wc -l` -gt 0 ]; then
|
|
option=""
|
|
while [ -z "$option" ]
|
|
do
|
|
MENU_OPTIONS=""
|
|
n=0
|
|
while read option
|
|
do
|
|
n=`expr $n + 1`
|
|
option=$(echo $option | tr " " "_")
|
|
MENU_OPTIONS="$MENU_OPTIONS $n ${option}"
|
|
done < $FILE_LIST
|
|
|
|
MENU_OPTIONS="$MENU_OPTIONS a Abort"
|
|
whiptail --title "${MENU_TITLE}" \
|
|
--menu "${MENU_MSG} [1-$n, a to abort]:" 20 120 8 \
|
|
-- $MENU_OPTIONS \
|
|
2>/tmp/whiptail || die "Aborting"
|
|
|
|
option_index=$(cat /tmp/whiptail)
|
|
|
|
if [ "$option_index" = "a" ]; then
|
|
option="a"
|
|
return
|
|
fi
|
|
|
|
option=`head -n $option_index $FILE_LIST | tail -1`
|
|
if [ "$option" == "a" ]; then
|
|
return
|
|
fi
|
|
done
|
|
if [ -n "$option" ]; then
|
|
FILE=$option
|
|
fi
|
|
else
|
|
whiptail $BG_COLOR_ERROR --title 'ERROR: No Files Found' \
|
|
--msgbox "No Files found matching the pattern. Aborting." 16 60
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
show_system_info()
|
|
{
|
|
TRACE "Under /bin/gui-init:show_system_info"
|
|
battery_charge="$(print_battery_charge)"
|
|
battery_health="$(print_battery_health)"
|
|
if [ -n $battery_charge -a -n $battery_health ];then
|
|
battery_status="\nBattery charge: $battery_charge%\nBattery health: $battery_health%\n"
|
|
fi
|
|
|
|
memtotal=$(cat /proc/meminfo | grep 'MemTotal' | tr -s ' ' | cut -f2 -d ' ')
|
|
memtotal=$((${memtotal} / 1024 / 1024 + 1))
|
|
cpustr=$(cat /proc/cpuinfo | grep 'model name' | uniq | sed -r 's/\(R\)//;s/\(TM\)//;s/CPU //;s/model name.*: //')
|
|
kernel=$(uname -s -r)
|
|
|
|
whiptail $BG_COLOR_MAIN_MENU --title 'System Info' \
|
|
--msgbox "${BOARD_NAME}\n\nFW_VER: ${FW_VER}\nKernel: ${kernel}\n\nCPU: ${cpustr}\nRAM: ${memtotal} GB\n$battery_status\n$(fdisk -l | grep -e '/dev/sd.:' -e '/dev/nvme.*:' | sed 's/B,.*/B/')" 16 60
|
|
}
|
|
|
|
# Get "Enable" or "Disable" to display in the configuration menu, based on a
|
|
# setting value
|
|
get_config_display_action()
|
|
{
|
|
[ "$1" = "y" ] && echo "Disable" || echo "Enable"
|
|
}
|
|
|
|
# Invert a config value
|
|
invert_config()
|
|
{
|
|
[ "$1" = "y" ] && echo "n" || echo "y"
|
|
}
|
|
|
|
# Get "Enable" or "Disable" for a config that internally is inverted (because it
|
|
# disables a behavior that is on by default).
|
|
get_inverted_config_display_action()
|
|
{
|
|
get_config_display_action "$(invert_config "$1")"
|
|
}
|