1 | #!/bin/bash |
---|
2 | |
---|
3 | ACTION="$1" |
---|
4 | DIRECTORY="/opt/adobe-air-sdk" |
---|
5 | DIRECTORY_BASE="/opt/adobe-air-sdk/scratch" |
---|
6 | VERSION="Scratch-latest.air" |
---|
7 | PACKAGE_NAME="scratch.air" |
---|
8 | APP_PATH="/var/cache/epi-downloads/" |
---|
9 | LOG_FILE="/tmp/zero-adobeair.log" |
---|
10 | ICON_FILE="/usr/share/mate/applications/edu.media.mit.scratch2editor.desktop" |
---|
11 | |
---|
12 | |
---|
13 | case $ACTION in |
---|
14 | |
---|
15 | installPackage) |
---|
16 | |
---|
17 | if [ -f "${DIRECTORY_BASE}/${PACKAGE_NAME}" ]; then |
---|
18 | rm -rf $DIRECTORY_BASE; sleep 2 |
---|
19 | |
---|
20 | if [ -d "$DIRECTORY_BASE" ]; then |
---|
21 | exit 1 |
---|
22 | fi |
---|
23 | fi |
---|
24 | |
---|
25 | mkdir $DIRECTORY_BASE |
---|
26 | |
---|
27 | cp "${APP_PATH}/${VERSION}" "${DIRECTORY_BASE}/${PACKAGE_NAME}" |
---|
28 | |
---|
29 | |
---|
30 | if ! [ -f "${DIRECTORY_BASE}/${PACKAGE_NAME}" ]; then |
---|
31 | exit 1 |
---|
32 | fi |
---|
33 | ;; |
---|
34 | |
---|
35 | postInstall) |
---|
36 | |
---|
37 | echo ">> Creating launcher..." |
---|
38 | : > $ICON_FILE |
---|
39 | unzip -j "${DIRECTORY_BASE}/${PACKAGE_NAME}" icons/AppIcon128.png -d "${DIRECTORY_BASE}/" |
---|
40 | cat << _EOF_ > $ICON_FILE |
---|
41 | [Desktop Entry] |
---|
42 | Encoding=UTF-8 |
---|
43 | Version=1.0 |
---|
44 | Type=Application |
---|
45 | Exec=/usr/sbin/lliurex_scratch2.sh |
---|
46 | TryExec=/usr/sbin/lliurex_scratch2.sh |
---|
47 | Icon=/opt/adobe-air-sdk/scratch/AppIcon128.png |
---|
48 | Terminal=false |
---|
49 | Name=Scratch 2 Editor |
---|
50 | Comment= Programming system and content development tool |
---|
51 | Name[es]=Scratch, programación visual |
---|
52 | Comment[es]=Sistema de programación visual para la educación |
---|
53 | Name[ca_ES@valencia]=Scratch, programació visual |
---|
54 | Comment[ca_ES@valencia]=Sistema de programació visual per a l'educació |
---|
55 | Name[ca_ES.UTF-8@valencia]=Scratch, programació visual |
---|
56 | Comment[ca_ES.UTF-8@valencia]=Sistema de programació visual per a l'educació |
---|
57 | Categories=Application;Education; |
---|
58 | MimeType=application/x-scratch-project |
---|
59 | _EOF_ |
---|
60 | chmod +x $ICON_FILE |
---|
61 | |
---|
62 | : > /usr/sbin/lliurex_scratch2.sh |
---|
63 | cat << _EOF_ > /usr/sbin/lliurex_scratch2.sh |
---|
64 | #!/bin/bash |
---|
65 | http_proxy=""; /opt/adobe-air-sdk/adobe-air/adobe-air /opt/adobe-air-sdk/scratch/scratch.air |
---|
66 | _EOF_ |
---|
67 | chmod +x /usr/sbin/lliurex_scratch2.sh |
---|
68 | |
---|
69 | |
---|
70 | ;; |
---|
71 | |
---|
72 | remove) |
---|
73 | echo "Removing files..." |
---|
74 | |
---|
75 | if [ -f "${DIRECTORY_BASE}/${PACKAGE_NAME}" ]; then |
---|
76 | rm -rf $DIRECTORY_BASE; sleep 2 |
---|
77 | |
---|
78 | if [ -d "$DIRECTORY_BASE" ]; then |
---|
79 | exit 1 |
---|
80 | else |
---|
81 | if [ -f /usr/sbin/lliurex-scratch2.sh ]; then |
---|
82 | rm -f /usr/sbin/lliurex-scratch2.sh |
---|
83 | fi |
---|
84 | fi |
---|
85 | fi |
---|
86 | ;; |
---|
87 | |
---|
88 | |
---|
89 | esac |
---|
90 | exit 0 |
---|