Script for OSM-installation on Ubuntu 14.04

A shell script is a computer program designed to be run by the Unix shell, a command line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manipulation, program execution, and printing text.

Few days before I got a work to create a shell script to install OSM on Ubuntu 14.04. I created the interactive shell script which you can see at

http://gdy.club/osm1404

But it was suggested by Dr. Rai to create a non-interactive shell script. It should not ask anything from the user but must do everything on its own. So, there was a need to learn about variables, statements and many more. I followed the following links to learn about shell scripting:

  1. Linux Shell Scripting Tutorial (LSST) v1.05r3
  2. Advanced Bash-Scripting Guide

Now, the basic idea to create the script is like this-

#!/bin/bash

sudo -u postgres -i
psql -U $USER -c “createuser \”$USER\” with password ‘root'”
psql -U $USER -c “createdb \”gis\” with owner \”$USER\” encoding=’utf8’ template template0″
EOF

# Set up PostGIS on the PostgreSQL database #
sudo -u postgres psql.

psql -U postgres -d gis -c "create extension postgis";
psql -U postgres -d gis -c "ALTER TABLE geometry_columns OWNER TO $USER";
psql -U postgres -d gis -c "ALTER TABLE spatial_ref_sys OWNER TO $USER";
EOF

There are so many other files where editing by a user is needed, like replacing the .zip files with .shp files in /osm-bright.osm2pgsql.mml. How can we do this, where we need to check every character carefully before making any change? Well! need to learn.

Advertisements

Published by

kaurdavinder

I am the one who discover myself daily through reading, writing, interacting with people and expressing my thoughts to inspire them if I would be able to bring a little change to the society through my work. I write blogs, participate in various social activities and want to be a Professional Speaker. Currently, I am pursuing my post graduation in Computer Applications from Guru Nanak Dev Engineering College, Ludhiana and I’m very much active in many technical & social communities.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s