#!/bin/bash #Based on lyshie's scripts at https://gist.github.com/lyshie/0c49393076b8b375ca1bd98c28f95fb0 ACTION="$1" PKG="$2" APP_PATH="/var/cache/epi-downloads/" TAR_PATH="/tmp/scratch_tmp/" PACKAGE_NAME="edu.media.mit.scratch2editor" VERSION="Scratch-desktop.exe" TAR="Scratch-latest.tar" LOG_FILE="/tmp/Install.log" URL_SCRATCH="http://lliurex.net/recursos-edu/misc/" NODE_PATH=$(npm root -g) SCRATCH_PATH="/tmp/scratch-desktop/" case $ACTION in testInstall) exit 0 ;; getStatus) case $PKG in scratch-desktop) TEST=$( dpkg-query -s $PACKAGE_NAME 2> /dev/null| grep Status | cut -d " " -f 4 ) if [ "$TEST" == 'installed' ]; then echo "0" else echo "1" fi ;; esac ;; preInstall) apt install npm p7zip-full -y # wget $URL_SCRATCH$VERSION -O ${APP_PATH}/${VERSION} # if [ $? != 0 ] # then # exit 1 # fi ;; installPackage) [ -e /usr/bin/node ] || ln -s /usr/bin/nodejs /usr/bin/node npm install -g electron@4.1.4 --save-dev ######## extract scratch-desktop rm -rf $SCRATCH_PATH mkdir $SCRATCH_PATH rm -rf $TAR_PATH mkdir $TAR_PATH # wget -O $SCRATCH_PATH.exe 'https://downloads.scratch.mit.edu/desktop/Scratch%20Desktop%20Setup%203.6.0.exe' tar -xf $APP_PATH$TAR -C $TAR_PATH 7za x -aoa -y $TAR_PATH$VERSION -o$SCRATCH_PATH #$SCRATCH_PATH.exe -o$SCRATCH_PATH ######## create electron app cp -rf $NODE_PATH/electron/dist/* $SCRATCH_PATH/ ln -fsr $SCRATCH_PATH/electron $SCRATCH_PATH/scratch-desktop ######## fix permissions chmod 755 $SCRATCH_PATH/locales chmod 755 $SCRATCH_PATH/swiftshader chmod 755 $SCRATCH_PATH/resources chmod 755 $SCRATCH_PATH/resources/static chmod 755 $SCRATCH_PATH/resources/static/assets ######## get application icon # wget -O $SCRATCH_PATH/resources/Icon.png 'https://scratch.mit.edu/images/download/icon.png cp $TAR_PATH/Icon.png $SCRATCH_PATH/resources/Icon.png ######## create deb package npm install -g electron-installer-debian@0.6.0 # wget -O /tmp/config-deb.json 'https://gist.githubusercontent.com/lyshie/0c49393076b8b375ca1bd98c28f95fb0/raw/223cc112d99c3bdc1829fc25b19c260856134a82/config-deb.json' /usr/local/bin/electron-installer-debian --config $TAR_PATH/config-deb.json dpkg -i /tmp/scratch-desktop_3.6.0_amd64.deb || exit 1 ;; remove) echo "Removing files..." apt remove scratch-desktop ;; esac exit 0