r1552: When installing without a manpage, just warn the user instead of aborting
[rox-filer.git] / install.sh
bloba17b007b6928d96d4a016e42d1b2f7a2fc69cd0c
1 #!/bin/sh
3 die() {
4 echo "$*" >&2
5 echo "Aborting..." >&2
6 exit 1
9 get_dir() {
10 while [ 1 -eq 1 ]; do
11 printf "[$1] >>> "
12 read DIR
14 case "$DIR" in
15 /*) return;;
16 ?*) echo "The path must start with a \`/'";;
17 *) DIR="$1"
18 echo OK, using default value.
19 return;;
20 esac
21 done
24 # Create the directory if it doesn't exist. Exit if it can't be created.
25 endir() {
26 if [ ! -d "$1" ]; then
27 mkdir -p "$1" || die "Can't create $1 directory!"
31 confirm_or_die() {
32 while [ 1 -eq 1 ]; do
33 printf "[yes/no] >>> "
34 read CONFIRM
35 case "$CONFIRM" in
36 [yY]*) return;;
37 [nN]*) die "OK.";;
38 esac
39 done
42 cd `dirname $0`
44 echo Testing the filer...
45 ./ROX-Filer/AppRun -v
46 if [ $? -ne 0 ]; then
47 die "Filer doesn't work! Giving up..."
50 umask 022
53 cat << EOF
55 **************************************************************************
57 Where would you like to install the filer?
58 Normally, you should choose (1) if you have root access, or (2) if not.
60 1) Inside /usr/local
61 2) Inside my home directory
62 3) Inside /usr
63 4) Specify paths manually
65 Enter 1, 2, 3 or 4:
66 EOF
67 printf ">>> "
69 read REPLY
70 echo
72 case $REPLY in
73 1) APPDIR=/usr/local/apps
74 BINDIR=/usr/local/bin
75 MANDIR=/usr/local/man
76 CHOICESDIR=/usr/local/share/Choices
77 MIMEDIR=/usr/local/share/mime/mime-info
79 2) APPDIR=${HOME}/Apps
80 BINDIR=${HOME}/bin
81 if [ -n "$CHOICESPATH" ]; then
82 CHOICESDIR=`echo $CHOICESPATH | sed -e 's/^\([^:]*\).*$/\\1/'`
84 echo -$CHOICESDIR-
85 if [ ! -n "$CHOICESDIR" ]; then
86 CHOICESDIR=${HOME}/Choices
88 MIMEDIR=${HOME}/.mime/mime-info
89 if [ ! -d ${HOME}/man ]; then
90 MANDIR=""
91 else
92 MANDIR=${HOME}/man
95 3) APPDIR=/usr/apps
96 BINDIR=/usr/bin
97 MANDIR=/usr/man
98 CHOICESDIR=/usr/share/Choices
99 MIMEDIR=/usr/local/mime/mime-info
101 4) echo "Where should the ROX-Filer application go?"
102 get_dir "/usr/local/apps"
103 APPDIR="$DIR"
104 echo
105 echo "Where should the launcher script go?"
106 get_dir "/usr/local/bin"
107 BINDIR="$DIR"
108 echo
109 echo "Where should the manual page go?"
110 get_dir "/usr/local/man"
111 MANDIR="$DIR"
112 echo
113 echo "Where should the default icons and run actions go?"
114 get_dir "/usr/local/share/Choices"
115 CHOICESDIR="$DIR"
116 echo
117 echo "Where should the MIME info file go?"
118 get_dir "/usr/local/share/mime/mime-info"
119 MIMEDIR="$DIR"
121 *) die "Invalid choice!";;
122 esac
124 MIMEINFO="${MIMEDIR}/rox.mimeinfo"
126 cat << EOF
127 The application directory will be:
128 $APPDIR/ROX-Filer
130 The launcher script will be:
131 $BINDIR/rox
133 Icons and run actions will be in:
134 $CHOICESDIR
136 MIME-info rules will be:
137 $MIMEINFO
140 if [ ! -f rox.1 ]; then
141 echo '*** The ROX-Filer manpage (rox.1) is missing.'
142 echo '*** It can be created from Manual.xml by running'
143 echo "*** 'make' in the ROX-Filer/src/Docs directory."
144 echo '*** The daily CVS snapshots have it ready-built'
145 echo
146 MANDIR=""
149 if [ -n "$MANDIR" ]; then
150 echo "The manual pages will be:"
151 echo " $MANDIR/man1/rox.1"
152 echo " $MANDIR/man1/ROX-Filer.1"
153 else
154 echo "The manual page will not be installed."
157 echo
158 echo "OK?"
159 confirm_or_die
160 echo
162 if [ -n "$MANDIR" ]; then
163 echo "Installing manpage..."
164 endir "$MANDIR"
165 endir "$MANDIR/man1"
166 cp rox.1 "$MANDIR/man1/rox.1" || die "Can't install manpage!"
167 rm -f "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
168 ln -s "$MANDIR/man1/rox.1" "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
171 echo "Installing icons (existing icons will not be replaced)..."
172 endir "$CHOICESDIR/MIME-icons"
173 endir "$CHOICESDIR/MIME-types"
174 cd Choices || die "Choices missing"
175 for file in MIME-*/*; do
176 if [ -f "$file" ]; then
177 dest="$CHOICESDIR/$file"
178 if [ ! -f "$dest" ]; then
179 if [ ! -d "$dest" ]; then
180 echo Install $file as $dest
181 cp "$file" "$dest"
185 done
186 cd ..
188 endir "$MIMEDIR"
189 cp rox.mimeinfo "$MIMEINFO" || die "Failed to create $MIMEINFO"
191 echo "Installing application..."
192 endir "$APPDIR"
194 (cd ROX-Filer/src; make clean) > /dev/null
195 if [ -d "$APPDIR/ROX-Filer" ]; then
196 echo "ROX-Filer is already installed - delete the existing"
197 echo "copy?"
198 confirm_or_die
199 echo Deleting...
200 rm -rf "$APPDIR/ROX-Filer"
202 cp -r ROX-Filer "$APPDIR"
204 echo "Installing launcher script..."
205 endir "$BINDIR"
207 cat > "$BINDIR/rox" << EOF
208 #!/bin/sh
209 exec $APPDIR/ROX-Filer/AppRun "\$@"
211 [ $? -eq 0 ] || die "Failed to install 'rox' script"
212 chmod a+x "$BINDIR/rox"
214 cat << EOF
216 Script installed. You can run the filer by simply typing 'rox'
217 Make sure that $BINDIR is in your PATH though - if it isn't then
218 you must use
219 \$ $BINDIR/rox
220 to run it instead.
222 ****************************
223 *** Now read the manual! ***
224 ****************************
226 Run ROX and click on the information icon on the toolbar:
228 \$ rox