Created
March 12, 2012 14:09
-
-
Save chiva/2022148 to your computer and use it in GitHub Desktop.
Instalador del IDE Arduino para Linux Ubuntu 11.XX
This file contains hidden or 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 | |
asterisks () | |
{ | |
echo "*********************************************" | |
} | |
header () | |
{ | |
echo | |
asterisks | |
echo "$1" | |
asterisks | |
echo | |
} | |
remove() | |
{ | |
if [ -d $1 ]; then | |
rm -rf $1 | |
fi | |
} | |
error () | |
{ | |
echo | |
asterisks | |
echo ERROR: "$1" | |
asterisks | |
echo | |
} | |
ARD_VER=1.0.1-rc1 | |
ARD_DIR=/usr/share/arduino | |
ARD_EXTRA=arduino_1.0+dfsg-9.debian | |
UBNT_VER=11. | |
# Comprobar si tenemos permisos | |
if [ "$(id -u)" != "0" ]; then | |
echo "Uso: sudo $0" | |
exit 6 | |
fi | |
# Comprobar que estamos en Ubuntu 11.XX | |
iden=`cat /etc/issue` | |
if [[ "$iden" != *"$UBNT_VER"* ]]; then | |
error "script no preparado para esta version de Ubuntu" | |
exit 1 | |
fi | |
# Comprobar si hay instalada una version anterior desde repositorio | |
dpkg -s arduino > /dev/null 2>&1 | |
if [ $? -eq 0 ]; then | |
repository=1 | |
installed=`dpkg -s arduino | grep Status | awk '{print $2}'` | |
if [ "$installed" == "install" ]; then | |
version=`dpkg -s arduino | grep Version | awk '{print $2}'` | |
echo | |
echo "Version '$version' detectada" | |
echo -n "Instalar version '$ARD_VER'? [S/n]: " | |
read -n 1 uninstall | |
echo | |
if [ "$uninstall" == "n" ]; then | |
echo | |
exit 0 | |
fi | |
fi | |
else | |
repository=0 | |
fi | |
# Comprobar si hay instalada una version manualmente | |
if [ $repository -eq 0 ]; then | |
if [ -d "$ARD_DIR" ]; then | |
version=`cat $ARD_DIR/lib/version.txt` | |
echo | |
echo "Version '$version' detectada" | |
echo -n "Instalar version '$ARD_VER'? [S/n]: " | |
read -n 1 reinstall | |
echo | |
if [ "$reinstall" == "n" ]; then | |
echo | |
exit 0 | |
fi | |
fi | |
fi | |
# Comprobar si estamos en version de 32 o 64 bits | |
if [ "$(uname -m)" == "x86_64" ]; then | |
ARDN_TGZ=arduino-$ARD_VER-linux64.tgz | |
else | |
ARDN_TGZ=arduino-$ARD_VER-linux.tgz | |
fi | |
####### | |
header "Preparando sistema de archivos" | |
####### | |
if [ $repository -eq 1 ]; then | |
apt-get -y --purge autoremove arduino | |
else | |
remove $ARD_DIR | |
fi | |
if [ $? -ne 0 ]; then | |
error "imposible borrar la instalacion actual de Arduino" | |
exit 3 | |
fi | |
####### | |
header "Instalando dependencias" | |
####### | |
apt-get update && \ | |
apt-get -y install openjdk-6-jre | |
if [ $? -ne 0 ]; then | |
error "no se pudieron instalar las dependencias" | |
exit 2 | |
fi | |
# Obtener extras | |
wget -N http://archive.ubuntu.com/ubuntu/pool/universe/a/arduino/$ARD_EXTRA.tar.gz && \ | |
tar -zxvf $ARD_EXTRA.tar.gz && \ | |
cp -fR debian/icons/* /usr/share/icons/hicolor && \ | |
mv -f debian/arduino.desktop /usr/share/applications/ && \ | |
remove debian && \ | |
rm -f $ARD_EXTRA.tar.gz | |
if [ $? -ne 0 ]; then | |
error "no se pudieron instalar los accesos directos" | |
exit 8 | |
fi | |
####### | |
header "Instalando Arduino $ARD_VER" | |
####### | |
wget -N http://files.arduino.cc/downloads/$ARDN_TGZ | |
if [ $? -ne 0 ]; then | |
error "no se pudo descargar el software de Arduino" | |
exit 4 | |
fi | |
tar -zxvf $ARDN_TGZ | |
if [ $? -ne 0 ]; then | |
error "no se pudo descomprimir el software de Arduino" | |
exit 5 | |
fi | |
mv arduino-$ARD_VER /usr/share/arduino | |
if [ $? -ne 0 ]; then | |
error "no se pudo mover la carpeta del software de Arduino" | |
exit 7 | |
fi | |
cp -f $ARD_DIR/arduino /usr/bin/ && \ | |
sed -i 's/\"\$(dirname -- \$(readlink -f -- \"\${0}\") )\"/\/usr\/share\/arduino/g' /usr/bin/arduino && \ | |
chmod 755 /usr/bin/arduino | |
if [ $? -ne 0 ]; then | |
error "no se pudo crear el ejecutable" | |
exit 9 | |
fi | |
rm -f $ARDN_TGZ | |
####### | |
header "Finalizado!" | |
####### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment