r328: Changed the install script so that the CVS directories don't get installed.
[rox-filer.git] / install.sh
blob190c240be4e236cec60c1f7881f95e16e3d7f294
1 #!/usr/bin/env bash
3 if [ -n "$CHOICESPATH" ]; then
4 CHOICESPATH=${HOME}/Choices:/usr/local/share/Choices:/usr/share/Choices
5 fi
7 function die () {
8 echo "$*" >&2
9 echo "Aborting..." >&2
10 exit 1
13 # Create the directory if it doesn't exist. Exit if it can't be created.
14 function endir () {
15 if [ ! -d "$1" ]; then
16 mkdir "$1" || die "Can't create $1 directory!"
20 function confirm_or_die () {
21 while [ 1 -eq 1 ]; do
22 echo -n "[yes/no] >>> "
23 read CONFIRM
24 case $CONFIRM in
25 [yY]*) return;;
26 [nN]*) die "OK.";;
27 esac
28 done
31 cd `dirname $0`
33 ./ROX-Filer/AppRun --version 2> /dev/null
35 if [ $? -ne 0 ]; then
36 echo "Filer didn't run... attempting to compile..."
37 ./ROX-Filer/AppRun --compile
38 else
39 echo "Filer is already compiled - good"
42 echo Testing...
43 ./ROX-Filer/AppRun --version
44 if [ $? -ne 0 ]; then
45 die "Filer doesn't work! Giving up..."
48 cat << EOF
51 ROX-Filer comes with some icons and other defaults. These should be
52 installed where it can find them. By default, it looks in
53 \${HOME}/Choices (${HOME}/Choices in your case)
54 /usr/local/share/Choices
55 /usr/share/Choices
56 in that order. You can choose a different search path by setting
57 the CHOICESPATH environment variable before running the filer.
59 Which Choices directory would you like to use? Option (1) is recommended
60 if you have root access; otherwise option (2) is best.
62 1) /usr/local/share/Choices
63 2) ${HOME}/Choices
64 3) /usr/share/Choices
66 Enter 1, 2, 3 or a path (starting with /):
67 EOF
68 echo -n ">>> "
70 read REPLY
71 echo
73 case $REPLY in
74 1) CHOICES=/usr/local/share/Choices;;
75 2) CHOICES=${HOME}/Choices;;
76 3) CHOICES=/usr/share/Choices;;
77 /*) CHOICES="$REPLY"
78 CHOICESPATH="${CHOICES}:${CHOICESPATH}"
79 echo "*** NOTE that if you install into a non-standard Choices "
80 echo "*** directory then you must ensure that CHOICESPATH is set "
81 echo "*** correctly before running the filer!"
82 echo
83 export CHOICESPATH;;
84 *) die "Invalid choice!";;
85 esac
87 echo "Default icons and run actions will be installed into '$CHOICES'."
89 endir "$CHOICES"
91 if [ -d "$CHOICES/MIME-icons" ]; then
92 cat << EOF
93 WARNING: You already have a $CHOICES/MIME-icons directory --- any icons you
94 have modified will be overwritten!
96 Continue? [y/n]
97 EOF
98 echo -n ">>> "
99 read REPLY
100 case $REPLY in
101 [yY]*) ;;
102 *) die "OK, back up the ones you want and try again...";;
103 esac
106 endir "$CHOICES/MIME-icons"
107 endir "$CHOICES/MIME-info"
108 endir "$CHOICES/MIME-types"
110 echo "Installing icons..."
111 cp Choices/MIME-icons/* "$CHOICES/MIME-icons"
113 echo "Installing other files. If you haven't modified these since the "
114 echo "last installation then answer 'yes' to any questions about overwriting "
115 echo "files. Otherwise, you'll have to decide what to do!"
116 cp -i Choices/MIME-types/* "$CHOICES/MIME-types"
117 cp -i Choices/MIME-info/* "$CHOICES/MIME-info"
118 echo
119 echo "OK, done that. Next step..."
121 cat << EOF
124 Where would you like to install the filer itself?
125 Normally, you should choose (1) if you have root access, or (2) if not.
127 1) /usr/local/apps
128 2) ${HOME}/Apps
129 3) /usr/apps
130 4) Leave it where it is (it'll still work)
132 Enter 1, 2, 3, 4 or a path (starting with /):
134 echo -n ">>> "
136 read REPLY
137 echo
139 case $REPLY in
140 1) APPDIR=/usr/local/apps;;
141 2) APPDIR=${HOME}/Apps;;
142 3) APPDIR=/usr/apps;;
143 4) APPDIR="";;
144 /*) APPDIR="$REPLY";;
145 *) die "Invalid choice!";;
146 esac
148 if [ -n "$APPDIR" ]; then
149 endir "$APPDIR"
151 (cd ROX-Filer/src; make clean) > /dev/null
152 if [ -e "$APPDIR/ROX-Filer" ]; then
153 echo "ROX-Filer is already installed - delete the existing"
154 echo "copy?"
155 confirm_or_die
156 echo Deleting...
157 rm -rf "$APPDIR/ROX-Filer.old"
159 cp -r ROX-Filer "$APPDIR"
160 else
161 echo "OK, I'll leave it where it is."
162 APPDIR=`pwd`
165 echo Making ROX-Filer the default handler for directories...
166 rm "$CHOICES/MIME-types/special_directory" 2> /dev/null
167 ln -s "$APPDIR/ROX-Filer" "$CHOICES/MIME-types/special_directory"
169 cat << EOF
172 Where would you like to install the 'rox' script, which is used to run
173 the filer?
175 1) /usr/local/bin
176 2) ${HOME}/bin
177 3) /usr/bin
178 4) I don't want to install it
180 Enter 1, 2, 3, 4 or a path (starting with /):
183 echo -n ">>> "
184 read REPLY
185 echo
187 case $REPLY in
188 1) BINDIR=/usr/local/bin;;
189 2) BINDIR=${HOME}/bin;;
190 3) BINDIR=/usr/bin;;
191 4) BINDIR="";;
192 /*) BINDIR="$REPLY";;
193 *) die "Invalid choice!";;
194 esac
196 if [ -n "$BINDIR" ]; then
197 endir "$BINDIR"
199 cat > "$BINDIR/rox" << EOF
200 #!/bin/sh
201 exec $APPDIR/ROX-Filer/AppRun "\$@"
203 [ $? -eq 0 ] || die "Failed to install 'rox' script"
204 chmod a+x "$BINDIR/rox"
206 cat << EOF
207 Script installed. You can run the filer by simply typing 'rox'
208 Make sure that $BINDIR is in your PATH though - if it isn't then
209 you must use
210 \$ $BINDIR/rox
211 to run it instead.
213 else
214 cat << EOF
215 OK, skipping installation of the 'rox' script.
216 To run the filer in future, use:
218 \$ $APPDIR/ROX-Filer/AppRun.
222 sleep 3
223 cat << EOF
225 ****************************
226 *** Now read the manual! ***
227 ****************************
229 Run ROX and click on the information icon on the toolbar:
231 \$ rox &