PageRenderTime 76ms CodeModel.GetById 33ms app.highlight 7ms RepoModel.GetById 34ms app.codeStats 0ms

/install/script/install.sh

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Shell | 132 lines | 120 code | 3 blank | 9 comment | 0 complexity | 74447aa4f24a24193d06e04a53484c57 MD5 | raw file
  1#!/bin/bash
  2
  3#
  4#Einstellen des Programmverzeichnisses
  5unset PROGRAM_DIR
  6#wenn root installiert, dann /usr/local/bin/
  7#wenn user installiert, dann ~/bin/
  8#wenn es wo anders hin soll, dann in der folgenden Zeile anders eintragen
  9#PROGRAM_DIR=""
 10#
 11#######################
 12
 13
 14MSG2="Java exec found in "
 15MSG3="OOPS, your java version is too old "
 16MSG4="You need to upgrade to JRE 1.6.x or newer from http://java.sun.com"
 17MSG5="Java version found: "
 18MSG6="Java version ok.."
 19MSG7="OOPS, you don't seem to have a valid JRE "
 20MSG8="OOPS, unable to locate java exec in "
 21MSG9=" hierarchy"
 22MSG10="Java exec not found in PATH, starting search.."
 23MSG11="Java exec found in PATH. Verifying.."
 24JARNAME="yabs.jar"
 25
 26
 27
 28SAVEIFS=$IFS
 29IFS=$(echo -en "\n\b")
 30
 31look_for_java()
 32{
 33  JAVADIR=/usr/java
 34  IFS=$'\n'
 35  potential_java_dirs=(`ls -1 "$JAVADIR" | sort | tac`)
 36  IFS=
 37  for D in "${potential_java_dirs[@]}"; do
 38    if [[ -d "$JAVADIR/$D" && -x "$JAVADIR/$D/bin/java" ]]; then
 39      JAVA_PROGRAM_DIR="$JAVADIR/$D/bin/"
 40      echo $MSG2 $JAVA_PROGRAM_DIR
 41      if check_version ; then
 42        return 0
 43      else
 44        return 1
 45      fi
 46    fi
 47  done
 48  echo $MSG8 "${JAVADIR}/" $MSG9 ; echo $MSG4
 49  return 1
 50}
 51
 52check_version()
 53{
 54  JAVA_HEADER=`${JAVA_PROGRAM_DIR}java -version 2>&1 | head -n 1`
 55  JAVA_IYABSL=`echo ${JAVA_HEADER} | cut -f1 -d' '`
 56
 57    VERSION=`echo ${JAVA_HEADER} | sed "s/java version \"\(.*\)\"/\1/"`
 58    if echo $VERSION | grep "^1.[0-5]" ; then
 59      echo $MSG3 "[${JAVA_PROGRAM_DIR}java = ${VERSION}]" ; echo $MSG4
 60      return 1
 61    else
 62      echo $MSG5 "[${JAVA_PROGRAM_DIR}java = ${VERSION}]" ; echo $MSG6
 63      return 0
 64    fi
 65
 66}
 67
 68
 69# locate and test the java executable
 70if [ "$JAVA_PROGRAM_DIR" = "" ]; then
 71  if ! command -v java &>/dev/null; then
 72    echo $MSG10
 73    if ! look_for_java ; then
 74      exit 1
 75    fi
 76  else
 77    echo $MSG11
 78    if ! check_version ; then
 79      if ! look_for_java ; then
 80        exit 1
 81      fi
 82    fi
 83  fi
 84fi
 85
 86
 87# get the app dir
 88
 89if [ "$PROGRAM_DIR" = "" ]
 90   then 
 91     if [ $(id -u) -eq 0 ]
 92        then PROGRAM_DIR=/usr/local/bin
 93     fi
 94     else 
 95        PROGRAM_DIR=$HOME/bin
 96fi
 97
 98
 99#Programmpfad zusammenbauen
100YABS=$PROGRAM_DIR/YaBS
101
102mkdir -p $YABS
103cp -r * $YABS
104
105
106echo "Program directory: ${YABS}"
107
108
109
110# build the classpath
111for FILE in ${YABS}/*.jar; do
112   CLASSPATH="${CLASSPATH:+${CLASSPATH}:}$FILE"
113done
114
115IFS=$SAVEIFS
116
117echo "#!/bin/bash" > yabs.sh
118echo "CLASSPATH=${CLASSPATH}" >> yabs.sh
119echo "IFS=$SAVEIFS" >> yabs.sh
120echo "${JAVA_PROGRAM_DIR}java -jar $YABS/$JARNAME $1 $2 $3 $4 $5 $6" >> yabs.sh
121chmod +x yabs.sh
122mv  yabs.sh $YABS
123pushd . > /dev/null
124cd $PROGRAM_DIR
125ln -s YaBS/yabs.sh yabs
126popd > /dev/null
127
128echo "Installation beendet. Programmstart mit 'yabs'"
129
130sync
131
132