Best Cygwin PostgreSQL Setup Script?

From: "Daniel Secomb" <dan(at)ds-d(dot)com>
To: <zuhans(at)iname(dot)com>, <pgsql-cygwin(at)postgresql(dot)org>
Subject: Best Cygwin PostgreSQL Setup Script?
Date: 2004-07-30 06:10:58
Message-ID: MCBBIFBENOMGNJNDAAJBGEGLCHAA.dan@ds-d.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-cygwin

Hi Hans.

Would it be fair to say that the following would be the best PostgreSQL
setup script?

export CYGWIN=server
unset LANG
echo
PATH=/usr/bin:/usr/sbin:$PATH
export PATH
echo "cygserver starting..."
echo
echo "cygserver-config starting..."
cygserver-config
echo "cygserver starting..."
cygserver &
ps -f
echo
echo "initdb starting..."
initdb -D /var/postgresql/data
ps -f
./db-stop

now "db-start":

!/bin/sh
export CYGWIN=server
PATH=/usr/bin:/usr/sbin:$PATH
export PATH
echo
echo "cygserver starting..."
cygserver &
ps -f
echo
echo "PostgreSQL starting..."
postmaster -i -D /var/postgresql/data &
ps -f

and finally "db-stop":

!/bin/sh
echo
echo "PostgreSQL finishing..."
pg_ctl stop -w -D /var/postgresql/data -s -m smart
ps -f
echo
echo "cygserver finishing..."
kill $(ps -f | grep cygserver | awk '{print $2}')
ps -f

Mike G mentioned the following:

I would assume the writer created a script that executes the standard
commands to start the postmaster and put it another script named db-start.

The db-start file would be something like:

#!/bin/sh
/usr/local/pgsql/bin/postmaster -D /var/postgresql/data >logfile 2>&1 &

Do you think he's right? How would I go about implementing it into the
script?

I really appreciate your help.

Dan
-----Original Message-----
From: pgsql-cygwin-owner(at)postgresql(dot)org
[mailto:pgsql-cygwin-owner(at)postgresql(dot)org]On Behalf Of zuhans(at)iname(dot)com
Sent: Thursday, July 29, 2004 5:30 AM
To: Daniel Secomb; pgsql-cygwin(at)postgresql(dot)org
Subject: Re: [CYGWIN] "initdb: failed" (invalid argument)?????????????

hi daniel,

i didn't mention this especially but now i see that this could be very
important:
those 3 "scripts" are 3 different files! that means:
1. create a file "pgini" (or whatever you like it to be named), open it
with any editor and type in the commands starting from "#!/bin/sh" until
"./db-stop".
2. create a file "db-start" (or whatever...), open it...editor... from
"#!/bin/sh" until "ps -f".
3. create..."db-stop" (or...), ...editor...from "#!/bin/sh" until "ps -f".

those files are batch-files, i.e. you call the file-name and then the
commands in it will be done line by line.
to call the files (i assume, that they are all in the same dir) you have
to type in at the command prompt:
1. "./pgini" (remember that this is only important the very first time!
2. "./db-start".
then work with postgresql whatever you want.
3. "./db-stop" - at the end of your hard working-day.
important: only type in what is between ""!
important: my solution is working (and for me - for testing and
programming purposes - its very ok so) - but there are more secure and
sophisticated around - have a look at those if you plan to setup a
production-environment!

greetings
hans

Daniel Secomb schrieb:
Hey Mike (or anybody else that can help me)!

The script below has worked for me up to a point. The part in the script
where it went off the rails is mentioned below:

Basic Cygserver configuration finished. Have fun!

$echo "cygserver starting..."
cygserver starting...
$ cygserver &
[1] 966609
$ cygserver: Initialization complete. Wating for requests.
ps -f
UID PID PPID TTY STIME COMMAND
Daniel S 942069 1 con 12:52:04 /usr/bin/BASH
Daniel S 966609 942069 con 13:01:01 /USR/SBIN/CYGSERVER
Daniel S 937673 942069 con 13:01:35 /usr/bin/PS
$ ./db-stop
BASH: ./db-stop: No such file or directory
$ #./db-stop
$ now "db-start":
BASH: now: command not found
$

What do you think???? Any idea why it didn't work??

Another thing too. There were a few lines in the script (see further below
to see the email that has the original script) that Cygwin didn't recognise.
For example:

When I typed in:
my "pgini":

Cygwin said:
BASH: my: command not found

And when I typed in:
#!/bin/sh

Cygwin said:
BASH: !/bin/sh: event not found

This may sound like a stupid question, but was I supposed to type in:
# the first very important set-variable

I am not very clear on what is supposed to be typed in and what is just
lines of helpful info.

I also thought I spotted some typos in your script, so I changed them to how
I thought it should be. For example:

You wrote:
#echo "IPC-Daemon starten..."

I changed it to:
#echo "cygserver starting..."

{I changed the "IPC-Daemon" to "cyserver" because my version of Cygwin
(1.5.10-3) no longer uses "IPC-Daemon" and uses "cygserver" instead.}

You wrote:
echo "sygserver starten..."

I changed it to:
echo "cygserver starting..."

Was I OK in doing this or was it suppose to be EXACTLY as you have written
it?

I extremely appreciate your help and support!!!

Kind Regards,

Daniel Secomb
Creative Director
DS Design
ABN 33 721 455 978
PO Box 4540,
Lake Haven NSW 2263
Australia
[p] +61 2 4393 6305
[f] +61 2 4393 6306
[m] +61414 571 500
mailto:dan(at)ds-d(dot)com
http://www.ds-d.com/

Take a look at our latest web development project:
http://www.specialfx.com.au/

>From the US, UK or Europe? Why not take advantage of the weaker Australian
dollar? Click the following link http://www.xe.com/ucc/ for a currency
conversion and find out how much you'll save!!

_________________________________________________________________

The material contained in this email may be confidential, and may also be
the subject of copyright and/or privileged information. If you are not the
intended recipient, any use, disclosure or copying of this document is
prohibited. If you have received this document in error, please advise the
sender and delete the document.

This email communication does not create or vary any contractual
relationship between DS Design and you. Internet communications are not
secure and accordingly DS Design does not accept any legal liability for the
contents of this message.

Please note that neither DS Design nor the sender accepts any responsibility
for viruses and it is your responsibility to scan the email and any
attachments.

-----Original Message-----
From: mike g [mailto:mike(at)thegodshalls(dot)com]
Sent: Monday, July 26, 2004 12:26 PM
To: Daniel Secomb
Subject: RE: [CYGWIN] "initdb: failed" (invalid argument)?????????????

Ok,

I believe 98 works the same way as the XP Home edition.

for everybody who is interested in my functioning scripts (on
win-xp-home) i give it in here:

at first i do an initiation of my postgresql-db "pgini" and at the end i
call my script "db-stop" to clean memory of processes (especially
cygserver).

and after that i call my db with "db-start" every time i need it (i
don't use it as a service, i don't use it for production just for
programming), and at the end of my working with my db i call my
"db-stop" again to clean memory. afterwards i exit cygwin or restart my
db with "db-start".

now my scripts:

my "pgini":

#!/bin/sh
# the first very important set-variable
CYGWIN=server
export CYGWIN
# the second very important set-variable - to unset it worked for me
(then language-setting is C).
unset LANG
echo
# the third very important set-variable
PATH=/usr/bin:/usr/sbin:$PATH
export PATH
#echo "IPC-Daemon starten..."
echo
echo "cygserver-config starting..."
cygserver-config
echo "sygserver starten..."
cygserver &
ps -f
echo
echo "initdb starting..."
initdb -D /var/postgresql/data
ps -f
./db-stop

now "db-start":

#!/bin/sh
CYGWIN=server
export CYGWIN
PATH=/usr/bin:/usr/sbin:$PATH
export PATH
echo
echo "sygserver starting..."
cygserver &
ps -f
echo
echo "PostgreSQL starting..."
postmaster -i -D /var/postgresql/data &
ps -f

and finally "db-stop":

#!/bin/sh
echo
echo "PostgreSQL finishing..."
pg_ctl stop -w -D /var/postgresql/data -s -m smart
ps -f
echo
echo "cygserver finishing..."
kill $(ps -f | grep cygserver | awk '{print $2}')
ps -f

greetings and thanks to all
hans
On Sat, 2004-07-24 at 02:16, Daniel Secomb wrote:
I'm using Windows 98SE, PostgreSQL 7.4.3.1 and Cygwin 1.5.10-3

Thank you for your intended help Mike.

God bless you!!

Dan

-----Original Message-----
From: mike g [mailto:mike(at)thegodshalls(dot)com]
Sent: Saturday, July 24, 2004 1:45 PM
To: Daniel Secomb
Cc: pgsql-cygwin(at)postgresql(dot)org
Subject: Re: [CYGWIN] "initdb: failed" (invalid argument)?????????????

What version of Postgresql are you using?

What version of Windows?

Mike
On Fri, 2004-07-23 at 20:18, Daniel Secomb wrote:
Hi,

For some weird reason, the initialization attempt has spat the dummy and
this is what it did:

$ export CYGWIN=server
$ /usr/sbin/cygserver &
[1] 686417
$ cygserver: Initialization complete. Waiting for requests.
initdb -D /usr/local/pgsql/data -W -E LATIN1
The files belonging to this database system will be owned by user
"Daniel
Secomb
".
This user must also own the server process.

The database cluster will be initialized with locale C.

creating directory /usr/local/pgsql/data... ok
creating directory /usr/local/pgsql/data/base... ok
creating directory /usr/local/pgsql/data/global... ok
creating directory /usr/local/pgsql/data/pg_xlog... ok
creating directory /usr/local/pgsql/data/pg_clog... ok
selecting default max_connections... 10
selecting default shared_buffers... 50
creating configuration files... ok
creating template1 database in /usr/local/pgsql/data/base/1... FATAL:
shmat<id=
1179648> failed: Invalid argument

initdb: failed
$

Any reason why it has done this?

Any help will be GREATLY appreciated!!

Many, many thanks!!

Kind Regards,

Daniel Secomb
Creative Director
DS Design
ABN 33 721 455 978
PO Box 4540,
Lake Haven NSW 2263
Australia
[p] +61 2 4393 6305
[f] +61 2 4393 6306
[m] +61414 571 500
mailto:dan(at)ds-d(dot)com
http://www.ds-d.com/

Take a look at our latest web development project:
http://www.specialfx.com.au/

>From the US, UK or Europe? Why not take advantage of the weaker
Australian
dollar? Click the following link http://www.xe.com/ucc/ for a currency
conversion and find out how much you'll save!!

_________________________________________________________________

The material contained in this email may be confidential, and may also
be
the subject of copyright and/or privileged information. If you are not
the
intended recipient, any use, disclosure or copying of this document is
prohibited. If you have received this document in error, please advise
the
sender and delete the document.

This email communication does not create or vary any contractual
relationship between DS Design and you. Internet communications are not
secure and accordingly DS Design does not accept any legal liability for
the
contents of this message.

Please note that neither DS Design nor the sender accepts any
responsibility
for viruses and it is your responsibility to scan the email and any
attachments.

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

In response to

Browse pgsql-cygwin by date

  From Date Subject
Next Message Jason Tishler 2004-07-30 11:49:02 Re: Postgres for Cygwin port in windows frustrated
Previous Message Jason Tishler 2004-07-29 20:11:42 Re: initdb failed: invalid value for parameter "lc_messages": "1033"