125 lines
2.6 KiB
Bash
125 lines
2.6 KiB
Bash
#!/bin/bash
|
|
|
|
# Konstanten
|
|
repo="https://github.com/devfix/b15f.git"
|
|
log="/tmp/b15f-install.log"
|
|
dependencies="git avr-libc avrdude libncurses5-dev g++ astyle"
|
|
user="$1"
|
|
path="/home/$user/b15f/"
|
|
udev_rule="SUBSYSTEM!=\"usb_device\", ACTION!=\"add\", GOTO=\"avrisp_end\"\nATTR{idVendor}==\"03eb\", ATTR{idProduct}==\"2104\", MODE=\"660\", GROUP=\"dialout\"\nLABEL=\"avrisp_end\""
|
|
udev_path="/etc/udev/rules.d/60-olimex.rules"
|
|
|
|
|
|
function hr1
|
|
{
|
|
printf '━%.0s' $(seq $(tput cols))
|
|
echo ""
|
|
}
|
|
|
|
function hr2
|
|
{
|
|
printf '\e(0'; printf 'q%.0s' $(seq $(tput cols)); printf '\e(B\n';
|
|
}
|
|
|
|
function title
|
|
{
|
|
echo ""
|
|
echo -e "*** $1 ***" >> "$log"
|
|
hr1
|
|
echo " $1"
|
|
hr1
|
|
}
|
|
|
|
function msg
|
|
{
|
|
echo ""
|
|
echo -e "* $1 *" >> "$log"
|
|
hr2
|
|
echo " $1"
|
|
hr2
|
|
}
|
|
|
|
function out
|
|
{
|
|
echo -e " $1" | tee -a "$log"
|
|
}
|
|
|
|
|
|
# aktiviere logging
|
|
exec 2>&1 | tee -a "$log"
|
|
|
|
if [ "$EUID" -ne 0 ]; then
|
|
current_user="`whoami`"
|
|
out "B15F wrid installiert für: $current_user"
|
|
out "Für die Installation werden Superrechte benötigt, Anmeldung (für sudo) folgt..."
|
|
printf " Nutzername: "
|
|
read user
|
|
printf " Melde $user an...\n "
|
|
su "$user" -c "printf \" Fordere Superrechte an...\n \" && sudo -S bash \"$0\" \"$current_user\""
|
|
exit 0
|
|
fi
|
|
|
|
title "Installation B15F"
|
|
|
|
# Abbruch bei Fehlern
|
|
set -e
|
|
|
|
msg "Installiere Abhängigkeiten"
|
|
|
|
out "Aktualisiere apt..."
|
|
apt-get update > /dev/null
|
|
|
|
out "Installiere Packete (wenn nötig)..."
|
|
apt-get install -y $dependencies > /dev/null
|
|
|
|
out "Konfiguriere udev rules..."
|
|
echo -e "$udev_rule" > "$udev_path"
|
|
|
|
out "Aktualisiere udev service..."
|
|
udevadm control --reload-rules
|
|
udevadm trigger
|
|
|
|
msg "Lade Projekt-Daten"
|
|
|
|
if [ -d "$path" ]; then
|
|
msg "Entferne alte Version"
|
|
|
|
cd "$path/control/src"
|
|
make clean
|
|
cd "$path/firmware"
|
|
make clean
|
|
|
|
msg "Aktualisiere Repository..."
|
|
su $user -c "git checkout master"
|
|
su $user -c "git pull"
|
|
su $user -c "git pull --prune"
|
|
else
|
|
out "Klone Repository..."
|
|
su $user -c "git clone -q \"$repo\" \"$path\""
|
|
fi
|
|
|
|
msg "Wichtiger Hinweis"
|
|
out "Bitte stellen Sie jetzt sicher, dass in der Datei \"$path/firmware/Makefile\" die Option \"MCU = ...\" für den richtigen Mikrocontroller eingestellt ist."
|
|
|
|
echo ""
|
|
out "Drücken Sie [Enter] zum fortfahren."
|
|
read
|
|
|
|
msg "Kompiliere Firmware"
|
|
|
|
cd "$path/firmware"
|
|
su $user -c "make" | tee -a "$log"
|
|
|
|
msg "Lade Firmware auf Mikrocontroller"
|
|
make upload | tee -a "$log"
|
|
|
|
msg "Kompiliere Steuersoftware"
|
|
|
|
cd "$path/control/src"
|
|
su $user -c "make" | tee -a "$log"
|
|
|
|
msg "Installiere Steuersoftware"
|
|
make install
|
|
|
|
title "Installation erfolgreich abgeschlossen"
|