mirror of
https://github.com/brain-hackers/brain-config.git
synced 2025-10-14 12:18:42 +09:00
use case to dispatch advanced menu
This commit is contained in:
36
raspi-config
36
raspi-config
@@ -160,7 +160,7 @@ set_overscan() {
|
||||
fi
|
||||
}
|
||||
|
||||
do_A1() { # Overscan
|
||||
do_overscan() {
|
||||
whiptail --yesno "What would you like to do with overscan" 20 60 2 \
|
||||
--yes-button Disable --no-button Enable
|
||||
RET=$?
|
||||
@@ -192,7 +192,7 @@ do_change_timezone() {
|
||||
dpkg-reconfigure tzdata
|
||||
}
|
||||
|
||||
do_A2() { # Hostname
|
||||
do_change_hostname() {
|
||||
whiptail --msgbox "\
|
||||
Please note: RFCs mandate that a hostname's labels \
|
||||
may contain only the ASCII letters 'a' through 'z' (case-insensitive),
|
||||
@@ -210,7 +210,7 @@ No other symbols, punctuation characters, or blank spaces are permitted.\
|
||||
fi
|
||||
}
|
||||
|
||||
do_A3() { # Memory Split
|
||||
do_memory_split() { # Memory Split
|
||||
if [ -e /boot/start_cd.elf ]; then
|
||||
# New-style memory split setting
|
||||
if ! mountpoint -q /boot; then
|
||||
@@ -262,7 +262,7 @@ set_memory_split() {
|
||||
sync
|
||||
}
|
||||
|
||||
do_A4() { # Overclock
|
||||
do_overclock() {
|
||||
whiptail --msgbox "\
|
||||
Be aware that overclocking may reduce the lifetime of your
|
||||
Raspberry Pi. If overclocking at a certain level causes
|
||||
@@ -352,7 +352,7 @@ EOF
|
||||
whiptail --msgbox "Set overclock to preset '$1'" 20 60 2
|
||||
}
|
||||
|
||||
do_A5() { # Enable/Disable SSH
|
||||
do_ssh() {
|
||||
if [ -e /var/log/regen_ssh_keys.log ] && ! grep -q "^finished" /var/log/regen_ssh_keys.log; then
|
||||
whiptail --msgbox "Initial ssh key generation still running. Please wait and try again." 20 60 2
|
||||
return 1
|
||||
@@ -451,7 +451,7 @@ do_camera() {
|
||||
fi
|
||||
}
|
||||
|
||||
do_A6() { # Update raspi-config
|
||||
do_update() {
|
||||
apt-get update &&
|
||||
apt-get install raspi-config &&
|
||||
printf "Sleeping 5 seconds before reloading raspi-config\n" &&
|
||||
@@ -545,18 +545,26 @@ do_internationalisation_menu() {
|
||||
|
||||
do_advanced_menu() {
|
||||
FUN=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --menu "Advanced Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
|
||||
"A1 Overscan" "You may need to configure overscan if black bars are present on display" \
|
||||
"A2 Hostname" "Set the visible name for this Pi on a network" \
|
||||
"A3 Memory Split" "Change the amount of memory made available to the GPU" \
|
||||
"A4 Overclock" "Configure overclocking for your Pi" \
|
||||
"A5 SSH" "Enable/Disable remote command line access to your Pi using SSH" \
|
||||
"A6 Update" "Update this tool to the latest version" \
|
||||
3>&1 1>&2 2>&3)
|
||||
"A1 Overscan" "You may need to configure overscan if black bars are present on display" \
|
||||
"A2 Hostname" "Set the visible name for this Pi on a network" \
|
||||
"A3 Memory Split" "Change the amount of memory made available to the GPU" \
|
||||
"A4 Overclock" "Configure overclocking for your Pi" \
|
||||
"A5 SSH" "Enable/Disable remote command line access to your Pi using SSH" \
|
||||
"A6 Update" "Update this tool to the latest version" \
|
||||
3>&1 1>&2 2>&3)
|
||||
RET=$?
|
||||
if [ $RET -eq 1 ]; then
|
||||
return 0
|
||||
elif [ $RET -eq 0 ]; then
|
||||
"do_$(echo $FUN | head -c 2)" || whiptail --msgbox "There was an error running option $FUN" 20 60 1
|
||||
case "$FUN" in
|
||||
A1\ *) do_overscan ;;
|
||||
A2\ *) do_change_hostname ;;
|
||||
A3\ *) do_memory_split ;;
|
||||
A4\ *) do_overclock ;;
|
||||
A5\ *) do_ssh ;;
|
||||
A6\ *) do_update ;;
|
||||
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
|
||||
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user