| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | # Checking Java. Does not consider $HOME_JAVA |
| 4 | |
| 5 | if type -p java; then |
| 6 | version=$(javascip-shell system . . java. -version 2>&1 | awkscip-shell system . . awk. -F '"' '/version/ {print $2}scip-shell filesystem . . `/version/ {print $2}`.') |
| 7 | if [[ "$version" < "1.8" ]]; then |
| 8 | echoscip-shell system . . echo. "Java $version found but at least Java 8 is required." |
| 9 | exit 1; |
| 10 | fi |
| 11 | else |
| 12 | echoscip-shell system . . echo. "No java found. LaTeXDraw requires Java 8." |
| 13 | exit 1; |
| 14 | fi |
| 15 | |
| 16 | |
| 17 | # Getting the installation directory |
| 18 | |
| 19 | path="/optscip-shell filesystem . . `/opt`." |
| 20 | read -e -i "$path" -p "Enter the folder where LaTeXDraw will be installed (default: /opt): " input |
| 21 | path="${input:-$path}" # If empty, getting the default value |
| 22 | path=$(echoscip-shell system . . echo. "$path"|sedscip-shell system . . sed. 's/\/$//g') #Removing the trailing / |
| 23 | |
| 24 | # The installation dir must be a dir |
| 25 | |
| 26 | if [scip-shell system . . `[`. ! -d $path ] ; then |
| 27 | echoscip-shell system . . echo. "$path is not a directory." |
| 28 | exit 1; |
| 29 | fi |
| 30 | |
| 31 | installFolder="latexdraw" |
| 32 | launcher="/usr/bin/latexdrawscip-shell filesystem . . `/usr/bin/latexdraw`." |
| 33 | dir="$( cd "$( dirnamescip-shell system . . dirname. "${BASH_SOURCE[0]}" )" && pwdscip-shell system . . pwd. )" |
| 34 | datadir="data" |
| 35 | home=`eval echo "~$USER"` |
| 36 | |
| 37 | if [scip-shell system . . `[`. ! -w $launcher ] ; then |
| 38 | echoscip-shell system . . echo. "Cannot write in '/usr/bin'. Make sure to run the script with super user rights." |
| 39 | exit 1; |
| 40 | fi |
| 41 | |
| 42 | # Copying files |
| 43 | |
| 44 | if [scip-shell system . . `[`. ! -e $path/$installFolder/"lib" ] ; then |
| 45 | mkdirscip-shell system . . mkdir. -p $path/$installFolder/"lib" |
| 46 | fi |
| 47 | |
| 48 | if [scip-shell system . . `[`. ! -e "/usr/share/latexdraw/images/app/scip-shell filesystem . . `/usr/share/latexdraw/images/app/`." ] ; then |
| 49 | mkdirscip-shell system . . mkdir. -p "/usr/share/latexdraw/images/app/scip-shell filesystem . . `/usr/share/latexdraw/images/app/`." |
| 50 | fi |
| 51 | |
| 52 | if [scip-shell system . . `[`. ! -e $HOME/".latexdraw" ] ; then |
| 53 | mkdirscip-shell system . . mkdir. $HOME/".latexdraw" |
| 54 | fi |
| 55 | |
| 56 | cpscip-shell system . . cp. $dir/$datadir/"templates"/* "/usr/share/latexdraw/scip-shell filesystem . . `/usr/share/latexdraw/`." |
| 57 | cpscip-shell system . . cp. $dir/$datadir/".cache"/* $HOME/".latexdraw/.cacheShared" |
| 58 | cpscip-shell system . . cp. $dir/$datadir/"gnome/latexdraw.png" "/usr/share/latexdraw/images/app/scip-shell filesystem . . `/usr/share/latexdraw/images/app/`." |
| 59 | cpscip-shell system . . cp. $dir/$datadir/"gnome/latexdraw.desktop" "/usr/share/applications/scip-shell filesystem . . `/usr/share/applications/`." |
| 60 | |
| 61 | cpscip-shell system . . cp. --remove-destination $dir/$datadir/"LaTeXDraw.jar" $path/$installFolder/ |
| 62 | cpscip-shell system . . cp. --remove-destination $dir/"license.txt" $path/$installFolder/ |
| 63 | cpscip-shell system . . cp. --remove-destination $dir/"release_note.txt" $path/$installFolder/ |
| 64 | cpscip-shell system . . cp. --remove-destination $dir/$datadir/"lib"/* $path/$installFolder/"lib/" |
| 65 | |
| 66 | ## Creation of the launcher |
| 67 | |
| 68 | if [scip-shell system . . `[`. ! -e $launcher ] ; then |
| 69 | printfscip-shell system . . printf. "#! /bin/sh\njava -jar $path/$installFolder/LaTeXDraw.jar $@\n" > $launcher |
| 70 | chmodscip-shell system . . chmod. +x $launcher |
| 71 | fi |