From fa7758acf02c45a207567c935065fc5fdb6bf5cd Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Wed, 6 May 2020 13:55:34 +0200 Subject: [PATCH] Added administration scripts --- .travis.yml | 6 ++++++ scripts/board-update.sh | 28 +++++++++++++++++++++++++++ scripts/compile.sh | 16 ++++++++++++++++ scripts/library-update.sh | 40 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 .travis.yml create mode 100644 scripts/board-update.sh create mode 100644 scripts/compile.sh create mode 100644 scripts/library-update.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0ab279b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: C++ +git: + submodules: false +script: + - shellcheck ./administration/*.sh + diff --git a/scripts/board-update.sh b/scripts/board-update.sh new file mode 100644 index 0000000..2cb5fb7 --- /dev/null +++ b/scripts/board-update.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# +# This script updates or creates the support for the ESP8266 board +# @author Kevin Veen-Birkenbach [kevin@veen.world] +# @see https://arduino-esp8266.readthedocs.io/en/latest/installing.html#using-git-version + +# set variables +ARDUINO_HARDWARE_PATH="$HOME/Arduino/hardware"; +ESP8266_PATH="$ARDUINO_HARDWARE_PATH/esp8266com"; +if [ -d "$ESP8266_PATH" ] + then + echo "Updates esp8266com..." + cd "$ESP8266_PATH/esp8266" || exit 1 + git status + git pull + else + echo "Creates support for ESP8266..." + mkdir -p "$ESP8266_PATH" && echo "Arduino hardware folder created" && cd "$ESP8266_PATH" || exit 2; + git clone https://github.com/esp8266/Arduino.git esp8266 + echo "Initialize the submodules..." + cd esp8266 || exit 3 + git submodule update --init + cd tools || exit 4 + python3 get.py + echo "esp8266com path looks now the follow:" + tree -dL 2 "$ESP8266_PATH" +fi +echo "Finished." diff --git a/scripts/compile.sh b/scripts/compile.sh new file mode 100644 index 0000000..d9a0d1a --- /dev/null +++ b/scripts/compile.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# @author Kevin Veen-Birkenbach [kevin@veen.world] +# This script compiles the program + +# set variables +ARDUINO_PATH="$HOME/.local/share/umake/ide/arduino/arduino"; + +# test preconditions +if [ ! -f "$ARDUINO_PATH" ] +then + echo "This program expects to find the Arduino IDE in $ARDUINO_PATH, but the file doesn't exist." + echo "Feel free to optimize this script or install Arduino how described under the following url:" + echo "https://askubuntu.com/questions/1025753/how-to-install-latest-arduino-ide" + exit 1; +fi +bash "$ARDUINO_PATH" --upload ../main/main.ino diff --git a/scripts/library-update.sh b/scripts/library-update.sh new file mode 100644 index 0000000..dfd35a3 --- /dev/null +++ b/scripts/library-update.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# This script updates the dependencies +# @author Kevin Veen-Birkenbach [kevin@veen.world] + +# set variables +ARDUINO_LIBRARIES_PATH="$HOME/Arduino/libraries"; + +# test preconditions +if [ ! -d "$ARDUINO_LIBRARIES_PATH" ] +then + echo "This program expects to find the Arduino libraries in $ARDUINO_LIBRARIES_PATH, but the directory doesn't exist." + echo "Feel free to optimize this script for your individual purpose." + exit 1; +fi + +# Pulls or clones a repository +# @param $1 Folder name +# @param $2 Git repository +pullOrClone(){ + local FOLDER_PATH="$ARDUINO_LIBRARIES_PATH/$1"; + echo "Trying to update $FOLDER_PATH..." + if [ -d "$FOLDER_PATH" ] + then + cd "$FOLDER_PATH" || exit 1; + if [ -d ".git" ] + then + git pull; + else + echo "Update not possible, because library hadn't been installed via git." + fi + else + cd "$ARDUINO_LIBRARIES_PATH" && git clone "$2"; + fi +} +( + pullOrClone "Adafruit_Sensor" "https://github.com/adafruit/Adafruit_Sensor"; + pullOrClone "DHT-sensor-library" "https://github.com/adafruit/DHT-sensor-library"; + pullOrClone "NewRemoteSwitch" "https://github.com/1technophile/NewRemoteSwitch"; +)