#!/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 epi-gtk /usr/share/zero-lliurex-adobeair/adobeair.epi } 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