-
Notifications
You must be signed in to change notification settings - Fork 3
/
emoflon-update.sh
64 lines (51 loc) · 1.45 KB
/
emoflon-update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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-ibex-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::IBeX 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."