mirror of
https://github.com/brain-hackers/brain-config.git
synced 2024-12-22 20:20:06 +09:00
Checking of initial state added for camera and 1-wire; unnecessary reboots removed.
This commit is contained in:
parent
f60f081a6f
commit
96c31754d7
124
raspi-config
124
raspi-config
@ -640,8 +640,10 @@ get_serial() {
|
||||
|
||||
do_serial() {
|
||||
DEFAULT=--defaultno
|
||||
CURRENT=0
|
||||
if [ $(get_serial) -eq 0 ] ; then
|
||||
DEFAULT=
|
||||
CURRENT=1
|
||||
fi
|
||||
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
@ -651,6 +653,9 @@ do_serial() {
|
||||
get_init_sys
|
||||
RET=$1
|
||||
fi
|
||||
if [ $RET -eq $CURRENT ]; then
|
||||
ASK_TO_REBOOT=1
|
||||
fi
|
||||
if [ $RET -eq 1 ]; then
|
||||
if [ $SYSTEMD -eq 0 ]; then
|
||||
sed -i /etc/inittab -e "s|^.*:.*:respawn:.*ttyAMA0|#&|"
|
||||
@ -659,7 +664,7 @@ do_serial() {
|
||||
sed -i /boot/cmdline.txt -e "s/console=serial0,[0-9]\+ //"
|
||||
set_config_var enable_uart 0 $CONFIG
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
whiptail --msgbox "Serial is now disabled" 20 60 1
|
||||
whiptail --msgbox "The serial interface is disabled" 20 60 1
|
||||
fi
|
||||
elif [ $RET -eq 0 ]; then
|
||||
if [ $SYSTEMD -eq 0 ]; then
|
||||
@ -681,12 +686,11 @@ do_serial() {
|
||||
fi
|
||||
set_config_var enable_uart 1 $CONFIG
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
whiptail --msgbox "Serial is now enabled" 20 60 1
|
||||
whiptail --msgbox "The serial interface is enabled" 20 60 1
|
||||
fi
|
||||
else
|
||||
return $RET
|
||||
fi
|
||||
ASK_TO_REBOOT=1
|
||||
}
|
||||
|
||||
disable_raspi_config_at_boot() {
|
||||
@ -935,28 +939,12 @@ registration.\
|
||||
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 $CONFIG ] || touch $CONFIG
|
||||
|
||||
if [ "$1" -eq 0 ]; then # disable camera
|
||||
set_config_var start_x 0 $CONFIG
|
||||
sed $CONFIG -i -e "s/^startx/#startx/"
|
||||
sed $CONFIG -i -e "s/^start_file/#start_file/"
|
||||
sed $CONFIG -i -e "s/^fixup_file/#fixup_file/"
|
||||
else # enable camera
|
||||
set_config_var start_x 1 $CONFIG
|
||||
CUR_GPU_MEM=$(get_config_var gpu_mem $CONFIG)
|
||||
if [ -z "$CUR_GPU_MEM" ] || [ "$CUR_GPU_MEM" -lt 128 ]; then
|
||||
set_config_var gpu_mem 128 $CONFIG
|
||||
fi
|
||||
sed $CONFIG -i -e "s/^startx/#startx/"
|
||||
sed $CONFIG -i -e "s/^fixup_file/#fixup_file/"
|
||||
get_camera() {
|
||||
CAM=$(get_config_var start_x $CONFIG)
|
||||
if [ $CAM -eq 1 ]; then
|
||||
echo 0
|
||||
else
|
||||
echo 1
|
||||
fi
|
||||
}
|
||||
|
||||
@ -965,16 +953,45 @@ do_camera() {
|
||||
whiptail --msgbox "Your firmware appears to be out of date (no start_x.elf). Please update" 20 60 2
|
||||
return 1
|
||||
fi
|
||||
# Stop if /boot is not a mountpoint
|
||||
if ! mountpoint -q /boot; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
DEFAULT=--defaultno
|
||||
CURRENT=0
|
||||
if [ $(get_camera) -eq 0 ] ; then
|
||||
DEFAULT=
|
||||
CURRENT=1
|
||||
fi
|
||||
|
||||
[ -e $CONFIG ] || touch $CONFIG
|
||||
sed $CONFIG -i -e "s/^startx/#startx/"
|
||||
sed $CONFIG -i -e "s/^fixup_file/#fixup_file/"
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
whiptail --yesno "Enable support for Raspberry Pi camera?" 20 60 2 \
|
||||
--yes-button Disable --no-button Enable
|
||||
whiptail --yesno "Would you like the camera interface to be enabled?" $DEFAULT 20 60 2
|
||||
RET=$?
|
||||
else
|
||||
RET=$1
|
||||
fi
|
||||
if [ $RET -eq 0 ] || [ $RET -eq 1 ]; then
|
||||
if [ $RET -eq $CURRENT ]; then
|
||||
ASK_TO_REBOOT=1
|
||||
set_camera $RET;
|
||||
fi
|
||||
if [ $RET -eq 1 ]; then
|
||||
set_config_var start_x 0 $CONFIG
|
||||
sed $CONFIG -i -e "s/^start_file/#start_file/"
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
whiptail --msgbox "The camera interface is disabled" 20 60 1
|
||||
fi
|
||||
elif [ $RET -eq 0 ]; then
|
||||
set_config_var start_x 1 $CONFIG
|
||||
CUR_GPU_MEM=$(get_config_var gpu_mem $CONFIG)
|
||||
if [ -z "$CUR_GPU_MEM" ] || [ "$CUR_GPU_MEM" -lt 128 ]; then
|
||||
set_config_var gpu_mem 128 $CONFIG
|
||||
fi
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
whiptail --msgbox "The camera interface is enabled" 20 60 1
|
||||
fi
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
@ -988,15 +1005,25 @@ get_onewire() {
|
||||
fi
|
||||
}
|
||||
|
||||
# $1 is 1 to disable interface, 0 to enable it
|
||||
set_onewire() {
|
||||
do_onewire() {
|
||||
DEFAULT=--defaultno
|
||||
CURRENT=0
|
||||
if [ $(get_onewire) -eq 0 ]; then
|
||||
DEFAULT=
|
||||
CURRENT=1
|
||||
fi
|
||||
|
||||
[ -e $CONFIG ] || touch $CONFIG
|
||||
if [ "$1" -eq 1 ]; then # disable driver
|
||||
sed $CONFIG -i -e "s/^dtoverlay=w1-gpio/#dtoverlay=w1-gpio/"
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
whiptail --msgbox "The one-wire interface is disabled" 20 60 1
|
||||
fi
|
||||
else # enable driver
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
whiptail --yesno "Would you like the one-wire interface to be enabled?" $DEFAULT 20 60 2
|
||||
RET=$?
|
||||
else
|
||||
RET=$1
|
||||
fi
|
||||
if [ $RET -eq $CURRENT ]; then
|
||||
ASK_TO_REBOOT=1
|
||||
fi
|
||||
if [ $RET -eq 0 ]; then
|
||||
sed $CONFIG -i -e "s/^#dtoverlay=w1-gpio/dtoverlay=w1-gpio/"
|
||||
if ! grep -q -E "^dtoverlay=w1-gpio" $CONFIG; then
|
||||
printf "dtoverlay=w1-gpio\n" >> $CONFIG
|
||||
@ -1004,24 +1031,11 @@ set_onewire() {
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
whiptail --msgbox "The one-wire interface is enabled" 20 60 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
do_onewire() {
|
||||
DEFAULT=--defaultno
|
||||
if [ $(get_onewire) -eq 0 ]; then
|
||||
DEFAULT=
|
||||
fi
|
||||
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
whiptail --yesno "Would you like the one-wire interface to be enabled?" $DEFAULT 20 60 2
|
||||
RET=$?
|
||||
else
|
||||
RET=$1
|
||||
fi
|
||||
if [ $RET -eq 0 ] || [ $RET -eq 1 ]; then
|
||||
ASK_TO_REBOOT=1
|
||||
set_onewire $RET;
|
||||
elif [ $RET -eq 1 ]; then
|
||||
sed $CONFIG -i -e "s/^dtoverlay=w1-gpio/#dtoverlay=w1-gpio/"
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
whiptail --msgbox "The one-wire interface is disabled" 20 60 1
|
||||
fi
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user