r3224: Renamed 'Info' menu item to 'Properties'.
[rox-filer.git] / install.sh
blob6930f6dffc16e7f2135dbe3cdea8d0792394963c
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 SHAREDIR=/usr/local/share
76 CHOICESDIR=${SHAREDIR}/Choices
77 MANDIR=/usr/local/man # (not under share!)
79 2) APPDIR=${HOME}/Apps
80 BINDIR=${HOME}/bin
81 if [ -n "$CHOICESPATH" ]; then
82 CHOICESDIR=`echo $CHOICESPATH | sed -e 's/^\([^:]*\).*$/\\1/'`
84 if [ ! -n "$CHOICESDIR" ]; then
85 CHOICESDIR=${HOME}/Choices
87 if [ -n "$XDG_DATA_HOME" ]; then
88 SHAREDIR=${XDG_DATA_HOME}
89 else
90 SHAREDIR=${HOME}/.local/share
92 MANDIR=${HOME}/man
93 if [ ! -d "$MANDIR" ]; then
94 MANDIR=
97 3) APPDIR=/usr/apps
98 BINDIR=/usr/bin
99 SHAREDIR=/usr/share
100 CHOICESDIR=${SHAREDIR}/Choices
101 MANDIR=${SHAREDIR}/man
103 4) echo "Where should the ROX-Filer application go?"
104 get_dir "/usr/local/apps"
105 APPDIR="$DIR"
106 echo
107 echo "Where should the launcher script go?"
108 get_dir "/usr/local/bin"
109 BINDIR="$DIR"
110 echo
111 echo "Where should the shared resources (eg, MIME data) go?"
112 get_dir "/usr/local/share"
113 SHAREDIR="$DIR"
114 echo
115 echo "Where should the default run actions go?"
116 get_dir "$SHAREDIR/Choices"
117 CHOICESDIR="$DIR"
118 echo
119 echo "Where should the man pages go?"
120 get_dir "/usr/local/man"
121 MANDIR="$DIR"
123 *) die "Invalid choice!";;
124 esac
126 MIMEDIR=${SHAREDIR}/mime
128 MIMEINFO="${MIMEDIR}/packages/rox.xml"
130 cat << EOF
131 The application directory will be:
132 $APPDIR/ROX-Filer
134 The launcher script will be:
135 $BINDIR/rox
137 Run actions will be in:
138 $CHOICESDIR
140 MIME rules will be:
141 $MIMEINFO
144 if [ ! -f rox.1 ]; then
145 echo '*** The ROX-Filer manpage (rox.1) is missing.'
146 echo '*** It can be created from Manual.xml by running'
147 echo "*** 'make' in the ROX-Filer/src/Docs directory."
148 echo '*** The daily CVS snapshots have it ready-built'
149 echo
150 MANDIR=""
153 if [ -n "$MANDIR" ]; then
154 echo "The manual pages will be:"
155 echo " $MANDIR/man1/rox.1"
156 echo " $MANDIR/man1/ROX-Filer.1"
157 else
158 echo "The manual page will not be installed."
161 echo
162 echo "OK?"
163 confirm_or_die
164 echo
166 endir "$SHAREDIR"
168 if [ -n "$MANDIR" ]; then
169 echo "Installing manpage..."
170 endir "$MANDIR"
171 endir "$MANDIR/man1"
172 cp rox.1 "$MANDIR/man1/rox.1" || die "Can't install manpage!"
173 rm -f "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
174 ln -s "$MANDIR/man1/rox.1" "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
177 echo "Installing run actions (existing actions will not be replaced)..."
178 endir "$CHOICESDIR/MIME-types"
179 cd Choices || die "Choices missing"
180 for file in MIME-types/*; do
181 if [ -f "$file" ]; then
182 dest="$CHOICESDIR/$file"
183 if [ ! -f "$dest" ]; then
184 if [ ! -d "$dest" ]; then
185 echo Install $file as $dest
186 cp "$file" "$dest"
190 done
191 cd ..
193 endir "$MIMEDIR"
194 endir "$MIMEDIR/packages"
195 cp rox.xml "$MIMEINFO" || die "Failed to create $MIMEINFO"
196 update-mime-database "$MIMEDIR" || die "update-mime-database failed
197 Make sure you have installed the shared MIME database from:
198 http://www.freedesktop.org/software/shared-mime-info"
200 echo "Installing application..."
201 endir "$APPDIR"
203 (cd ROX-Filer/src && make clean) > /dev/null 2>&1
204 if [ -d "$APPDIR/ROX-Filer" ]; then
205 echo "ROX-Filer is already installed - delete the existing"
206 echo "copy?"
207 confirm_or_die
208 echo Deleting...
209 rm -rf "$APPDIR/ROX-Filer"
211 cp -r ROX-Filer "$APPDIR"
213 echo "Installing launcher script..."
214 endir "$BINDIR"
216 cat > "$BINDIR/rox" << EOF
217 #!/bin/sh
218 exec $APPDIR/ROX-Filer/AppRun "\$@"
220 [ $? -eq 0 ] || die "Failed to install 'rox' script"
221 chmod a+x "$BINDIR/rox"
223 cat << EOF
225 Script installed. You can run the filer by simply typing 'rox'
226 Make sure that $BINDIR is in your PATH though - if it isn't then
227 you must use
228 \$ $BINDIR/rox
229 to run it instead.
231 ****************************
232 *** Now read the manual! ***
233 ****************************
235 Run ROX and click on the help icon on the toolbar:
237 \$ rox