source: livedvd/gisvm/trunk/bin/install_opencpn.sh

Last change on this file was 10564, checked in by hamish, 3 years ago

mkdir for docs

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:mime-type set to text/x-sh
File size: 8.2 KB
Line 
1#!/bin/sh
2# Copyright (c) 2009-2010 The Open Source Geospatial Foundation.
3# Licensed under the GNU LGPL.
4#
5# This script is free software; you can redistribute it and/or modify it
6# under the terms of the GNU Lesser General Public License as published
7# by the Free Software Foundation, either version 2.1 of the License,
8# or any later version.  This library is distributed in the hope that
9# it will be useful, but WITHOUT ANY WARRANTY, without even the implied
10# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU Lesser General Public License for more details, either
12# in the "LICENSE.LGPL.txt" file distributed with this software or at
13# web page "http://www.fsf.org/licenses/lgpl.html".
14
15# About:
16# =====
17# This script will install the OpenCPN GPS navigation software
18#    written by H.Bowman <hamish_b  yahoo com>
19#    OpenCPN homepage: http://www.opencpn.org/
20#    OpenCPN license: GPLv2
21#
22# Description: OpenCPN is an OpenSource Chart PLotter/Navigator
23#     OpenCPN supports:
24#       BSB raster and S57 ENC vector charts
25#       AIS Target tracking
26#       NMEA GPS input
27#       GPDS Daemon input
28#       Autopilot output
29#       Unlimited Route/Mark creation
30#
31
32./diskspace_probe.sh "`basename $0`" begin
33BUILD_DIR=`pwd`
34####
35
36# live disc's username is "user"
37if [ -z "$USER_NAME" ] ; then
38   USER_NAME="user"
39fi
40USER_HOME="/home/$USER_NAME"
41
42
43TMP_DIR=/tmp/build_opencpn
44
45if [ ! -d "$TMP_DIR" ] ; then
46   mkdir "$TMP_DIR"
47fi
48cd "$TMP_DIR"
49
50OLD=no
51####
52if [ "$OLD" = "yes" ] ; then
53URL="http://download.osgeo.org/livedvd/data/opencpn/precise/i386"
54PKGS="
55opencpn-data_2.5.0+dfsg-0_all.deb
56opencpn-doc_2.5.0+dfsg-0_all.deb
57opencpn_2.5.0+dfsg-0_i386.deb
58opencpn-plugins_2.5.0+dfsg-0_i386.deb
59"
60for PKG in $PKGS ; do
61   wget -c --progress=dot:mega "$URL/$PKG"
62done
63
64####
65else
66####
67
68BASEURL="http://downloads.sourceforge.net/project/opencpn/opencpn"
69OCPNVER="3.2.2"
70URL="$BASEURL/$OCPNVER/opencpn_${OCPNVER}-1_i386.deb"
71
72wget -c --progress=dot:mega "$URL"
73
74PKGS="opencpn_${OCPNVER}-1_i386.deb"
75fi
76####
77
78
79# recommended:
80apt-get --assume-yes install gpsd gpsd-clients python-gps gdebi
81
82# dpkg -I <packagename.deb>
83# Depends: libatk1.0-0 (>= 1.29.3), libbz2-1.0, libc6 (>= 2.7), libcairo2 (>= 1.2.4),
84#  libgcc1 (>= 1:4.1.1), libgl1-mesa-glx | libgl1, libglib2.0-0 (>= 2.12.0),
85#  libglu1-mesa | libglu1, libgtk2.0-0 (>= 2.8.0), libice6 (>= 1:1.0.0),
86#  libpango1.0-0 (>= 1.14.0), libsm6, libstdc++6 (>= 4.1.1), libtinyxml2.6.2 (>= 2.5.3-3),
87#  libwxbase2.8-0 (>= 2.8.10.1), libwxgtk2.8-0 (>= 2.8.10.1), libx11-6, libxext6,
88#  zlib1g (>= 1:1.1.4), libgps19
89
90DEPS="libgl1-mesa-glx libglu1-mesa \
91      libglib2.0-0 libgtk2.0-0 libstdc++6 \
92      libwxbase2.8-0 libwxgtk2.8-0 zlib1g \
93      libtinyxml2.6.2 xtide-coastline"
94
95apt-get --assume-yes install $DEPS
96
97for PKG in $PKGS ; do
98   gdebi --non-interactive --quiet "$PKG"
99
100   if [ $? -ne 0 ] ; then
101      echo 'ERROR: Package install failed! Aborting.'
102      exit 1
103   fi
104done
105
106wget -nv -O tips.html \
107  "http://opencpn.cvs.sourceforge.net/viewvc/*checkout*/opencpn/opencpn/data/doc/tips.html"
108mkdir -p /usr/share/doc/opencpn-doc/doc/
109cp tips.html /usr/share/doc/opencpn-doc/doc/
110
111
112#### download sample data
113# RNC raster (BSB format)
114# ENC vector (S-57 format)
115#
116# (Sorry Australians, complain to your hydrographic office that encrypting
117#  safety-critical data for the purposes of "DRM" is fundamentally stupid.
118#  They should rely on well-established cryptographically signed methods
119#  to ensure that the data has not been corrupted or tampered with instead.
120#  So we use NOAA data from the USA for our examples instead of Sydney Harbour.)
121
122DATADIR="/usr/local/share/opencpn"
123mkdir -p "$DATADIR/c.dist/BSB_ROOT"
124mkdir -p "$DATADIR/c.dist/ENC_ROOT"
125
126mkdir "$DATADIR/gpx"   # GPX tracks, etc
127mkdir "$DATADIR/grib"  # GRIB weather data downloads:
128
129adduser "$USER_NAME" users
130chown -R root.users "$DATADIR"
131chmod -R g+rw "$DATADIR"
132
133# send users to these websites as part of the min-tutorial:
134# http://www.nauticalcharts.noaa.gov/mcd/Raster/download_agreement.htm
135# http://www.nauticalcharts.noaa.gov/mcd/enc/download_agreement.htm
136# find the chart numbers you want then,
137#   http://www.charts.noaa.gov/RNCs/
138
139## "Copying of the NOAA RNCs® to any other server or location for further
140##  distribution is discouraged unless the following guidelines are followed:
141##  1) this User Agreement is displayed and accepted by anyone accessing the
142##  NOAA RNCs®, and 2) a reference to this Web site is included so that anyone
143##  accessing the NOAA RNCs® is advised of their origin."
144
145
146### Raster BSB charts ###
147# New York Harbor:
148#RNC_CHARTS="
149# 12300
150# 12326
151# 12327
152# 12334
153# 12335
154# 12358
155# 12401
156# 12402
157# 13006"
158# save space; fewer:
159RNC_CHARTS="
160 12300
161 12326
162 12327
163 12402
164 13006"
165
166
167### Raster BSB charts ###
168cd "$TMP_DIR"
169
170for CHART in $RNC_CHARTS ; do
171  wget -N --progress=dot:mega "http://www.charts.noaa.gov/RNCs/$CHART.zip"
172  if [ $? -ne 0 ] ; then
173     # try try again
174     wget -N --progress=dot:mega "http://www.charts.noaa.gov/RNCs/$CHART.zip"
175  fi
176  wget -N -nv "http://www.charts.noaa.gov/RNCs/${CHART}_RNCProdCat.xml"
177done
178
179cd "$DATADIR/c.dist"
180
181for CHART in $RNC_CHARTS ; do
182   unzip -u -o "$TMP_DIR/$CHART.zip"
183   cp "$TMP_DIR/${CHART}_RNCProdCat.xml" BSB_ROOT/
184done
185
186
187### Vector S-57 charts ###
188# New York Harbor and Long Island Sound:
189#ENC_CHARTS="
190# US2EC03M
191# US3NY01M
192# US4NY13M
193# US4NY1AM
194# US4NY1GM
195# US5CN10M
196# US5CN11M
197# US5CN12M
198# US5NY12M
199# US5NY14M
200# US5NY15M
201# US5NY16M
202# US5NY18M
203# US5NY19M
204# US5NY1BM
205# US5NY1CM
206# US5NY1DM
207# US5NY50M"
208# save space; fewer:
209ENC_CHARTS="
210 US2EC03M
211 US3NY01M
212 US4NY1AM
213 US5NY19M
214 US5NY1CM"
215
216
217cd "$TMP_DIR"
218
219for CHART in $ENC_CHARTS ; do
220  wget -N --progress=dot:mega "http://www.charts.noaa.gov/ENCs/$CHART.zip"
221  if [ $? -ne 0 ] ; then
222     # try try again
223    wget -N --progress=dot:mega "http://www.charts.noaa.gov/ENCs/$CHART.zip"
224  fi
225  wget -N -nv "http://www.charts.noaa.gov/ENCs/${CHART}_ENCProdCat.xml"
226done
227
228cd "$DATADIR/c.dist"
229
230for CHART in $ENC_CHARTS ; do
231   unzip -u -o "$TMP_DIR/$CHART.zip"
232   cp "$TMP_DIR/${CHART}_ENCProdCat.xml" ENC_ROOT/
233done
234
235
236echo "Chart download complete."
237
238
239###  data acceptance in user-init'd run-time script "opencpn_noaa_agreement.sh"
240# for data install license agreement question in the user-run data fetch script:
241cd "$BUILD_DIR"
242cp ../app-conf/opencpn/noaa_agreement.txt "$DATADIR/"
243cp ../app-conf/opencpn/opencpn_noaa_agreement.sh /usr/local/bin/
244cp ../app-conf/opencpn/launch_opencpn.sh /usr/local/bin/
245apt-get --assume-yes install gxmessage
246
247
248#### pre-set config file with data paths and initial position
249
250mkdir /etc/skel/.opencpn
251
252cat << EOF > "/etc/skel/.opencpn/opencpn.conf"
253[Directories]
254InitChartDir=$DATADIR/charts
255GPXIODir=$DATADIR/gpx
256GRIBDirectory=$DATADIR/grib
257[ChartDirectories]
258ChartDir1=$DATADIR/charts/BSB_ROOT
259ChartDir2=$DATADIR/charts/ENC_ROOT
260[Settings/GlobalState]
261VPLatLon="   40.39,  -73.47"
262VPScale=0.0048
263OwnShipLatLon="   40.337,   -73.472"
264nBoundaryStyle=79
265FrameWinX=800
266[Settings/NMEADataSource]
267DataConnections=1;2;localhost;2947;0;;4800;1;0;0;;0;;0;0;0;0;1
268EOF
269
270mkdir "$USER_HOME/.opencpn"
271cp "/etc/skel/.opencpn/opencpn.conf" "$USER_HOME/.opencpn/"
272chown -R "$USER_NAME.$USER_NAME" "$USER_HOME/.opencpn/"
273
274
275#### install icon on desktop/menus
276cd "$TMP_DIR"
277wget -nv "http://opencpn.cvs.sourceforge.net/viewvc/*checkout*/opencpn/opencpn/data/opencpn.png" \
278  -O opencpn.png
279cp opencpn.png /usr/share/icons/
280
281cat << EOF > /usr/share/applications/opencpn.desktop
282[Desktop Entry]
283Type=Application
284Encoding=UTF-8
285Name=OpenCPN
286Comment=GPS Navigation. You need to setup Gpsd manually
287Categories=Application;Education;Geography;
288Exec=/usr/local/bin/launch_opencpn.sh
289Icon=/usr/share/icons/opencpn.png
290Terminal=false
291EOF
292
293cp /usr/share/applications/opencpn.desktop "$USER_HOME/Desktop/"
294chown -R $USER_NAME.$USER_NAME "$USER_HOME/Desktop/opencpn.desktop"
295
296# add menu item
297if [ ! -e /usr/share/menu/opencpn ] ; then
298   cat << EOF > /usr/share/menu/opencpn
299?package(opencpn):needs="x11"\
300  section="Applications/Science/Geoscience"\
301  longtitle="OpenCPN Ocean Navigator"\
302  title="OpenCPN" command="opencpn"\
303  icon="/usr/share/icons/opencpn.png"
304EOF
305
306   update-menus
307fi
308
309
310#### install help manual
311# PDF version of:
312# http://opencpn.org/docwiki
313#  ?
314# just point to /usr/local/share/opencpn/doc/help.html
315
316
317####
318"$BUILD_DIR"/diskspace_probe.sh "`basename $0`" end
Note: See TracBrowser for help on using the repository browser.