updated on Mon Jan 16 00:01:41 UTC 2012
[aur-mirror.git] / regain-desktop / start-regain.sh
blob76cabe8dad5dcc0c6b51cd2db992295c05b0712d
1 #! /bin/bash
3 # Please note: This script was not provided by the authors of Regain, but
4 # by the maintainer of the PKGBUILD - Frank Poehler <fp29129@googlemail.com>.
5 # It is released under the same license as Regain.
6 # For questions, suggestions or bug reports regarding this script,
7 # just drop me a line.
10 REGAIN_PATH="/opt/regain-desktop"
11 USER_PATH="/home/$USER/.local/share/regain-desktop"
13 install_in_userspace() {
14 if ! test -e "$USER_PATH"; then
15 mkdir -p "$USER_PATH"
16 echo "Created user's Regain directory in '$USER_PATH'."
17 else
18 if ! test -d "$USER_PATH"; then
19 save_ext=".saved_`date`"
20 mv "$USER_PATH" "$USER_PATH$save_ext" || exit 1
21 echo "Tried to create user's Regain directory in '$USER_PATH', but found something here that does not seem to belong to Regain Desktop Search."
22 echo "Moved that to '$USER_PATH$save_ext'".
23 mkdir -p "$USER_PATH"
24 echo "Now created user's Regain directory in '$USER_PATH'."
28 if ! test -e "$USER_PATH"/conf; then
29 mkdir -p "$USER_PATH"/conf
30 cp -R --preserve=mode "$REGAIN_PATH"/conf/default "$USER_PATH"/conf/
31 echo "Copied default configuration into user's Regain directory."
32 echo "For details about Regain configuration, see"
33 echo "http://regain.murfman.de/wiki/doku.php?id=config"
34 else
35 if ! test -d "$USER_PATH"/conf; then
36 save_ext=".saved_`date`"
37 mv "$USER_PATH"/conf "$USER_PATH/conf$save_ext" || exit 1
38 echo "Tried to copy default configuration files into '$USER_PATH/conf', but found something here that does seem to not belong to Regain Desktop Search."
39 mkdir "$USER_PATH"/conf || exit 1
40 cp -R --preserve=mode "$REGAIN_PATH"/conf/default "$USER_PATH"/conf/ || exit 1
41 echo "Moved that to '$USER_PATH/conf$save_ext'".
42 echo "Now copied default configuration files into '$USER_PATH'"
46 for i in 'preparator' 'web' 'regain.jar'; do
47 if ! test -e "$USER_PATH/$i"; then
48 ln -s "$REGAIN_PATH/$i" "$USER_PATH"
49 echo "Sym-linked '$REGAIN_PATH/$i' to '$USER_PATH/$i'."
51 done
54 if [ `whoami` == "root" ] ; then
55 USER_PATH="$REGAIN_PATH"
56 else
57 install_in_userspace
60 cd "$USER_PATH"
61 running=`lsof "$USER_PATH"/regain.jar 2>/dev/null`
62 if test -z "$running"; then
63 echo "Starting Regain..."
64 java -Djava.library.path=/usr/lib/jni -jar regain.jar
65 else
66 echo
67 echo "Regain is already running."
68 echo "To stop it, do"
69 echo " lsof ""$USER_PATH"/regain.jar
70 echo 'grab the PID and do'
71 echo ' kill <PID>'
72 echo 'To restart Regain, run this script again after you have killed the running instance of Regain as described above.'
73 echo
74 exit 1
75 fi