#!/bin/bash ICON_FILE="/usr/share/mate/applications/edu.media.mit.scratch2editor.desktop" DIRECTORY="/opt/adobe-air-sdk" if [ $EUID -ne 0 ]; then echo "Debes ejecutarlo como root (o mediante sudo)" 1>&2 exit 1 fi function adobe_install { echo ">> Eliminando versiones anteriores..." apt-get -y --purge remove adobeair rm -rf /opt/adobe-air-sdk rm $ICON_FILE CHKBITS=`uname -m` if [ $CHKBITS = "x86_64" ]; then echo ">> Instalando dependencias 32bit..." apt-get -q update apt-get -q -y install libgtk2.0-0:i386 libstdc++6:i386 libxml2:i386 libxslt1.1:i386 libcanberra-gtk-module:i386 gtk2-engines-murrine:i386 libqt4-qt3support:i386 libgnome-keyring0:i386 libnss-mdns:i386 libnss3:i386 fi echo ">> Enlazando librerías de Gnome..." ln -s /usr/lib/i386-linux-gnu/libgnome-keyring.so.0 /usr/lib/libgnome-keyring.so.0 ln -s /usr/lib/i386-linux-gnu/libgnome-keyring.so.0.2.0 /usr/lib/libgnome-keyring.so.0.2.0 echo ">> Descargando Adobe Air SDK..." #zero-lliurex-wget http://lliurex.net/recursos-edu/misc/AdobeAIRSDK.tbz2 /tmp zero-lliurex-wget http://airdownload.adobe.com/air/lin/download/2.6/AdobeAIRSDK.tbz2 #wget -q http://lliurex.net/recursos-edu/misc/AdobeAIRSDK.tbz2 mkdir /opt/adobe-air-sdk tar jxf /tmp/AdobeAIRSDK.tbz2 -C /opt/adobe-air-sdk echo ">> Descargando Air runtime/SDK desde Archlinux..." #wget -q http://lliurex.net/recursos-edu/misc/adobe-air.tar.gz zero-lliurex-wget http://lliurex.net/recursos-edu/misc/adobe-air.tar.gz /tmp tar xvf /tmp/adobe-air.tar.gz -C /opt/adobe-air-sdk chmod +x /opt/adobe-air-sdk/adobe-air/adobe-air echo ">> Ya tenemos el AdobeAir instalado, felicidades..." } function select_file { FILE="$(zenity --file-selection --filename /home/ --title='Select AIR File to install in AdobeAir')" case $? in 0) air_install;; 1) zenity --question \ --title="Word counter" \ --text="No file selected. Do you want to select one?" \ && select_file || exit;; -1) echo "An unexpected error has occurred."; exit;; esac } function select_icon { ICON_ROUTE="/usr/share/icons/adobeair_icon" if [ ! -d "$ICON_ROUTE" ]; then mkdir -p $ICON_ROUTE fi ICON="$(zenity --file-selection --filename /usr/share/icons/ --title='Select icon to your new App')" case $? in 0) cp $ICON $ICON_ROUTE/$ICON; echo "You have selected this Icon: $ICON_ROUTE/$ICON";; 1) zenity --question \ --title="Word counter" \ --text="No file selected. Do you want to select one?" \ && select_icon || $( echo "No desktop created, please execute it again and select one icon"; exit );; -1) echo "An unexpected error has occurred."; exit;; esac } function air_install { if [ ! -d "$DIRECTORY" ]; then echo "Abort installation, you do not have installed AdobeAIr." exit 1 fi echo "You have selected this Air file: $FILE" filename=$(basename $FILE) extension="${filename##*.}" filename_only="${filename%.*}" echo "The extension is $extension" if [ "$extension" == "air" ]; then echo "Is an AIR file, install it..." if [ -d /opt/adobe-air-sdk/$filename_only ]; then rm -rf /opt/adobe-air-sdk/$filename_only fi mkdir /opt/adobe-air-sdk/$filename_only cp $FILE /opt/adobe-air-sdk/$filename_only/$filename echo "You have installed new AIR file in /opt/adobe-air-sdk/$filename_only/$filename" select_icon NEW_ICON_FILE="/usr/share/applications/$filename_only.desktop" cat << _EOF_ > $NEW_ICON_FILE [Desktop Entry] Encoding=UTF-8 Version=1.0 Type=Application Exec=/opt/adobe-air-sdk/adobe-air/adobe-air /opt/adobe-air-sdk/$filename_only/$filename Icon=$ICON Terminal=false Name=$filename_only Comment=Application from AdobeAir $filename_only MimeType=application/x-scratch-project Categories=Application;Education;Development;ComputerScience; _EOF_ chmod +x $NEW_ICON_FILE echo "--------------------------------------------------------------" echo "Congratulations your app can be launched from $NEW_ICON_FILE" zenity --info --title="LliureX Air Installer" --text="Your new Air application can be launched from $NEW_ICON_FILE site in Main Menu -> Education" else echo "Sorry your file is not AIR file, abort installation." exit 1 fi } function select_function { ans=$(zenity --list --text "Select function" --radiolist --column "Pick" --column "Option" FALSE AdobeAir TRUE "Select Air file") if [ "$ans" == "" ]; then exit 1 else if [ "$ans" == "AdobeAir" ]; then adobe_install else select_file fi fi } select_function