From 4673a0b824aabb3ec9b784cf53ba867762677af8 Mon Sep 17 00:00:00 2001 From: Alex Bradbury Date: Wed, 22 May 2013 20:21:24 +0100 Subject: [PATCH] use case to dispatch advanced menu --- debian/files | 1 + debian/raspi-config.debhelper.log | 45 ++ debian/raspi-config.substvars | 1 + debian/raspi-config/DEBIAN/control | 10 + debian/raspi-config/DEBIAN/md5sums | 4 + debian/raspi-config/usr/bin/raspi-config | 540 ++++++++++++++++++ .../usr/share/doc/raspi-config/LICENSE | 26 + .../usr/share/doc/raspi-config/changelog.gz | Bin 0 -> 674 bytes .../doc/raspi-config/sample_profile_d.sh | 18 + raspi-config | 36 +- 10 files changed, 667 insertions(+), 14 deletions(-) create mode 100644 debian/files create mode 100644 debian/raspi-config.debhelper.log create mode 100644 debian/raspi-config.substvars create mode 100644 debian/raspi-config/DEBIAN/control create mode 100644 debian/raspi-config/DEBIAN/md5sums create mode 100755 debian/raspi-config/usr/bin/raspi-config create mode 100644 debian/raspi-config/usr/share/doc/raspi-config/LICENSE create mode 100644 debian/raspi-config/usr/share/doc/raspi-config/changelog.gz create mode 100644 debian/raspi-config/usr/share/doc/raspi-config/sample_profile_d.sh diff --git a/debian/files b/debian/files new file mode 100644 index 0000000..90c48a8 --- /dev/null +++ b/debian/files @@ -0,0 +1 @@ +raspi-config_20130520_all.deb unknown extra diff --git a/debian/raspi-config.debhelper.log b/debian/raspi-config.debhelper.log new file mode 100644 index 0000000..2d06fcd --- /dev/null +++ b/debian/raspi-config.debhelper.log @@ -0,0 +1,45 @@ +dh_auto_configure +dh_auto_build +dh_auto_test +dh_prep +dh_installdirs +dh_auto_install +dh_install +dh_installdocs +dh_installchangelogs +dh_installexamples +dh_installman +dh_installcatalogs +dh_installcron +dh_installdebconf +dh_installemacsen +dh_installifupdown +dh_installinfo +dh_pysupport +dh_installinit +dh_installmenu +dh_installmime +dh_installmodules +dh_installlogcheck +dh_installlogrotate +dh_installpam +dh_installppp +dh_installudev +dh_installwm +dh_installxfonts +dh_bugfiles +dh_lintian +dh_gconf +dh_icons +dh_perl +dh_usrlocal +dh_link +dh_compress +dh_fixperms +dh_strip +dh_makeshlibs +dh_shlibdeps +dh_installdeb +dh_gencontrol +dh_md5sums +dh_builddeb diff --git a/debian/raspi-config.substvars b/debian/raspi-config.substvars new file mode 100644 index 0000000..abd3ebe --- /dev/null +++ b/debian/raspi-config.substvars @@ -0,0 +1 @@ +misc:Depends= diff --git a/debian/raspi-config/DEBIAN/control b/debian/raspi-config/DEBIAN/control new file mode 100644 index 0000000..d90b3f4 --- /dev/null +++ b/debian/raspi-config/DEBIAN/control @@ -0,0 +1,10 @@ +Package: raspi-config +Version: 20130520 +Architecture: all +Maintainer: Alex Bradbury +Installed-Size: 56 +Depends: whiptail, parted, lua5.1, triggerhappy +Section: unknown +Priority: extra +Homepage: https://github.com/asb/raspi-config +Description: Simple configuration for Raspberry Pi diff --git a/debian/raspi-config/DEBIAN/md5sums b/debian/raspi-config/DEBIAN/md5sums new file mode 100644 index 0000000..d0614af --- /dev/null +++ b/debian/raspi-config/DEBIAN/md5sums @@ -0,0 +1,4 @@ +2fd8412db2073efef03c425b3b9c57e2 usr/bin/raspi-config +87c25b1874010cc3f7a251d7956b4e57 usr/share/doc/raspi-config/LICENSE +e5562803adb62bec2cb741c62987e7a1 usr/share/doc/raspi-config/changelog.gz +2cc747f451e60b002ce7f4051749e654 usr/share/doc/raspi-config/sample_profile_d.sh diff --git a/debian/raspi-config/usr/bin/raspi-config b/debian/raspi-config/usr/bin/raspi-config new file mode 100755 index 0000000..e371c0c --- /dev/null +++ b/debian/raspi-config/usr/bin/raspi-config @@ -0,0 +1,540 @@ +#!/bin/sh +# Part of raspi-config http://github.com/asb/raspi-config +# +# See LICENSE file for copyright and license details + +INTERACTIVE=True +ASK_TO_REBOOT=0 + +do_info() { + whiptail --msgbox "\ +This tool provides a straight-forward way of doing initial +configuration of the Raspberry Pi. Although it can be run +at any time, some of the options may have difficulties if +you have heavily customised your installation.\ +" 20 70 1 +} + +do_expand_rootfs() { + if ! [ -h /dev/root ]; then + whiptail --msgbox "/dev/root does not exist or is not a symlink. Don't know how to expand" 20 60 2 + return 0 + fi + + ROOT_PART=$(readlink /dev/root) + PART_NUM=${ROOT_PART#mmcblk0p} + if [ "$PART_NUM" = "$ROOT_PART" ]; then + whiptail --msgbox "/dev/root is not an SD card. Don't know how to expand" 20 60 2 + return 0 + fi + + LAST_PART_NUM=$(parted /dev/mmcblk0 -ms unit s p | tail -n 1 | cut -f 1 -d:) + + if [ "$LAST_PART_NUM" != "$PART_NUM" ]; then + whiptail --msgbox "/dev/root is not the last partition. Don't know how to expand" 20 60 2 + return 0 + fi + + # Get the starting offset of the root partition + PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d:) + [ "$PART_START" ] || return 1 + # Return value will likely be error for fdisk as it fails to reload the + # partition table because the root fs is mounted + fdisk /dev/mmcblk0 < /etc/init.d/resize2fs_once && +#!/bin/sh +### BEGIN INIT INFO +# Provides: resize2fs_once +# Required-Start: +# Required-Stop: +# Default-Start: 2 3 4 5 S +# Default-Stop: +# Short-Description: Resize the root filesystem to fill partition +# Description: +### END INIT INFO + +. /lib/lsb/init-functions + +case "$1" in + start) + log_daemon_msg "Starting resize2fs_once" && + resize2fs /dev/root && + rm /etc/init.d/resize2fs_once && + update-rc.d resize2fs_once remove && + log_end_msg $? + ;; + *) + echo "Usage: $0 start" >&2 + exit 3 + ;; +esac +EOF + chmod +x /etc/init.d/resize2fs_once && + update-rc.d resize2fs_once defaults && + if [ "$INTERACTIVE" = True ]; then + whiptail --msgbox "Root partition has been resized.\nThe filesystem will be enlarged upon the next reboot" 20 60 2 + fi +} + +set_config_var() { + lua - "$1" "$2" "$3" < "$3.bak" +local key=assert(arg[1]) +local value=assert(arg[2]) +local fn=assert(arg[3]) +local file=assert(io.open(fn)) +local made_change=false +for line in file:lines() do + if line:match("^#?%s*"..key.."=.*$") then + line=key.."="..value + made_change=true + end + print(line) +end + +if not made_change then + print(key.."="..value) +end +EOF +mv "$3.bak" "$3" +} + +get_config_var() { + lua - "$1" "$2" <&1 1>&2 2>&3) + if [ $? -eq 0 ]; then + echo $NEW_HOSTNAME > /etc/hostname + sed -i "s/127.0.1.1.*$CURRENT_HOSTNAME/127.0.1.1\t$NEW_HOSTNAME/g" /etc/hosts + ASK_TO_REBOOT=1 + fi +} + +do_memory_split() { + if [ -e /boot/start_cd.elf ]; then + # New-style memory split setting + if ! mountpoint -q /boot; then + return 1 + fi + ## get current memory split from /boot/config.txt + CUR_GPU_MEM=$(get_config_var gpu_mem /boot/config.txt) + [ -z "$CUR_GPU_MEM" ] && CUR_GPU_MEM=64 + ## ask users what gpu_mem they want + NEW_GPU_MEM=$(whiptail --inputbox "How much memory should the GPU have? e.g. 16/32/64/128/256" \ + 20 70 -- "$CUR_GPU_MEM" 3>&1 1>&2 2>&3) + if [ $? -eq 0 ]; then + set_config_var gpu_mem "$NEW_GPU_MEM" /boot/config.txt + ASK_TO_REBOOT=1 + fi + else # Old firmware so do start.elf renaming + get_current_memory_split + MEMSPLIT=$(whiptail --menu "Set memory split.\n$MEMSPLIT_DESCRIPTION" 20 60 10 \ + "240" "240MiB for ARM, 16MiB for VideoCore" \ + "224" "224MiB for ARM, 32MiB for VideoCore" \ + "192" "192MiB for ARM, 64MiB for VideoCore" \ + "128" "128MiB for ARM, 128MiB for VideoCore" \ + 3>&1 1>&2 2>&3) + if [ $? -eq 0 ]; then + set_memory_split ${MEMSPLIT} + ASK_TO_REBOOT=1 + fi + fi +} + +get_current_memory_split() { + # Stop if /boot is not a mountpoint + if ! mountpoint -q /boot; then + return 1 + fi + AVAILABLE_SPLITS="128 192 224 240" + MEMSPLIT_DESCRIPTION="" + for SPLIT in $AVAILABLE_SPLITS;do + if [ -e /boot/arm${SPLIT}_start.elf ] && cmp /boot/arm${SPLIT}_start.elf /boot/start.elf >/dev/null 2>&1;then + CURRENT_MEMSPLIT=$SPLIT + MEMSPLIT_DESCRIPTION="Current: ${CURRENT_MEMSPLIT}MiB for ARM, $((256 - $CURRENT_MEMSPLIT))MiB for VideoCore" + break + fi + done +} + +set_memory_split() { + cp -a /boot/arm${1}_start.elf /boot/start.elf + sync +} + +do_overclock() { + whiptail --msgbox "\ +Be aware that overclocking may reduce the lifetime of your +Raspberry Pi. If overclocking at a certain level causes +system instability, try a more modest overclock. Hold down +shift during boot to temporarily disable overclock. +See http://elinux.org/RPi_Overclocking for more information.\ +" 20 70 1 + OVERCLOCK=$(whiptail --menu "Chose overclock preset" 20 60 10 \ + "None" "700MHz ARM, 250MHz core, 400MHz SDRAM, 0 overvolt" \ + "Modest" "800MHz ARM, 250MHz core, 400MHz SDRAM, 0 overvolt" \ + "Medium" "900MHz ARM, 250MHz core, 450MHz SDRAM, 2 overvolt" \ + "High" "950MHz ARM, 250MHz core, 450MHz SDRAM, 6 overvolt" \ + "Turbo" "1000MHz ARM, 500MHz core, 600MHz SDRAM, 6 overvolt" \ + 3>&1 1>&2 2>&3) + if [ $? -eq 0 ]; then + case "$OVERCLOCK" in + None) + set_overclock None 700 250 400 0 + ;; + Modest) + set_overclock Modest 800 250 400 0 + ;; + Medium) + set_overclock Medium 900 250 450 2 + ;; + High) + set_overclock High 950 250 450 6 + ;; + Turbo) + whiptail --msgbox "Warning: some people have reported SD card corruption with this level of overclock." \ + 20 70 1 + [ $? -ne 0 ] && return 1 + set_overclock Turbo 1000 500 600 6 + ;; + *) + whiptail --msgbox "Programmer error, unrecognised overclock preset" 20 60 2 + return 1 + ;; + esac + ASK_TO_REBOOT=1 + fi +} + +set_overclock() { + set_config_var arm_freq $2 /boot/config.txt && + set_config_var core_freq $3 /boot/config.txt && + set_config_var sdram_freq $4 /boot/config.txt && + set_config_var over_voltage $5 /boot/config.txt && + # now set up an init.d script +cat <<\EOF > /etc/init.d/switch_cpu_governor && +#!/bin/sh +### BEGIN INIT INFO +# Provides: switch_cpu_governor +# Required-Start: udev mountkernfs $remote_fs +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Switch to ondemand cpu governor (unless shift key is pressed) +# Description: +### END INIT INFO + +. /lib/lsb/init-functions + +case "$1" in + start) + log_daemon_msg "Checking if shift key is held down" + timeout 1 thd --dump /dev/input/event* | grep -q "LEFTSHIFT\|RIGHTSHIFT" + if [ $? -eq 0 ]; then + printf " Yes. Not switching scaling governor" + log_end_msg 0 + else + SYS_CPUFREQ_GOVERNOR=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + [ -e $SYS_CPUFREQ_GOVERNOR ] && echo "ondemand" > $SYS_CPUFREQ_GOVERNOR + echo 70 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold + printf " No. Switching to ondemand scaling governor" + log_end_msg 0 + fi + ;; + *) + echo "Usage: $0 start" >&2 + exit 3 + ;; +esac +EOF + chmod +x /etc/init.d/switch_cpu_governor && + update-rc.d switch_cpu_governor defaults && + whiptail --msgbox "Set overclock to preset '$1'" 20 60 2 +} + +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 + fi + whiptail --yesno "Would you like the SSH server enabled or disabled?" 20 60 2 \ + --yes-button Enable --no-button Disable + RET=$? + if [ $RET -eq 0 ]; then + update-rc.d ssh enable && + invoke-rc.d ssh start && + whiptail --msgbox "SSH server enabled" 20 60 1 + elif [ $RET -eq 1 ]; then + update-rc.d ssh disable && + whiptail --msgbox "SSH server disabled" 20 60 1 + else + return $RET + fi +} + +do_boot_behaviour() { + if [ -e /etc/init.d/lightdm ]; then + whiptail --yesno "Should we boot straight to desktop?" 20 60 2 + RET=$? + if [ $RET -eq 0 ]; then # yes + update-rc.d lightdm enable 2 + sed /etc/lightdm/lightdm.conf -i -e "s/^#autologin-user=.*/autologin-user=pi/" + ASK_TO_REBOOT=1 + elif [ $RET -eq 1 ]; then # no + update-rc.d lightdm disable 2 + ASK_TO_REBOOT=1 + else # user hit escape + return 1 + fi + else + whiptail --msgbox "Do sudo apt-get install lightdm to allow configuration of boot to desktop" 20 60 2 + return 1 + fi +} + +do_rastrack() { + whiptail --msgbox "\ +Rastrack (http://rastrack.co.uk) is a website run by Ryan Walmsley +for tracking where people are using Raspberry Pis around the world. +If you have an internet connection, you can add yourself directly +using this tool. This is just a bit of fun, not any sort of official +registration.\ +" 20 70 1 + if [ $? -ne 0 ]; then + return 0; + fi + UNAME=$(whiptail --inputbox "Username / Nickname For Rastrack Addition" 20 70 3>&1 1>&2 2>&3) + if [ $? -ne 0 ]; then + return 1; + fi + EMAIL=$(whiptail --inputbox "Email Address For Rastrack Addition" 20 70 3>&1 1>&2 2>&3) + if [ $? -ne 0 ]; then + return 1; + fi + curl --data "name=$UNAME&email=$EMAIL" http://rastrack.co.uk/api.php + printf "Hit enter to continue\n" + read TMP +} + +# $1 is 0 to disable camera, 1 to enable it +set_camera() { + # Stop if /boot is not a mountpoint + if ! mountpoint -q /boot; then + return 1 + fi + + [ -e /boot/config.txt ] || touch /boot/config.txt + + if [ "$1" -eq 0 ]; then # disable camera + set_config_var start_file start.elf /boot/config.txt + set_config_var fixup_file fixup.dat /boot/config.txt + else # enable camera + set_config_var start_file start_x.elf /boot/config.txt + set_config_var fixup_file fixup_x.dat /boot/config.txt + set_config_var gpu_mem 128 /boot/config.txt + fi +} + +do_camera() { + if [ ! -e /boot/start_x.elf ]; then + whiptail --msgbox "Your firmware appears to be out of date (no start_x.elf). Please update" 20 60 2 + return 1 + fi + whiptail --yesno "Enable support for Raspberry Pi camera?" 20 60 2 \ + --yes-button Disable --no-button Enable + RET=$? + if [ $RET -eq 0 ] || [ $RET -eq 1 ]; then + ASK_TO_REBOOT=1 + set_camera $RET; + else + return 1 + fi +} + +do_update() { + apt-get update && + apt-get install raspi-config && + printf "Sleeping 5 seconds before reloading raspi-config\n" && + sleep 5 && + exec raspi-config +} + +do_finish() { + if [ -e /etc/profile.d/raspi-config.sh ]; then + rm -f /etc/profile.d/raspi-config.sh + sed -i /etc/inittab \ + -e "s/^#\(.*\)#\s*RPICFG_TO_ENABLE\s*/\1/" \ + -e "/#\s*RPICFG_TO_DISABLE/d" + telinit q + fi + if [ $ASK_TO_REBOOT -eq 1 ]; then + whiptail --yesno "Would you like to reboot now?" 20 60 2 + if [ $? -eq 0 ]; then # yes + sync + reboot + fi + fi + exit 0 +} + +# +# Command line options for non-interactive use +# +for i in $* +do + case $i in + --memory-split) + OPT_MEMORY_SPLIT=GET + printf "Not currently supported\n" + exit 1 + ;; + --memory-split=*) + OPT_MEMORY_SPLIT=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` + printf "Not currently supported\n" + exit 1 + ;; + --expand-rootfs) + INTERACTIVE=False + do_expand_rootfs + printf "Please reboot\n" + exit 0 + ;; + *) + # unknown option + ;; + esac +done + +#if [ "GET" = "${OPT_MEMORY_SPLIT:-}" ]; then +# set -u # Fail on unset variables +# get_current_memory_split +# echo $CURRENT_MEMSPLIT +# exit 0 +#fi + +# Everything else needs to be run as root +if [ $(id -u) -ne 0 ]; then + printf "Script must be run as root. Try 'sudo raspi-config'\n" + exit 1 +fi + +if [ -n "${OPT_MEMORY_SPLIT:-}" ]; then + set -e # Fail when a command errors + set_memory_split "${OPT_MEMORY_SPLIT}" + exit 0 +fi + +# +# Interactive use loop +# +while true; do + FUN=$(whiptail --menu "Raspi-config" 20 80 13 --cancel-button Finish --ok-button Select \ + "info" "Information about this tool" \ + "expand_rootfs" "Expand root partition to fill SD card" \ + "overscan" "Change overscan" \ + "configure_keyboard" "Set keyboard layout" \ + "change_pass" "Change password for 'pi' user" \ + "change_locale" "Set locale" \ + "change_timezone" "Set timezone" \ + "change_hostname" "Set hostname" \ + "memory_split" "Change memory split" \ + "overclock" "Configure overclocking" \ + "ssh" "Enable or disable ssh server" \ + "boot_behaviour" "Start desktop on boot?" \ + "camera" "Enable/Disable camera addon support" \ + "rastrack" "Add this Pi to the Raspberry Pi Map - Rastrack" \ + "update" "Try to upgrade raspi-config" \ + 3>&1 1>&2 2>&3) + RET=$? + if [ $RET -eq 1 ]; then + do_finish + elif [ $RET -eq 0 ]; then + "do_$FUN" || whiptail --msgbox "There was an error running do_$FUN" 20 60 1 + else + exit 1 + fi +done diff --git a/debian/raspi-config/usr/share/doc/raspi-config/LICENSE b/debian/raspi-config/usr/share/doc/raspi-config/LICENSE new file mode 100644 index 0000000..dd318ed --- /dev/null +++ b/debian/raspi-config/usr/share/doc/raspi-config/LICENSE @@ -0,0 +1,26 @@ +raspi-config is licensed under the terms of the MIT license reproduced below. + +##################################################### + +Copyright (c) 2012 Alex Bradbury + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/debian/raspi-config/usr/share/doc/raspi-config/changelog.gz b/debian/raspi-config/usr/share/doc/raspi-config/changelog.gz new file mode 100644 index 0000000000000000000000000000000000000000..c4875d6106e12e3dbb550a204bd3a421cc1a2b20 GIT binary patch literal 674 zcmV;T0$u$diwFP!000021C^CqPuoBch2Qfl<`LSstnGv(?nO;ip@NEvNDGf>V^5rw z*Sqds2>$mSJB9{{81i66zU=Hd=bPCWZYvR_TCGG5M-dBSHjdaacx4@5O8f}k5@&W-LDz36SqqSRE*l1ILSiwn#_b1IW5Ec~uSftV!RNOe>gjQ4`2w*Pp z0lpcYExoDX6SvE+banS1w8_5!TxvChh|z8}G_oL^C8KG=B6!b2#s&lPg7R?OtNf?l zpnmKki;s6gMNNu^E;q4KxOyv1w?;rO}CNit%+GW!FbXBlQ-eN}1W zV5JQh%!PGmNE&DbRMQ!r7I5U&Too3sYp&py%hF1$k9UgjrI5na;54Cdu-4WoUgFcj zxylS~VBxgF-E~2*1srsMb=A;&T6QA}N3yPvG+C?Fo-I)|4&j<2SfZf}uLPvDz2T4U z-X8Rs5ft=pKSW8B_5OZ{LKaPXgZ@)x+~G6wom1Ps|1NB6Ak}5rgdv5(#}8UAN~=I9 z3W29i+#`64?ZQRJPEodbRbuZ8jaW`5DiU&Y(;%~_@vK$-hqgdkR>ec0WmpD>49BAVlKSwVr!3` zc-9l!X*lT>b0!|3zOV@)75(jSNgW`O({LUrhV6(MC*xT{^0u`90Za&q IjW`DY0CWXRg8%>k literal 0 HcmV?d00001 diff --git a/debian/raspi-config/usr/share/doc/raspi-config/sample_profile_d.sh b/debian/raspi-config/usr/share/doc/raspi-config/sample_profile_d.sh new file mode 100644 index 0000000..17ad7bd --- /dev/null +++ b/debian/raspi-config/usr/share/doc/raspi-config/sample_profile_d.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# Part of raspi-config http://github.com/asb/raspi-config +# +# See LICENSE file for copyright and license details + +# Should be installed to /etc/profile.d/raspi-config.sh to force raspi-config +# to run at initial login + +# You may also want to set automatic login in /etc/inittab on tty1 by adding a +# line such as: +# 1:2345:respawn:/bin/login -f root tty1 /dev/tty1 2>&1 # RPICFG_TO_DISABLE + +if [ $(id -u) -ne 0 ]; then + printf "\nNOTICE: the software on this Raspberry Pi has not been fully configured. Please run 'sudo raspi-config'\n\n" +else + raspi-config + exec login -f pi +fi diff --git a/raspi-config b/raspi-config index 88c3919..1fb30ee 100755 --- a/raspi-config +++ b/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 }