I built this deployment script which runs when my debian 6.0 server is deployed. I have shown it here before (this is a linode stackscript incase anyone else is wondering):
#!/bin/bash
#
# Install PostgreSQL
#
# Copyright (c) 2010 Filip Wasilewski <[email protected]>.
#
# My ref: http://www.linode.com/?r=aadfce9845055011e00f0c6c9a5c01158c452deb
function postgresql_install {
aptitude -y install postgresql postgresql-contrib postgresql-dev libpq-dev
}
function postgresql_create_user {
# postgresql_create_user(username, password)
if [ -z "$1" ]; then
echo "postgresql_create_user() requires username as the first argument"
return 1;
fi
if [ -z "$2" ]; then
echo "postgresql_create_user() requires a password as the second argument"
return 1;
fi
echo "CREATE ROLE $1 WITH LOGIN ENCRYPTED PASSWORD '$2';" | sudo -i -u postgres psql
}
function postgresql_create_database {
# postgresql_create_database(dbname, owner)
if [ -z "$1" ]; then
echo "postgresql_create_database() requires database name as the first argument"
return 1;
fi
if [ -z "$2" ]; then
echo "postgresql_create_database() requires an owner username as the second argument"
return 1;
fi
sudo -i -u postgres createdb --owner=$2 $1
}
postgresql_install
postgresql_create_user(username, password)
postgresql_create_database(dbname, username)
I deployed my server with this script, which was built on top of Filip's version, but then when I try to see if postgresql is running by typing pg_ctl it says command not found.
Where I have I gone wrong on this? Since it deploys when the server runs I am not able to see where it is going wrong.
psql
andcreatedb
in yourPATH
? You really should be using full paths in this sort of script. – mu is too short Dec 5 '12 at 22:52which psql
on a machine that has it all properly installed and accessible. – mu is too short Dec 5 '12 at 23:21PATH
. Trylocate psql
or check the package to see where it is installing things. – mu is too short Dec 6 '12 at 17:41