1#!/usr/local/bin/bash
2
3VERSION=0.60
4
5# Update the geomorphrc file from v. 0.2x to v. 0.3x
6
7if [ ! -f $HOME/.geomorph/geomorphrc ] ; then
8	echo "File $HOME/.geomorph/geomorphrc not found - exiting!"
9	exit
10fi
11
12# 1. We test if it's a v.0.2x by trying to find a keyword used only in v. 0.3x
13
14COUNT=`grep -i camera_1  $HOME/.geomorph/geomorphrc | wc -l`
15
16# echo "Lines with 'camera_1':"$COUNT
17
18if [ $COUNT -eq 0 ] ; then
19	echo "Updating $HOME/.geomorph/geomorphrc to 0.3x!"
20else
21	echo "$HOME/.geomorph/geomorphrc seems to be already updated to 0.3x, exiting!"
22	exit
23fi
24
25# 2. We backup the file
26
27DT=`date +%Y%m%d%H%M%S`
28cp $HOME/.geomorph/geomorphrc $HOME/geomorph/geomorphrc_$DT
29echo "Backup of $HOME/.geomorph/geomorphrc made on $HOME/geomorph/geomorphrc_$DT"
30
31# 3. We replace the default browser if it does not exist (in case the user left it to galeon...)
32
33browser=`cat $HOME/.geomorph/geomorphrc | grep doc_reader | sed s/\ //g | sed s/doc_reader// | sed s/=// | sed s/\;.*$//`
34
35if ! type $browser 1> /dev/null ; then
36	echo "Browser $browser not found, we reinitialize the doc_reader variable with a best-guess default!"
37	# Version without the GNU -i extension of sed - 2005-11-19
38	if type epiphany 1> /dev/null; then
39		sed /doc_reader/s/$browser/epiphany/ $HOME/.geomorph/geomorphrc > tmp_$DT
40	elif type firefox 1> /dev/null; then
41		sed /doc_reader/s/$browser/firefox/ $HOME/.geomorph/geomorphrc > tmp_$DT
42	elif type mozilla 1> /dev/null; then
43		sed /doc_reader/s/$browser/mozilla/ $HOME/.geomorph/geomorphrc > tmp_$DT
44	elif type konqueror 1> /dev/null; then
45		sed /doc_reader/s/$browser/konqueror/ $HOME/.geomorph/geomorphrc > tmp_$DT
46	# else
47		# Do nothing!
48	fi
49	if type tmp_$DT 1> /dev/null; then
50		cp -f tmp_$DT $HOME/.geomorph/geomorphrc
51		rm -f tmp_$DT
52	fi
53
54fi
55
56# 4. We add the output_prefix variable in the rendering section
57
58# sed -i s/other_render_options/output_prefix\ =\ \_\ \;\\nother_render_options/ $HOME/.geomorph/geomorphrc
59
60# Version without the GNU -i extension, which does not work on some older systems:
61
62sed s/other_render_options/output_prefix\ =\ \_\ \;\\nother_render_options/ $HOME/.geomorph/geomorphrc > tmp_$DT
63cp -f tmp_$DT $HOME/.geomorph/geomorphrc
64rm -f tmp_$DT
65
66# 5. We add the 3d_preview and the camera_1 to camera_5 sections
67
68if type /usr/local/share/geomorph/$VERSION/v0_30_new_sections >& /dev/null ; then
69	/usr/local/share/geomorph/$VERSION/v0_30_new_sections >> $HOME/.geomorph/geomorphrc
70elif type ./v0_30_new_sections > /dev/null ; then
71	./v0_30_new_sections >> $HOME/.geomorph/geomorphrc
72fi
73