How to Auto Generate pg_hba.conf file at Startup


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to Auto Generate pg_hba.conf file at Startup
# 1  
Old 09-30-2010
Question How to Auto Generate pg_hba.conf file at Startup

Hi there,

I'll start by letting you you know my current shell programming and scripting is very week (and thats a euphemistic description). I'm really just wanting someone to make a suggestion to get me rolling in the right direction though absolutely any help is of course welcome.

Set Up
- Running multiple servers using Amazons EC2 service
- One primary postgres DB
- Multiple application servers all needing access to the DB
- This set up is monitored for loading and should the load exceed the set parameters another application server instance is spun up

The problem
- Although the domain names remain static the IPs do not and so when the server farm is started or suspended (as is often the case for the dev farm) and started again the IP addresses change. I can't do anything about this. This is just what I have to work with.
- Of course with constantly shifting IP addresses it means that I constantly need to log in and adjust the pg_hba.conf file.

The Solution
- Write a script that fires once the data drive has mounted that queries the domain names of the other existing servers in the farm returning their IP addresses and writing them to the pg_hba.conf file and subsequently reloading the settings or starting the server.

these are the steps as I see it...
1) copy a template pg_hba.conf file over the top of the existing one.
2) in a loop query a set of domain names and append each resulting IP address to the bottom of the new pg_hba.conf file (Line to be appended:"host all all xxx.xxx.xxx.xxx/32 trust"
3) Start/Reload the postgres service


I'm not sure what I am going to do when new servers spin up... Any suggestion about that would be welcome.

The Questions!!
- Should I be doing this with a shell script?
- Would I be better to say write a java server that does all this and remains constantly listening on a given port (would solve the issue of additional servers spinning up)?
- Where should I start?
- How should I go about it?

Once I have this nailed of course I'll be happy to share Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Auto startup and shutdown in AIX

Hi All, I would like to schedule auto IPL (shutdown and start-up) by using a shell script. Can you please give me some idea? want to test on my lab box first. shell script should bring AIX LPAR down and then need to start/activate the LPAR after 30 min any idea is highly... (3 Replies)
Discussion started by: System Admin 77
3 Replies

2. Shell Programming and Scripting

Auto generate Line Numbers

How do I generate line numbers in Vi? I have this: ,'04-90020-039N','61423','2GDV00039-0002', SYSDATE); ,'04-90020-040D','61423','2GDV00046-0001', SYSDATE); ,'04-90020-041N','61423','2GDV00038-0002', SYSDATE); ,'04-90020-043D','61423','2GDV00047-0001', SYSDATE);... (3 Replies)
Discussion started by: djehresmann
3 Replies

3. UNIX for Dummies Questions & Answers

auto generate ID

Using 'awk' i want to generate new ID..which should be increment of maximum number given as UID.. eg..in /etc/passwd..3rd field is UID..and we just want next user ID for this file..keep in mind that file is not sorted..so last line in the file may not display last UID..means UIDs in file are... (1 Reply)
Discussion started by: aadi_uni
1 Replies

4. Shell Programming and Scripting

shell script to auto process ten random files and generate logs

Hello member's I'm learning to script in the ksh environment on a Solaris Box. I have 10 files in a directory that I need to pass, as input to a batch job one by one. lets say, the files are named as follows: abcd.txt ; efgh.bat ; wxyz.temp etc. (random filenames with varied extensions ).... (1 Reply)
Discussion started by: novice82
1 Replies

5. Linux

file location for GNOME auto startup apps

I know how to add an apps to auto-start in GUI, but I'd like to know how to do it mannualy. So where is the file saved to by GUI ? (1 Reply)
Discussion started by: honglus
1 Replies

6. HP-UX

Auto-Port Aggregation startup fails on boot

I have a machine running HP-UX 11.23 (PARISC) and APA startup fails on boot. This is found in /etc/rc.log: Configure Auto-Port Aggregation(LAN Monitor) interfaces Output from "/sbin/rc2.d/S343hplm start": ---------------------------- get_start_dlpi_version: failed, errno is 22 ERROR: ... (1 Reply)
Discussion started by: kknigga
1 Replies

7. UNIX for Dummies Questions & Answers

how do i auto start application upon startup?

sorry, i'm a newbie to unix... but how do i or rather where do i write scripts that auto start my application e.g. Informix? in Windows it would be services but in UNIX where can i auto start my informix program? To run informix i just type "oninit". And do i have to login to any user before... (2 Replies)
Discussion started by: doofie
2 Replies

8. UNIX for Dummies Questions & Answers

auto-startup a process

hi, i just realise that everytimes i boot up my sun solaris 8 sparc, i need to explicitly run the following comand to start up my snmp agent. cd /etc/rc2.d ./K07dmi start ./K07snmpdx start i just wonder that how to make it auto-startup once the machine is boot up. please enlighten me.... (1 Reply)
Discussion started by: champion
1 Replies

9. HP-UX

hpux startup process, AUTO file?

hi, one of the process of hpux startup is this ISL where it consults the AUTO file. is this AUTO file resident in disk? thanks (5 Replies)
Discussion started by: yls177
5 Replies

10. UNIX for Dummies Questions & Answers

auto startup of a program

how do i make a program run at system startup? is there a hirarchy i have to consider? is there any equivalent to an NT "Service" in unix? how do you set it up? thanx Ron (2 Replies)
Discussion started by: exoron
2 Replies
Login or Register to Ask a Question