mirror of
https://github.com/CopterExpress/clover.git
synced 2026-05-27 21:49:32 +00:00
65 lines
2.4 KiB
Bash
Executable File
65 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
##################################################################################################################################
|
|
# Image initialisation
|
|
##################################################################################################################################
|
|
|
|
set -e
|
|
|
|
echo_stamp() {
|
|
# 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}
|
|
}
|
|
|
|
echo_stamp "Install apt keys & repos"
|
|
|
|
# TODO: This STDOUT consist 'OK'
|
|
curl http://repo.coex.space/aptly_repo_signing.key 2> /dev/null | apt-key add -
|
|
apt-get update \
|
|
&& apt-get install --no-install-recommends -y -qq dirmngr=2.1.18-8~deb9u2 > /dev/null \
|
|
&& apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
|
|
|
|
echo "deb http://packages.ros.org/ros/ubuntu stretch main" > /etc/apt/sources.list.d/ros-latest.list
|
|
echo "deb http://repo.coex.space/rpi-ros-kinetic stretch main" > /etc/apt/sources.list.d/rpi-ros-kinetic.list
|
|
echo "deb http://repo.coex.space/clever stretch main" > /etc/apt/sources.list.d/clever.list
|
|
|
|
echo_stamp "Update apt cache"
|
|
|
|
# TODO: FIX ERROR: /usr/bin/apt-key: 596: /usr/bin/apt-key: cannot create /dev/null: Permission denied
|
|
apt-get update -qq > /dev/null
|
|
# && apt upgrade -y
|
|
|
|
echo_stamp "Write CLEVER information"
|
|
|
|
# Clever image version
|
|
echo "$1" >> /etc/clever_version
|
|
# Origin image file name
|
|
echo "${2%.*}" >> /etc/clever_origin
|
|
|
|
echo_stamp "Write magic script to /etc/rc.local"
|
|
MAGIC_SCRIPT="sudo /root/init_rpi.sh; sudo sed -i '/sudo \\\/root\\\/init_rpi.sh/d' /etc/rc.local && sudo reboot"
|
|
sed -i "19a${MAGIC_SCRIPT}" /etc/rc.local
|
|
|
|
# It needs for autosizer.sh & maybe that is correct
|
|
echo_stamp "Change boot partition"
|
|
sed -i 's/root=[^ ]*/root=\/dev\/mmcblk0p2/' /boot/cmdline.txt
|
|
sed -i 's/.* \/boot vfat defaults 0 2$/\/dev\/mmcblk0p1 \/boot vfat defaults 0 2/' /etc/fstab
|
|
sed -i 's/.* \/ ext4 defaults,noatime 0 1$/\/dev\/mmcblk0p2 \/ ext4 defaults,noatime 0 1/' /etc/fstab
|
|
|
|
echo_stamp "End of init image"
|