image_builder: add echo_stamp to other files

This commit is contained in:
Artem Smirnov
2018-08-20 19:06:41 +03:00
parent a008f6b57c
commit 3fc266a061
7 changed files with 211 additions and 57 deletions

View File

@@ -1,39 +1,61 @@
#!/bin/bash
# Exit immidiately on non-zero result
set -e
#
# Script for image configure
# @urpylka Artem Smirnov
#
# Exit immidiately on non-zero result
set -e
echo_stamp() {
# STATIC FUNCTION
# TEMPLATE: echo_stamp <TEXT> <TYPE>
# TYPE: SUCCESS, ERROR, INFO
# More info there https://www.shellhacks.com/ru/bash-colors/
TEXT="$(date) | $1"
TEXT="\e[1m$TEXT\e[0m" # BOLD
case "$2" in
SUCCESS)
TEXT="\e[32m${TEXT}\e[0m";; # GREEN
ERROR)
TEXT="\e[31m${TEXT}\e[0m";; # RED
*)
TEXT="\e[34m${TEXT}\e[0m";; # BLUE
esac
echo -e ${TEXT}
}
##################################################
# Configure hardware interfaces
##################################################
# 1. Enable sshd
echo -e "\033[0;31m\033[1m$(date) | #1 Turn on sshd\033[0m\033[0m"
echo_stamp "#1 Turn on sshd"
touch /boot/ssh
# /usr/bin/raspi-config nonint do_ssh 0
# 2. Enable GPIO
echo -e "\033[0;31m\033[1m$(date) | #2 GPIO enabled by default\033[0m\033[0m"
echo_stamp "#2 GPIO enabled by default"
# 3. Enable I2C
echo -e "\033[0;31m\033[1m$(date) | #3 Turn on I2C\033[0m\033[0m"
echo_stamp "#3 Turn on I2C"
/usr/bin/raspi-config nonint do_i2c 0
# 4. Enable SPI
echo -e "\033[0;31m\033[1m$(date) | #4 Turn on SPI\033[0m\033[0m"
echo_stamp "#4 Turn on SPI"
/usr/bin/raspi-config nonint do_spi 0
# 5. Enable raspicam
echo -e "\033[0;31m\033[1m$(date) | #5 Turn on raspicam\033[0m\033[0m"
echo_stamp "#5 Turn on raspicam"
/usr/bin/raspi-config nonint do_camera 0
# 6. Enable hardware UART
echo -e "\033[0;31m\033[1m$(date) | #6 Turn on UART\033[0m\033[0m"
echo_stamp "#6 Turn on UART"
# Temporary solution
# https://github.com/RPi-Distro/raspi-config/pull/75
/usr/bin/raspi-config nonint do_serial 1
@@ -46,9 +68,9 @@ echo -e "\033[0;31m\033[1m$(date) | #6 Turn on UART\033[0m\033[0m"
# 7. Enable V4L driver http://robocraft.ru/blog/electronics/3158.html
#echo "bcm2835-v4l2" >> /etc/modules
echo -e "\033[0;31m\033[1m$(date) | #7 Turn on v4l2 driver\033[0m\033[0m"
echo_stamp "#7 Turn on v4l2 driver"
if ! grep -q "^bcm2835-v4l2" /etc/modules;
then printf "bcm2835-v4l2\n" >> /etc/modules
fi
echo -e "\033[0;31m\033[1m$(date) | End of configure hardware interfaces\033[0m\033[0m"
echo_stamp "End of configure hardware interfaces"