Convert all tabs into spaces (#70)

This commit is contained in:
Nick Lee 2017-10-30 20:20:14 +08:00 committed by XECDesign
parent b346f4edae
commit 3929227971

View File

@ -9,8 +9,8 @@ BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf
CONFIG=/boot/config.txt CONFIG=/boot/config.txt
is_pi () { is_pi () {
grep -q "^model name\s*:\s*ARMv" /proc/cpuinfo grep -q "^model name\s*:\s*ARMv" /proc/cpuinfo
return $? return $?
} }
if is_pi ; then if is_pi ; then
@ -370,19 +370,19 @@ do_memory_split() { # Memory Split
if [ -e /boot/start_cd.elf ]; then if [ -e /boot/start_cd.elf ]; then
# New-style memory split setting # New-style memory split setting
## get current memory split from /boot/config.txt ## get current memory split from /boot/config.txt
arm=$(vcgencmd get_mem arm | cut -d '=' -f 2 | cut -d 'M' -f 1) arm=$(vcgencmd get_mem arm | cut -d '=' -f 2 | cut -d 'M' -f 1)
gpu=$(vcgencmd get_mem gpu | cut -d '=' -f 2 | cut -d 'M' -f 1) gpu=$(vcgencmd get_mem gpu | cut -d '=' -f 2 | cut -d 'M' -f 1)
tot=$(($arm+$gpu)) tot=$(($arm+$gpu))
if [ $tot -gt 512 ]; then if [ $tot -gt 512 ]; then
CUR_GPU_MEM=$(get_config_var gpu_mem_1024 $CONFIG) CUR_GPU_MEM=$(get_config_var gpu_mem_1024 $CONFIG)
elif [ $tot -gt 256 ]; then elif [ $tot -gt 256 ]; then
CUR_GPU_MEM=$(get_config_var gpu_mem_512 $CONFIG) CUR_GPU_MEM=$(get_config_var gpu_mem_512 $CONFIG)
else else
CUR_GPU_MEM=$(get_config_var gpu_mem_256 $CONFIG) CUR_GPU_MEM=$(get_config_var gpu_mem_256 $CONFIG)
fi fi
if [ -z "$CUR_GPU_MEM" ] || [ $CUR_GPU_MEM = "0" ]; then if [ -z "$CUR_GPU_MEM" ] || [ $CUR_GPU_MEM = "0" ]; then
CUR_GPU_MEM=$(get_config_var gpu_mem $CONFIG) CUR_GPU_MEM=$(get_config_var gpu_mem $CONFIG)
fi fi
[ -z "$CUR_GPU_MEM" ] || [ $CUR_GPU_MEM = "0" ] && CUR_GPU_MEM=64 [ -z "$CUR_GPU_MEM" ] || [ $CUR_GPU_MEM = "0" ] && CUR_GPU_MEM=64
## ask users what gpu_mem they want ## ask users what gpu_mem they want
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
@ -393,14 +393,14 @@ do_memory_split() { # Memory Split
true true
fi fi
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
if [ $(get_config_var gpu_mem_1024 $CONFIG) != "0" ] || [ $(get_config_var gpu_mem_512 $CONFIG) != "0" ] || [ $(get_config_var gpu_mem_256 $CONFIG) != "0" ]; then if [ $(get_config_var gpu_mem_1024 $CONFIG) != "0" ] || [ $(get_config_var gpu_mem_512 $CONFIG) != "0" ] || [ $(get_config_var gpu_mem_256 $CONFIG) != "0" ]; then
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "Device-specific memory settings were found. These have been cleared." 20 60 2 whiptail --msgbox "Device-specific memory settings were found. These have been cleared." 20 60 2
fi fi
clear_config_var gpu_mem_1024 $CONFIG clear_config_var gpu_mem_1024 $CONFIG
clear_config_var gpu_mem_512 $CONFIG clear_config_var gpu_mem_512 $CONFIG
clear_config_var gpu_mem_256 $CONFIG clear_config_var gpu_mem_256 $CONFIG
fi fi
set_config_var gpu_mem "$NEW_GPU_MEM" $CONFIG set_config_var gpu_mem "$NEW_GPU_MEM" $CONFIG
ASK_TO_REBOOT=1 ASK_TO_REBOOT=1
fi fi
@ -930,32 +930,32 @@ do_boot_splash() {
RET=$1 RET=$1
fi fi
if [ $RET -eq 0 ]; then if [ $RET -eq 0 ]; then
if is_pi ; then if is_pi ; then
if ! grep -q "splash" $CMDLINE ; then if ! grep -q "splash" $CMDLINE ; then
sed -i $CMDLINE -e "s/$/ quiet splash plymouth.ignore-serial-consoles/" sed -i $CMDLINE -e "s/$/ quiet splash plymouth.ignore-serial-consoles/"
fi fi
else else
sed -i /etc/default/grub -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\"\(.*\)\"/GRUB_CMDLINE_LINUX_DEFAULT=\"\1 quiet splash plymouth.ignore-serial-consoles\"/" sed -i /etc/default/grub -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\"\(.*\)\"/GRUB_CMDLINE_LINUX_DEFAULT=\"\1 quiet splash plymouth.ignore-serial-consoles\"/"
sed -i /etc/default/grub -e "s/ \+/ /g" sed -i /etc/default/grub -e "s/ \+/ /g"
sed -i /etc/default/grub -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\" /GRUB_CMDLINE_LINUX_DEFAULT=\"/" sed -i /etc/default/grub -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\" /GRUB_CMDLINE_LINUX_DEFAULT=\"/"
update-grub update-grub
fi fi
STATUS=enabled STATUS=enabled
elif [ $RET -eq 1 ]; then elif [ $RET -eq 1 ]; then
if is_pi ; then if is_pi ; then
if grep -q "splash" $CMDLINE ; then if grep -q "splash" $CMDLINE ; then
sed -i $CMDLINE -e "s/ quiet//" sed -i $CMDLINE -e "s/ quiet//"
sed -i $CMDLINE -e "s/ splash//" sed -i $CMDLINE -e "s/ splash//"
sed -i $CMDLINE -e "s/ plymouth.ignore-serial-consoles//" sed -i $CMDLINE -e "s/ plymouth.ignore-serial-consoles//"
fi fi
else else
sed -i /etc/default/grub -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\"\(.*\)quiet\(.*\)\"/GRUB_CMDLINE_LINUX_DEFAULT=\"\1\2\"/" sed -i /etc/default/grub -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\"\(.*\)quiet\(.*\)\"/GRUB_CMDLINE_LINUX_DEFAULT=\"\1\2\"/"
sed -i /etc/default/grub -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\"\(.*\)splash\(.*\)\"/GRUB_CMDLINE_LINUX_DEFAULT=\"\1\2\"/" sed -i /etc/default/grub -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\"\(.*\)splash\(.*\)\"/GRUB_CMDLINE_LINUX_DEFAULT=\"\1\2\"/"
sed -i /etc/default/grub -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\"\(.*\)plymouth.ignore-serial-consoles\(.*\)\"/GRUB_CMDLINE_LINUX_DEFAULT=\"\1\2\"/" sed -i /etc/default/grub -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\"\(.*\)plymouth.ignore-serial-consoles\(.*\)\"/GRUB_CMDLINE_LINUX_DEFAULT=\"\1\2\"/"
sed -i /etc/default/grub -e "s/ \+/ /g" sed -i /etc/default/grub -e "s/ \+/ /g"
sed -i /etc/default/grub -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\" /GRUB_CMDLINE_LINUX_DEFAULT=\"/" sed -i /etc/default/grub -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\" /GRUB_CMDLINE_LINUX_DEFAULT=\"/"
update-grub update-grub
fi fi
STATUS=disabled STATUS=disabled
else else
return $RET return $RET
@ -1119,22 +1119,22 @@ do_gldriver() {
if ! grep -q -E "^dtoverlay=vc4-kms-v3d" $CONFIG; then if ! grep -q -E "^dtoverlay=vc4-kms-v3d" $CONFIG; then
ASK_TO_REBOOT=1 ASK_TO_REBOOT=1
fi fi
sed $CONFIG -i -e "s/^dtoverlay=vc4-fkms-v3d/#dtoverlay=vc4-fkms-v3d/" sed $CONFIG -i -e "s/^dtoverlay=vc4-fkms-v3d/#dtoverlay=vc4-fkms-v3d/"
sed $CONFIG -i -e "s/^#dtoverlay=vc4-kms-v3d/dtoverlay=vc4-kms-v3d/" sed $CONFIG -i -e "s/^#dtoverlay=vc4-kms-v3d/dtoverlay=vc4-kms-v3d/"
if ! grep -q -E "^dtoverlay=vc4-kms-v3d" $CONFIG; then if ! grep -q -E "^dtoverlay=vc4-kms-v3d" $CONFIG; then
printf "dtoverlay=vc4-kms-v3d\n" >> $CONFIG printf "dtoverlay=vc4-kms-v3d\n" >> $CONFIG
fi fi
STATUS="The full KMS GL driver is enabled." STATUS="The full KMS GL driver is enabled."
;; ;;
G2*) G2*)
if ! grep -q -E "^dtoverlay=vc4-fkms-v3d" $CONFIG; then if ! grep -q -E "^dtoverlay=vc4-fkms-v3d" $CONFIG; then
ASK_TO_REBOOT=1 ASK_TO_REBOOT=1
fi fi
sed $CONFIG -i -e "s/^dtoverlay=vc4-kms-v3d/#dtoverlay=vc4-kms-v3d/" sed $CONFIG -i -e "s/^dtoverlay=vc4-kms-v3d/#dtoverlay=vc4-kms-v3d/"
sed $CONFIG -i -e "s/^#dtoverlay=vc4-fkms-v3d/dtoverlay=vc4-fkms-v3d/" sed $CONFIG -i -e "s/^#dtoverlay=vc4-fkms-v3d/dtoverlay=vc4-fkms-v3d/"
if ! grep -q -E "^dtoverlay=vc4-fkms-v3d" $CONFIG; then if ! grep -q -E "^dtoverlay=vc4-fkms-v3d" $CONFIG; then
printf "dtoverlay=vc4-fkms-v3d\n" >> $CONFIG printf "dtoverlay=vc4-fkms-v3d\n" >> $CONFIG
fi fi
STATUS="The fake KMS GL driver is enabled." STATUS="The fake KMS GL driver is enabled."
;; ;;
G3*) G3*)
@ -1155,10 +1155,10 @@ do_gldriver() {
fi fi
if echo "$GLOPT" | grep -q -E "1" ; then if echo "$GLOPT" | grep -q -E "1" ; then
if grep -q "splash" $CMDLINE ; then if grep -q "splash" $CMDLINE ; then
sed -i $CMDLINE -e "s/ quiet//" sed -i $CMDLINE -e "s/ quiet//"
sed -i $CMDLINE -e "s/ splash//" sed -i $CMDLINE -e "s/ splash//"
sed -i $CMDLINE -e "s/ plymouth.ignore-serial-consoles//" sed -i $CMDLINE -e "s/ plymouth.ignore-serial-consoles//"
fi fi
sed $CONFIG -i -e "s/^gpu_mem/#gpu_mem/" sed $CONFIG -i -e "s/^gpu_mem/#gpu_mem/"
fi fi
whiptail --msgbox "$STATUS" 20 60 1 whiptail --msgbox "$STATUS" 20 60 1
@ -1189,11 +1189,11 @@ do_net_names () {
ASK_TO_REBOOT=1 ASK_TO_REBOOT=1
fi fi
if [ $RET -eq 0 ]; then if [ $RET -eq 0 ]; then
sed -i $CMDLINE -e "s/net.ifnames=0 *//" sed -i $CMDLINE -e "s/net.ifnames=0 *//"
rm -f /etc/systemd/network/99-default.link rm -f /etc/systemd/network/99-default.link
STATUS=enabled STATUS=enabled
elif [ $RET -eq 1 ]; then elif [ $RET -eq 1 ]; then
ln -sf /dev/null /etc/systemd/network/99-default.link ln -sf /dev/null /etc/systemd/network/99-default.link
STATUS=disabled STATUS=disabled
else else
return $RET return $RET
@ -1228,24 +1228,24 @@ do_audio() {
do_resolution() { do_resolution() {
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
CMODE=$(get_config_var hdmi_mode $CONFIG) CMODE=$(get_config_var hdmi_mode $CONFIG)
CGROUP=$(get_config_var hdmi_group $CONFIG) CGROUP=$(get_config_var hdmi_group $CONFIG)
if [ $CMODE -eq 0 ] ; then if [ $CMODE -eq 0 ] ; then
CSET="Default" CSET="Default"
elif [ $CGROUP -eq 2 ] ; then elif [ $CGROUP -eq 2 ] ; then
CSET="DMT Mode "$CMODE CSET="DMT Mode "$CMODE
else else
CSET="CEA Mode "$CMODE CSET="CEA Mode "$CMODE
fi fi
oIFS="$IFS" oIFS="$IFS"
IFS="/" IFS="/"
if tvservice -d /dev/null | grep -q Nothing ; then if tvservice -d /dev/null | grep -q Nothing ; then
value="Default/720x480/DMT Mode 4/640x480 60Hz 4:3/DMT Mode 9/800x600 60Hz 4:3/DMT Mode 16/1024x768 60Hz 4:3/DMT Mode 85/1280x720 60Hz 16:9/DMT Mode 35/1280x1024 60Hz 5:4/DMT Mode 51/1600x1200 60Hz 4:3/DMT Mode 82/1920x1080 60Hz 16:9/" value="Default/720x480/DMT Mode 4/640x480 60Hz 4:3/DMT Mode 9/800x600 60Hz 4:3/DMT Mode 16/1024x768 60Hz 4:3/DMT Mode 85/1280x720 60Hz 16:9/DMT Mode 35/1280x1024 60Hz 5:4/DMT Mode 51/1600x1200 60Hz 4:3/DMT Mode 82/1920x1080 60Hz 16:9/"
else else
value="Default/Monitor preferred resolution/" value="Default/Monitor preferred resolution/"
value=$value$(tvservice -m CEA | grep progressive | cut -b 12- | sed 's/mode \([0-9]\+\): \([0-9]\+\)x\([0-9]\+\) @ \([0-9]\+\)Hz \([0-9]\+\):\([0-9]\+\), clock:[0-9]\+MHz progressive/CEA Mode \1\/\2x\3 \4Hz \5:\6/' | tr '\n' '/') value=$value$(tvservice -m CEA | grep progressive | cut -b 12- | sed 's/mode \([0-9]\+\): \([0-9]\+\)x\([0-9]\+\) @ \([0-9]\+\)Hz \([0-9]\+\):\([0-9]\+\), clock:[0-9]\+MHz progressive/CEA Mode \1\/\2x\3 \4Hz \5:\6/' | tr '\n' '/')
value=$value$(tvservice -m DMT | grep progressive | cut -b 12- | sed 's/mode \([0-9]\+\): \([0-9]\+\)x\([0-9]\+\) @ \([0-9]\+\)Hz \([0-9]\+\):\([0-9]\+\), clock:[0-9]\+MHz progressive/DMT Mode \1\/\2x\3 \4Hz \5:\6/' | tr '\n' '/') value=$value$(tvservice -m DMT | grep progressive | cut -b 12- | sed 's/mode \([0-9]\+\): \([0-9]\+\)x\([0-9]\+\) @ \([0-9]\+\)Hz \([0-9]\+\):\([0-9]\+\), clock:[0-9]\+MHz progressive/DMT Mode \1\/\2x\3 \4Hz \5:\6/' | tr '\n' '/')
fi fi
RES=$(whiptail --default-item $CSET --menu "Choose screen resolution" 20 60 10 ${value} 3>&1 1>&2 2>&3) RES=$(whiptail --default-item $CSET --menu "Choose screen resolution" 20 60 10 ${value} 3>&1 1>&2 2>&3)
STATUS=$? STATUS=$?
IFS=$oIFS IFS=$oIFS
@ -1253,45 +1253,45 @@ do_resolution() {
GRS=$(echo "$RES" | cut -d ' ' -f 1) GRS=$(echo "$RES" | cut -d ' ' -f 1)
MODE=$(echo "$RES" | cut -d ' ' -f 3) MODE=$(echo "$RES" | cut -d ' ' -f 3)
if [ $GRS = "Default" ] ; then if [ $GRS = "Default" ] ; then
MODE=0 MODE=0
elif [ $GRS = "DMT" ] ; then elif [ $GRS = "DMT" ] ; then
GROUP=2 GROUP=2
else else
GROUP=1 GROUP=1
fi fi
fi fi
else else
GROUP=$1 GROUP=$1
MODE=$2 MODE=$2
STATUS=0 STATUS=0
fi fi
if [ $STATUS -eq 0 ]; then if [ $STATUS -eq 0 ]; then
if [ $MODE -eq 0 ]; then if [ $MODE -eq 0 ]; then
clear_config_var hdmi_force_hotplug $CONFIG clear_config_var hdmi_force_hotplug $CONFIG
clear_config_var hdmi_group $CONFIG clear_config_var hdmi_group $CONFIG
clear_config_var hdmi_mode $CONFIG clear_config_var hdmi_mode $CONFIG
else else
set_config_var hdmi_force_hotplug 1 $CONFIG set_config_var hdmi_force_hotplug 1 $CONFIG
set_config_var hdmi_group $GROUP $CONFIG set_config_var hdmi_group $GROUP $CONFIG
set_config_var hdmi_mode $MODE $CONFIG set_config_var hdmi_mode $MODE $CONFIG
fi fi
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
if [ $MODE -eq 0 ] ; then if [ $MODE -eq 0 ] ; then
whiptail --msgbox "The resolution is set to default" 20 60 1 whiptail --msgbox "The resolution is set to default" 20 60 1
else else
whiptail --msgbox "The resolution is set to $GRS mode $MODE" 20 60 1 whiptail --msgbox "The resolution is set to $GRS mode $MODE" 20 60 1
fi fi
fi fi
if [ $MODE -eq 0 ] ; then if [ $MODE -eq 0 ] ; then
TSET="Default" TSET="Default"
elif [ $GROUP -eq 2 ] ; then elif [ $GROUP -eq 2 ] ; then
TSET="DMT Mode "$MODE TSET="DMT Mode "$MODE
else else
TSET="CEA Mode "$MODE TSET="CEA Mode "$MODE
fi fi
if [ "$TSET" != "$CSET" ] ; then if [ "$TSET" != "$CSET" ] ; then
ASK_TO_REBOOT=1 ASK_TO_REBOOT=1
fi fi
fi fi
} }
@ -1566,7 +1566,7 @@ do_internationalisation_menu() {
do_interface_menu() { do_interface_menu() {
if ! is_pi ; then if ! is_pi ; then
do_ssh do_ssh
else else
FUN=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --menu "Interfacing Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \ FUN=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --menu "Interfacing Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"P1 Camera" "Enable/Disable connection to the Raspberry Pi Camera" \ "P1 Camera" "Enable/Disable connection to the Raspberry Pi Camera" \
@ -1678,7 +1678,7 @@ if [ "$INTERACTIVE" = True ]; then
[ -e $CONFIG ] || touch $CONFIG [ -e $CONFIG ] || touch $CONFIG
calc_wt_size calc_wt_size
while true; do while true; do
if is_pi ; then if is_pi ; then
FUN=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --backtitle "$(cat /proc/device-tree/model)" --menu "Setup Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Finish --ok-button Select \ FUN=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --backtitle "$(cat /proc/device-tree/model)" --menu "Setup Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Finish --ok-button Select \
"1 Change User Password" "Change password for the current user" \ "1 Change User Password" "Change password for the current user" \
"2 Network Options" "Configure network settings" \ "2 Network Options" "Configure network settings" \