r1475: Wrap long icon names onto multiple lines.
[rox-filer.git] / install.sh
blob1bae5943ac3385e5f2bb83a14a87675c6e7c5d05
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
52 cat << EOF
54 **************************************************************************
56 Where would you like to install the filer?
57 Normally, you should choose (1) if you have root access, or (2) if not.
59 1) Inside /usr/local
60 2) Inside my home directory
61 3) Inside /usr
62 4) Specify paths manually
64 Enter 1, 2, 3 or 4:
65 EOF
66 printf ">>> "
68 read REPLY
69 echo
71 case $REPLY in
72 1) APPDIR=/usr/local/apps
73 BINDIR=/usr/local/bin
74 MANDIR=/usr/local/man
76 2) APPDIR=${HOME}/Apps
77 BINDIR=${HOME}/bin
78 if [ ! -d ${HOME}/man ]; then
79 MANDIR=""
80 else
81 MANDIR=${HOME}/man
84 3) APPDIR=/usr/apps
85 BINDIR=/usr/bin
86 MANDIR=/usr/man
88 4) echo "Where should the ROX-Filer application go?"
89 get_dir "/usr/local/apps"
90 APPDIR="$DIR"
91 echo
92 echo "Where should the launcher script go?"
93 get_dir "/usr/local/bin"
94 BINDIR="$DIR"
95 echo
96 echo "Where should the manual page go?"
97 get_dir "/usr/local/man"
98 MANDIR="$DIR"
100 *) die "Invalid choice!";;
101 esac
103 cat << EOF
105 The application directory will be:
106 $APPDIR/ROX-Filer
108 The launcher script will be:
109 $BINDIR/rox
112 if [ -n "$MANDIR" ]; then
113 echo "The manual pages will be:"
114 echo " $MANDIR/man1/rox.1"
115 echo " $MANDIR/man1/ROX-Filer.1"
116 else
117 echo "The manual page will not be installed."
120 echo
121 echo "OK?"
122 confirm_or_die
123 echo
125 if [ -n "$MANDIR" ]; then
126 echo "Installing manpage..."
127 endir "$MANDIR"
128 endir "$MANDIR/man1"
129 cp rox.1 "$MANDIR/man1/rox.1" || die "Can't install manpage!"
130 rm -f "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
131 ln -s "$MANDIR/man1/rox.1" "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
134 echo "Installing application..."
135 endir "$APPDIR"
137 (cd ROX-Filer/src; make clean) > /dev/null
138 if [ -d "$APPDIR/ROX-Filer" ]; then
139 echo "ROX-Filer is already installed - delete the existing"
140 echo "copy?"
141 confirm_or_die
142 echo Deleting...
143 rm -rf "$APPDIR/ROX-Filer"
145 cp -r ROX-Filer "$APPDIR"
147 echo "Installing launcher script..."
148 endir "$BINDIR"
150 cat > "$BINDIR/rox" << EOF
151 #!/bin/sh
152 exec $APPDIR/ROX-Filer/AppRun "\$@"
154 [ $? -eq 0 ] || die "Failed to install 'rox' script"
155 chmod a+x "$BINDIR/rox"
157 cat << EOF
158 Script installed. You can run the filer by simply typing 'rox'
159 Make sure that $BINDIR is in your PATH though - if it isn't then
160 you must use
161 \$ $BINDIR/rox
162 to run it instead.
165 if [ ! -n "$CHOICESPATH" ]; then
166 CHOICESPATH=${HOME}/Choices:/usr/local/share/Choices:/usr/share/Choices
169 cat << EOF
172 ROX-Filer requires some icons and other defaults. These should be
173 installed where it can find them. By default, it looks in
174 \${HOME}/Choices (${HOME}/Choices in your case)
175 /usr/local/share/Choices
176 /usr/share/Choices
177 in that order. You can choose a different search path by setting
178 the CHOICESPATH environment variable before running the filer. These
179 files are supplied in the 'rox-base' package. Make sure you have the
180 latest version installed!
184 IFS=":"
185 REPORT="I couldn't find the required files!"
187 for DIR in $CHOICESPATH; do
188 if [ ! -n "$DIR" ]; then
189 continue
192 echo Looking for files in $DIR...
194 if [ -f "$DIR/MIME-icons/special_executable.xpm" ]; then
195 REPORT=""
196 echo "Found them!"
197 break
198 elif [ -d "$DIR/MIME-icons" ]; then
199 REPORT="I found an old installation in $DIR, but not the latest version."
201 done
203 if [ -n "$REPORT" ]; then
204 echo
205 echo $REPORT
206 echo "Please download and install the latest version of the rox-base package"
207 echo "from http://rox.sourceforge.net before using the filer!"
208 echo
209 echo "Continue?"
210 confirm_or_die
213 cat << EOF
216 ****************************
217 *** Now read the manual! ***
218 ****************************
220 Run ROX and click on the information icon on the toolbar:
222 \$ rox