diff --git a/image_builder/scripts/hardware_setup.sh b/image_builder/scripts/hardware_setup.sh index 543c06d9..bc70aab1 100755 --- a/image_builder/scripts/hardware_setup.sh +++ b/image_builder/scripts/hardware_setup.sh @@ -1,135 +1,42 @@ #!/bin/bash +# Exit immidiately on non-zero result set -e -################################################################################################################################## -# Настройка интерфейсов -################################################################################################################################## +# +# Script for image configure +# @urpylka Artem Smirnov +# -# вот так все в принципе должно включиться -# /usr/bin/raspi-config nonint do_i2c 0 -# /usr/bin/raspi-config nonint do_spi 0 -# /usr/bin/raspi-config nonint do_camera 0 -# /usr/bin/raspi-config nonint do_rgpio 0 -# /usr/bin/raspi-config nonint do_ssh 0 +################################################## +# Configure hardware interfaces +################################################## -# по идеи эти настройки должны проводиться до по другому как сделано в prepare_image.sh - -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" -} - -BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf -CONFIG=/boot/config.txt - -# 2. Изменить необходимые настройки - -# 2.1. Включить sshd +# 1. Enable sshd echo -e "\033[0;31m\033[1m$(date) | #1 Turn on sshd\033[0m\033[0m" touch /boot/ssh +# /usr/bin/raspi-config nonint do_ssh 0 -# 2.2. Включить GPIO -# Включено по умолчанию +# 2. Enable GPIO +echo -e "\033[0;31m\033[1m$(date) | #2 SSHd enabled by default\033[0m\033[0m" -# 2.3. Включить I2C -echo -e "\033[0;31m\033[1m$(date) | #2 Turn on I2C\033[0m\033[0m" +# 3. Enable I2C +echo -e "\033[0;31m\033[1m$(date) | #3 Turn on I2C\033[0m\033[0m" +/usr/bin/raspi-config nonint do_i2c 0 -set_config_var dtparam=i2c_arm on $CONFIG && - if ! [ -e $BLACKLIST ]; then - touch $BLACKLIST - fi - sed $BLACKLIST -i -e "s/^\(blacklist[[:space:]]*i2c[-_]bcm2708\)/#\1/" - sed /etc/modules -i -e "s/^#[[:space:]]*\(i2c[-_]dev\)/\1/" - if ! grep -q "^i2c[-_]dev" /etc/modules; then - printf "i2c-dev\n" >> /etc/modules - fi +# 4. Enable SPI +echo -e "\033[0;31m\033[1m$(date) | #4 Turn on SPI\033[0m\033[0m" +/usr/bin/raspi-config nonint do_spi 0 -# 2.4. Включить SPI -echo -e "\033[0;31m\033[1m$(date) | #3 Turn on SPI\033[0m\033[0m" +# 5. Enable raspicam +echo -e "\033[0;31m\033[1m$(date) | #5 Turn on raspicam\033[0m\033[0m" +/usr/bin/raspi-config nonint do_camera 0 -set_config_var dtparam=spi on $CONFIG && - if ! [ -e $BLACKLIST ]; then - touch $BLACKLIST - fi - sed $BLACKLIST -i -e "s/^\(blacklist[[:space:]]*spi[-_]bcm2708\)/#\1/" - -# 2.5. Включить raspicam -echo -e "\033[0;31m\033[1m$(date) | #4 Turn on raspicam\033[0m\033[0m" - -get_config_var() { - lua - "$1" "$2" <> /etc/modules +echo -e "\033[0;31m\033[1m$(date) | #6 Turn on v4l2 driver\033[0m\033[0m" if ! grep -q "^bcm2835-v4l2" /etc/modules; then printf "bcm2835-v4l2\n" >> /etc/modules fi -echo -e "\033[0;31m\033[1m$(date) | #5 End of configuring interfaces\033[0m\033[0m" +echo -e "\033[0;31m\033[1m$(date) | End of configure hardware interfaces\033[0m\033[0m"