updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / mysql-gui-tools / mysql-administrator
blobc6c36f3f0129a53740fc17b00b26401c54672a82
1 #!/bin/sh
3 PRG="$0"
5 # need this for relative symlinks
6 while [ -h "$PRG" ] ; do
7 ls=`ls -ld "$PRG"`
8 link=`expr "$ls" : '.*-> \(.*\)$'`
9 if expr "$link" : '/.*' > /dev/null; then
10 PRG="$link"
11 else
12 PRG=`dirname "$PRG"`"/$link"
14 done
16 DIRNAME=`dirname $PRG`
18 tmp_DIRNAME1=`cd $DIRNAME/..; pwd`
19 tmp_DIRNAME2=`cd $DIRNAME; pwd`
21 if [ -d "$tmp_DIRNAME1/share" ]; then
22 # installed to /
23 DIRNAME="$tmp_DIRNAME1"
24 LIBPREFIX="$DIRNAME/lib/mysql-gui"
25 elif [ -d "$tmp_DIRNAME2/share" ]; then
26 # installed to /opt or something similar
27 DIRNAME="$tmp_DIRNAME2"
28 LIBPREFIX="$DIRNAME"
29 else
30 echo "Data files not found. Please check your installation."
31 exit 1
34 DIRNAME=/
36 if [ -f "$LIBPREFIX/lib/pango.modules" ]; then
37 bundled_deps=1
38 else
39 bundled_deps=0
42 export MA_DIR="$DIRNAME"
43 export LD_LIBRARY_PATH="$LIBPREFIX/lib:$LD_LIBRARY_PATH"
45 ### begin stuff needed for bundled gtk libraries
46 pangorc_path=$LIBPREFIX/lib/pangorc
47 gdkpixbuf_path=$LIBPREFIX/lib/gdk-pixbuf.loaders
48 pangomodules_path=$LIBPREFIX/lib/pango.modules
49 desktopfile_path=$DIRNAME/MySQLAdministrator.desktop
51 if [ $bundled_deps -ne 0 ]; then
52 args=""
53 for arg in $*; do
54 if test $arg = "--update-paths"; then
55 echo "Updating `basename $0` installation paths..."
56 old_prefix=$(grep ModuleFiles $pangorc_path|sed -e 's#.*=.\?\(/.*\)/lib/pango.modules#\1#')
57 new_prefix=$LIBPREFIX
59 # replace paths in our custom configuration files
60 for f in $pangorc_path $gdkpixbuf_path $pangomodules_path $desktopfile_path; do
61 sed -e "s:$old_prefix:$new_prefix:g" $f > $f.bak
62 if [ $? -ne 0 ]; then
63 echo "Error updating files for new installation path."
64 echo "Please make sure `basename $0` is installed correctly and you have"
65 echo "proper write permissions in the installation directory."
66 exit 1
68 mv $f.bak $f
69 if [ $? -ne 0 ]; then
70 echo "Error updating files for new installation path."
71 echo "Please make sure `basename $0` is installed correctly and you have"
72 echo "proper write permissions in the installation directory."
73 exit 1
75 done
76 echo "Done."
77 exit
78 else
79 args="$args \"$arg\""
81 done
84 # if we're in a bundle, make sure the paths in the pango and gdk-pixbuf
85 # loaders are correct
86 export GDK_PIXBUF_MODULE_FILE="$gdkpixbuf_path"
87 export PANGO_RC_FILE="$pangorc_path"
88 export GTK_EXE_PREFIX="$LIBPREFIX"
90 prefix=$(grep ModuleFiles $pangorc_path|sed -e 's#.*=.\?\(/.*\)/lib/pango.modules#\1#')
92 if ! [ -f "$prefix/lib/pango.modules" ]; then
93 cat <<EOF
94 Error starting $0.
95 The actual installation path of `basename $0` is different from the
96 expected one. Please run $0 --update-paths (as the root
97 user, if needed) to have the installation directory updated.
98 EOF
99 exit 1
102 ### end stuff needed for bundled gtk libraries
105 $PRG-bin $args