r313: Added some details about CVS to the README and fixed a silly bug in
[rox-filer/ma.git] / install.sh
blob9ced201acc9b4a889ffa6dce2dcf4effec542d07
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 cd `dirname $0`
22 ./ROX-Filer/AppRun --version 2> /dev/null
24 if [ $? -ne 0 ]; then
25 echo "Filer didn't run... attempting to compile..."
26 ./ROX-Filer/AppRun --compile
27 else
28 echo "Filer is already compiled - good"
31 echo Testing...
32 ./ROX-Filer/AppRun --version
33 if [ $? -ne 0 ]; then
34 die "Filer doesn't work! Giving up..."
37 cat << EOF
40 ROX-Filer comes with some icons and other defaults. These should be
41 installed where it can find them. By default, it looks in
42 \${HOME}/Choices (${HOME}/Choices in your case)
43 /usr/local/share/Choices
44 /usr/share/Choices
45 in that order. You can choose a different search path by setting
46 the CHOICESPATH environment variable before running the filer.
48 Which Choices directory would you like to use? Option (1) is recommended
49 if you have root access; otherwise option (2) is best.
51 1) /usr/local/share/Choices
52 2) ${HOME}/Choices
53 3) /usr/share/Choices
55 Enter 1, 2, 3 or a path (starting with /):
56 EOF
57 echo -n ">>> "
59 read REPLY
60 echo
62 case $REPLY in
63 1) CHOICES=/usr/local/share/Choices;;
64 2) CHOICES=${HOME}/Choices;;
65 3) CHOICES=/usr/share/Choices;;
66 /*) CHOICES="$REPLY"
67 CHOICESPATH="${CHOICES}:${CHOICESPATH}"
68 echo "*** NOTE that if you install into a non-standard Choices "
69 echo "*** directory then you must ensure that CHOICESPATH is set "
70 echo "*** correctly before running the filer!"
71 echo
72 export CHOICESPATH;;
73 *) die "Invalid choice!";;
74 esac
76 echo "Default icons and run actions will be installed into '$CHOICES'."
78 endir "$CHOICES"
80 if [ -d "$CHOICES/MIME-icons" ]; then
81 cat << EOF
82 WARNING: You already have a $CHOICES/MIME-icons directory --- any icons you
83 have modified will be overwritten!
85 Continue? [y/n]
86 EOF
87 echo -n ">>> "
88 read REPLY
89 case $REPLY in
90 [yY]*) ;;
91 *) die "OK, back up the ones you want and try again...";;
92 esac
95 echo "Installing icons..."
96 cp -r Choices/MIME-icons "$CHOICES"
98 echo "Installing other files. If you haven't modified these since the "
99 echo "last installation then answer 'yes' to any questions about overwriting "
100 echo "files. Otherwise, you'll have to decide what to do!"
101 cp -ri Choices/MIME-types "$CHOICES"
102 cp -ri Choices/MIME-info "$CHOICES"
103 echo
104 echo "OK, done that. Next step..."
106 cat << EOF
109 Where would you like to install the filer itself?
110 Normally, you should choose (1) if you have root access, or (2) if not.
112 1) /usr/local/apps
113 2) ${HOME}/Apps
114 3) /usr/apps
115 4) Leave it where it is (it'll still work)
117 Enter 1, 2, 3, 4 or a path (starting with /):
119 echo -n ">>> "
121 read REPLY
122 echo
124 case $REPLY in
125 1) APPDIR=/usr/local/apps;;
126 2) APPDIR=${HOME}/Apps;;
127 3) APPDIR=/usr/apps;;
128 4) APPDIR="";;
129 /*) APPDIR="$REPLY";;
130 *) die "Invalid choice!";;
131 esac
133 if [ -n "$APPDIR" ]; then
134 endir "$APPDIR"
136 (cd ROX-Filer/src; make clean) > /dev/null
137 cp -r ROX-Filer $APPDIR
138 else
139 echo "OK, I'll leave it where it is."
140 APPDIR=`pwd`
143 echo Making ROX-Filer the default handler for directories...
144 rm "$CHOICES/MIME-types/special_directory" 2> /dev/null
145 ln -s "$APPDIR/ROX-Filer" "$CHOICES/MIME-types/special_directory"
147 cat << EOF
150 Where would you like to install the 'rox' script, which is used to open
151 files (and, often, start the filer)?
153 1) /usr/local/bin
154 2) ${HOME}/bin
155 3) /usr/bin
156 4) I don't want to install it
158 Enter 1, 2, 3, 4 or a path (starting with /):
161 echo -n ">>> "
162 read REPLY
163 echo
165 case $REPLY in
166 1) BINDIR=/usr/local/bin;;
167 2) BINDIR=${HOME}/bin;;
168 3) BINDIR=/usr/bin;;
169 4) BINDIR="";;
170 /*) BINDIR="$REPLY";;
171 *) die "Invalid choice!";;
172 esac
174 if [ -n "$BINDIR" ]; then
175 endir "$BINDIR"
177 cp rox "$BINDIR" || die "Failed to install 'rox' script"
179 cat << EOF
180 Script installed. You can run the filer by simply typing 'rox'
181 Make sure that $BINDIR is in your PATH though - if it isn't then
182 you must use
183 \$ $BINDIR/rox
184 to run it instead.
186 else
187 cat << EOF
188 OK, skipping installation of the 'rox' script.
189 To run the filer in future, use:
191 \$ $APPDIR/ROX-Filer/AppRun.
195 sleep 3
196 cat << EOF
198 ****************************"
199 *** Now read the manual! ***"
200 ****************************"
202 Type:
204 \$ $APPDIR/ROX-Filer/AppRun $APPDIR/ROX-Filer/Help &