Global check for mountpoint and existence of /boot/config.txt

This commit is contained in:
spl 2016-05-24 11:57:24 +01:00
parent 96c31754d7
commit a8a933ef64
1 changed files with 8 additions and 25 deletions

View File

@ -219,13 +219,6 @@ EOF
# $1 is 0 to disable overscan, 1 to disable it # $1 is 0 to disable overscan, 1 to disable it
set_overscan() { set_overscan() {
# Stop if /boot is not a mountpoint
if ! mountpoint -q /boot; then
return 1
fi
[ -e $CONFIG ] || touch $CONFIG
if [ "$1" -eq 0 ]; then # disable overscan if [ "$1" -eq 0 ]; then # disable overscan
sed $CONFIG -i -e "s/^overscan_/#overscan_/" sed $CONFIG -i -e "s/^overscan_/#overscan_/"
set_config_var disable_overscan 1 $CONFIG set_config_var disable_overscan 1 $CONFIG
@ -335,9 +328,6 @@ No other symbols, punctuation characters, or blank spaces are permitted.\
do_memory_split() { # Memory Split 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
if ! mountpoint -q /boot; then
return 1
fi
## 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)
@ -389,10 +379,6 @@ do_memory_split() { # Memory Split
} }
get_current_memory_split() { 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" AVAILABLE_SPLITS="128 192 224 240"
MEMSPLIT_DESCRIPTION="" MEMSPLIT_DESCRIPTION=""
for SPLIT in $AVAILABLE_SPLITS;do for SPLIT in $AVAILABLE_SPLITS;do
@ -532,7 +518,7 @@ do_ssh() {
} }
get_spi() { get_spi() {
if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*spi(=(on|true|yes|1))?(,.*)?$" $CONFIG; then if grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*spi(=(on|true|yes|1))?(,.*)?$" $CONFIG; then
echo 0 echo 0
else else
echo 1 echo 1
@ -574,7 +560,7 @@ do_spi() {
} }
get_i2c() { get_i2c() {
if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?(=(on|true|yes|1))?(,.*)?$" $CONFIG; then if grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?(=(on|true|yes|1))?(,.*)?$" $CONFIG; then
echo 0 echo 0
else else
echo 1 echo 1
@ -953,10 +939,6 @@ do_camera() {
whiptail --msgbox "Your firmware appears to be out of date (no start_x.elf). Please update" 20 60 2 whiptail --msgbox "Your firmware appears to be out of date (no start_x.elf). Please update" 20 60 2
return 1 return 1
fi fi
# Stop if /boot is not a mountpoint
if ! mountpoint -q /boot; then
return 1
fi
DEFAULT=--defaultno DEFAULT=--defaultno
CURRENT=0 CURRENT=0
@ -965,7 +947,6 @@ do_camera() {
CURRENT=1 CURRENT=1
fi fi
[ -e $CONFIG ] || touch $CONFIG
sed $CONFIG -i -e "s/^startx/#startx/" sed $CONFIG -i -e "s/^startx/#startx/"
sed $CONFIG -i -e "s/^fixup_file/#fixup_file/" sed $CONFIG -i -e "s/^fixup_file/#fixup_file/"
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
@ -998,7 +979,7 @@ do_camera() {
} }
get_onewire() { get_onewire() {
if [ -e $CONFIG ] && grep -q -E "^dtoverlay=w1-gpio" $CONFIG; then if grep -q -E "^dtoverlay=w1-gpio" $CONFIG; then
echo 0 echo 0
else else
echo 1 echo 1
@ -1013,7 +994,6 @@ do_onewire() {
CURRENT=1 CURRENT=1
fi fi
[ -e $CONFIG ] || touch $CONFIG
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --yesno "Would you like the one-wire interface to be enabled?" $DEFAULT 20 60 2 whiptail --yesno "Would you like the one-wire interface to be enabled?" $DEFAULT 20 60 2
RET=$? RET=$?
@ -1043,8 +1023,6 @@ do_onewire() {
# $1 is 0 to disable driver, 1 to enable it # $1 is 0 to disable driver, 1 to enable it
set_gldriver() { set_gldriver() {
[ -e $CONFIG ] || touch $CONFIG
if [ "$1" -eq 0 ]; then # disable driver if [ "$1" -eq 0 ]; then # disable driver
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/"
rm /etc/xdg/autostart/xcompmgr.desktop rm /etc/xdg/autostart/xcompmgr.desktop
@ -1341,6 +1319,11 @@ do_advanced_menu() {
# Interactive use loop # Interactive use loop
# #
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
if ! mountpoint -q /boot; then
whiptail --msgbox "The boot partition is not mounted - cannot configure. Note that raspi-config is intended for use on Raspbian only and cannot be guaranteed to work on other operating systems." 20 60 1
exit 1
fi
[ -e $CONFIG ] || touch $CONFIG
get_init_sys get_init_sys
calc_wt_size calc_wt_size
while true; do while true; do