Last active
December 27, 2017 22:30
-
-
Save koter84/58078854a925be8e182d8ce867864568 to your computer and use it in GitHub Desktop.
Install Arduino-IDE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# get current dir | |
arduino_dir="/opt/$(ls /opt/ | grep arduino | grep -v tar)" | |
if [ "$arduino_dir" == "/opt/" ] | |
then | |
arduino_dir="" | |
fi | |
echo "Arduino DIR: $arduino_dir" | |
arduino_dir_version=$(echo $arduino_dir | sed 's/.*arduino-//') | |
echo "Arduino DIR Version: $arduino_dir_version" | |
# get current url | |
arduino_url=$(curl -s https://www.arduino.cc/en/Main/Software | sed 's/<a/\n<a/g' | grep '\.tar\.xz' | grep linux64 | grep -v beta | grep -v nightly | sed s/.*href=\"// | cut -d"\"" -f1 | awk -F/ '{print $NF}') | |
arduino_url="https://downloads.arduino.cc/$arduino_url" | |
echo "Arduino URL: $arduino_url" | |
arduino_url_version=$(echo $arduino_url | awk -F/ '{print $NF}' | sed 's/arduino-//' | sed 's/-.*//') | |
echo "Arduino URL Version: $arduino_url_version" | |
arduino_url_dir=$(echo $arduino_url | awk -F/ '{print $NF}' | cut -d"/" -f-1 | sed s/'-linux64.tar.xz'// ) | |
#echo "Arduino URL Dir: $arduino_url_dir" | |
# check that a current version is found | |
if [ "$arduino_dir_version" == "" ] | |
then | |
echo "New Installation! (no old version found)" | |
new_install="1" | |
fi | |
# check that a new version and url are found | |
if [ "$arduino_url" == "" ] || [ "$arduino_url_version" == "" ] | |
then | |
echo "couldn't find url for new version" | |
exit | |
fi | |
# check current dir version with current url version | |
if [ "$arduino_dir_version" != "$arduino_url_version" ] | |
then | |
if [ "$new_install" != "1" ] | |
then | |
echo "New Version Found!" | |
fi | |
cd /opt/ | |
# download | |
wget --quiet --show-progress -O arduino.new.tar.xz "$arduino_url" | |
# unpack | |
tar -xf arduino.new.tar.xz | |
# remove download | |
rm arduino.new.tar.xz | |
# remove old version | |
rm -rf $arduino_dir | |
# install desktop shortcut, menu item and file associations | |
cd $arduino_url_dir/ | |
./install.sh | |
# check for Stack dir | |
if [ -d /data/Stack ] | |
then | |
# setup some better defaults :-) | |
if [ -f ~/.arduino15/preferences.txt ] | |
then | |
sed -i s:sketchbook.path=.*:sketchbook.path=/data/Stack/Arduino: ~/.arduino15/preferences.txt | |
else | |
mkdir -p ~/.arduino15 | |
echo "build.verbose=true" >> ~/.arduino15/preferences.txt | |
echo "upload.verbose=true" >> ~/.arduino15/preferences.txt | |
echo "editor.linenumbers=true" >> ~/.arduino15/preferences.txt | |
echo "sketchbook.path=/data/Stack/Arduino" >> ~/.arduino15/preferences.txt | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment