Skip to content

Commit

Permalink
Merge pull request #54 from eMoflon/feature/update-script
Browse files Browse the repository at this point in the history
Adds Eclipse install/update script
  • Loading branch information
maxkratz committed Jul 8, 2022
2 parents 4479954 + b725932 commit f212406
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,23 @@ Currently, the list of additional packages includes:

Feel free to request others, e.g., via Github issues.


## Usage/Installation

Quick installation using curl and bash:
`$ FOLDER="$HOME/eclipse-apps/emt"; mkdir -p $FOLDER && cd $FOLDER && curl https://raw.githubusercontent.com/eMoflon/emoflon-eclipse-build/main/emoflon-update.sh | bash -s -- $FOLDER`

### Normal installation

**The latest release can be found [here](https://github.com/eMoflon/emoflon-eclipse-build/releases/latest).**
Download an archive for the version you are looking for from the release page and extract it.

### Updating

You can use the [update script](./eclipse-update.sh) to update your installation.
Example usage:
`$ ./eclipse-update.sh ~/eclipse-apps/emt`


## Runner requirements

Expand Down
64 changes: 64 additions & 0 deletions emoflon-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

#
# Config
#

ECLIPSE_ARCHIVE=eclipse-emoflon-windows-dev # Name of the archive to download
FORCE_DOWNLOAD=0 # 1 = force download of new archive
TARGET_DIR=$1 # Target directory
API_URL="https://api.github.com/repos/eMoflon/emoflon-eclipse-build/releases/latest"

set -e
START_PWD=$PWD

#
# Utils
#

# Displays the given input including "=> " on the console.
log () {
printf "=> $1\n"
}

#
# Script
#

if [[ -z "$TARGET_DIR" ]]; then
log "Parameter for target directory was empty. Exit.\n Call script with the parameter, e.g.:\n ./eclipse-update.sh /home/mkratz/eclipse-apps/emt"
exit 1;
fi

log "Started Eclipse install/update script."
cd $TARGET_DIR

# Get eclipse
if [[ ! -f "./$ECLIPSE_ARCHIVE.zip" ]] || [[ "$FORCE_DOWNLOAD" = "1" ]]; then
TAG=$(curl -s $API_URL \
| grep "\"name\"\: \"v" \
| cut -d : -f 2,3 \
| tr -d \" |tr -d ,)
log "Downloading latest eMoflon Eclipse archive from Github.\nRelease:$TAG"
curl -s $API_URL \
| grep "$ECLIPSE_ARCHIVE.*zip" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi -
fi

if [[ -f "./eclipse" ]]; then
log "Rename old Eclipse folder."
mv ./eclipse ./eclipse-old
fi

log "Extract new Eclipse archive."
unzip -qq -o $ECLIPSE_ARCHIVE.zip

if [[ -f "./eclipse-old" ]]; then
log "Remove old Eclipse folder."
rm -rf ./eclipse-old
fi

cd $START_PWD
log "Updated successfully."

0 comments on commit f212406

Please sign in to comment.