r1524: Merged rox-base with rox.
[rox-filer.git] / install.sh
blobe13fd9be80eb3b2cb7ca191001abf82c1e5637a9
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
75 CHOICESDIR=/usr/local/share/Choices
76 MIMEDIR=/usr/local/share/mime/mime-info
78 2) APPDIR=${HOME}/Apps
79 BINDIR=${HOME}/bin
80 CHOICESDIR=${HOME}/Choices
81 MIMEDIR=${HOME}/.mime/mime-info
82 if [ ! -d ${HOME}/man ]; then
83 MANDIR=""
84 else
85 MANDIR=${HOME}/man
88 3) APPDIR=/usr/apps
89 BINDIR=/usr/bin
90 MANDIR=/usr/man
91 CHOICESDIR=/usr/share/Choices
92 MIMEDIR=/usr/local/mime/mime-info
94 4) echo "Where should the ROX-Filer application go?"
95 get_dir "/usr/local/apps"
96 APPDIR="$DIR"
97 echo
98 echo "Where should the launcher script go?"
99 get_dir "/usr/local/bin"
100 BINDIR="$DIR"
101 echo
102 echo "Where should the manual page go?"
103 get_dir "/usr/local/man"
104 MANDIR="$DIR"
105 echo
106 echo "Where should the default icons and run actions go?"
107 get_dir "/usr/local/share/Choices"
108 CHOICESDIR="$DIR"
109 echo
110 echo "Where should the MIME info file go?"
111 get_dir "/usr/local/share/mime/mime-info"
112 MIMEDIR="$DIR"
114 *) die "Invalid choice!";;
115 esac
117 MIMEINFO="${MIMEDIR}/rox.mimeinfo"
119 cat << EOF
120 The application directory will be:
121 $APPDIR/ROX-Filer
123 The launcher script will be:
124 $BINDIR/rox
126 Icons and run actions will be in:
127 $CHOICESDIR
129 MIME-info rules will be:
130 $MIMEINFO
133 if [ -n "$MANDIR" ]; then
134 echo "The manual pages will be:"
135 echo " $MANDIR/man1/rox.1"
136 echo " $MANDIR/man1/ROX-Filer.1"
137 else
138 echo "The manual page will not be installed."
141 echo
142 echo "OK?"
143 confirm_or_die
144 echo
146 if [ -n "$MANDIR" ]; then
147 echo "Installing manpage..."
148 endir "$MANDIR"
149 endir "$MANDIR/man1"
150 cp rox.1 "$MANDIR/man1/rox.1" || die "Can't install manpage!"
151 rm -f "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
152 ln -s "$MANDIR/man1/rox.1" "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
155 echo "Installing icons (existing icons will not be replaced)..."
156 endir "$CHOICESDIR/MIME-icons"
157 endir "$CHOICESDIR/MIME-types"
158 cd Choices || die "Choices missing"
159 for file in MIME-*/*; do
160 if [ -f "$file" ]; then
161 dest="$CHOICESDIR/$file"
162 if [ ! -f "$dest" ]; then
163 if [ ! -d "$dest" ]; then
164 echo Install $file as $dest
165 cp "$file" "$dest"
169 done
170 cd ..
172 endir "$MIMEDIR"
173 cp rox.mimeinfo "$MIMEINFO" || die "Failed to create $MIMEINFO"
175 echo "Installing application..."
176 endir "$APPDIR"
178 (cd ROX-Filer/src; make clean) > /dev/null
179 if [ -d "$APPDIR/ROX-Filer" ]; then
180 echo "ROX-Filer is already installed - delete the existing"
181 echo "copy?"
182 confirm_or_die
183 echo Deleting...
184 rm -rf "$APPDIR/ROX-Filer"
186 cp -r ROX-Filer "$APPDIR"
188 echo "Installing launcher script..."
189 endir "$BINDIR"
191 cat > "$BINDIR/rox" << EOF
192 #!/bin/sh
193 exec $APPDIR/ROX-Filer/AppRun "\$@"
195 [ $? -eq 0 ] || die "Failed to install 'rox' script"
196 chmod a+x "$BINDIR/rox"
198 cat << EOF
200 Script installed. You can run the filer by simply typing 'rox'
201 Make sure that $BINDIR is in your PATH though - if it isn't then
202 you must use
203 \$ $BINDIR/rox
204 to run it instead.
206 ****************************
207 *** Now read the manual! ***
208 ****************************
210 Run ROX and click on the information icon on the toolbar:
212 \$ rox