1#!/usr/bin/env bash
2
3appname=ugenecl
4
5# Check if '-ui' parameter is present.
6# If it does exclude it from the list of parameters and use ugeneui instead of ugenecl
7
8params=()
9
10while [[ $# -gt 0 ]]; do
11  if [ "$1" = "-ui" ]; then
12    appname=ugeneui
13  else
14    params+=("$1")
15  fi
16  shift
17done
18
19dirname=$(dirname "$(readlink -f "$0")")
20
21tmp="${dirname#?}"
22
23if [ "${dirname%$tmp}" != "/" ]; then
24  dirname="$PWD/$dirname"
25fi
26
27# Check compatibility OS and UGENE (32-bit or 64-bit)
28system_i686=false
29
30case "$(uname -m | grep -c 64 | tr -d ' ')" in
310*) system_i686=true ;;
32esac
33
34ugene_i686=false
35ugene_x86_64=false
36
37case "$(file -b "$dirname/$appname" | cut -d "," -f1 | grep -c 64 | tr -d ' ')" in
380*) ugene_i686=true ;;
391*) ugene_x86_64=true ;;
40esac
41
42if $system_i686; then
43  if $ugene_x86_64; then
44    echo "Warning: You have a 32-bit operating system but you are trying to launch a 64-bit version of the UGENE package. You have to download the appropriate UGENE version instead."
45  fi
46else
47  if $ugene_i686; then
48    echo "Warning: You have a 64-bit operating system but you are trying to launch a 32-bit version of the UGENE package. You have to download the appropriate UGENE version instead."
49  fi
50fi
51
52"$dirname"/"$appname" "${params[@]}"
53