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
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:
Now, the basic idea to create the script is like this-
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″
# 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";
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.