Hi,
For administration purposes, I set up a SSH tunnel to tunnel postgres connections to their designated VM.
On login to the proxmox machine using putty, putty establishes a tunnel on a specific port from the remote machine as descriped here: http://www.postgresonline.com/journal/archives/38-PuTTY-for-SSH-Tunneling-to-PostgreSQL-Server.html. Autossh runs on the proxmox machine to "extend" that tunnel to a specific client. I.e. it is called from a script like this:
Note that different tunnel ports are used to address individual postgres VMs.
I tried to create a service for it like this:
This works just fine, but the tunnel "extensions" are not established when the proxmox server boots up, i.e. the skript needs to be called manually or the service needs to be started manually, e.g. like this: service establishSSHTunnels start.
This is probably because of the delayed start of the VM which starts after proxmox.
I tried to remedy this using the "sleep 60" line but with no luck. Maybe there are also other reasons that prevent this approach from working.
Question is: Is there a way to schedule some work on the proxmox server after a specific VM has booted up?
Thanks
For administration purposes, I set up a SSH tunnel to tunnel postgres connections to their designated VM.
On login to the proxmox machine using putty, putty establishes a tunnel on a specific port from the remote machine as descriped here: http://www.postgresonline.com/journal/archives/38-PuTTY-for-SSH-Tunneling-to-PostgreSQL-Server.html. Autossh runs on the proxmox machine to "extend" that tunnel to a specific client. I.e. it is called from a script like this:
Code:
#! /bin/sh
#establish tunnel to postgres VM
autossh -M 0 -q -f -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -L 5433:postgres.myserver.com:5432 -f postgres@postgres.myserver.com
I tried to create a service for it like this:
Code:
#! /bin/sh
### BEGIN INIT INFO
# Provides: establishSSHTunnels
# Required-Start: $ssh
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Establishes an SSH tunnel to the postgres VM
### END INIT INFO
NAME=establishSSHTunnels
DAEMON=/sbin/establishSSHTunnels
[ -x "$DAEMON" ] || exit 0
case "$1" in
start)
sleep 60 #let the DB VZ come up
exec /sbin/establishSSHTunnels
;;
stop|restart|force-reload|status)
#no op
;;
*)
echo "Usage: $NAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
:
This works just fine, but the tunnel "extensions" are not established when the proxmox server boots up, i.e. the skript needs to be called manually or the service needs to be started manually, e.g. like this: service establishSSHTunnels start.
This is probably because of the delayed start of the VM which starts after proxmox.
I tried to remedy this using the "sleep 60" line but with no luck. Maybe there are also other reasons that prevent this approach from working.
Question is: Is there a way to schedule some work on the proxmox server after a specific VM has booted up?
Thanks