LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   startup script for openvz (https://www.linuxquestions.org/questions/linux-newbie-8/startup-script-for-openvz-761137/)

laurens 10-11-2009 07:29 AM

startup script for openvz
 
Hi all,

First, I always look for similar topics, but weirdly enough I didn't find anything; maybe I used the wrong search terms. Anyway here's my question.

When a server running OpenVZ (host and 5 containers) is restarted, obviously the containers are restarted too. This causes to erase some important iptables configurations in one of the containers.

My solution is to run a script from the host machine every time the server (unintentionally) restarts.

the easy script should do something like this.
Code:

vzctl start 101
sleep 20 secs (?!)
vzctl exec 101 iptables add ....

My question is: where put this 'script.sh' to make sure it runs every time the server (host) is restarted?
PS: my guess is it is better to run the sript from the host instead of the container.

Thanks in advance!!

jmc1987 10-11-2009 08:09 AM

How did you install OpenVZ (assuming you installed it with hypervm since you can only have host.) If that is how you insatlled I would recommend you install openVZ then install hypervm with

Code:

sh ./hypervm-install-master.sh --virtualization-type=NONE
What system and arch did you install it on. You shouldn't lose nothing from the containers everytime you reboot. sounds like you have a misconfiguration somewhere.

laurens 10-11-2009 09:32 AM

Quote:

Originally Posted by jmc1987 (Post 3715362)
How did you install OpenVZ (assuming you installed it with hypervm since you can only have host.) If that is how you insatlled I would recommend you install openVM then install hypervm with

Code:

sh ./hypervm-install-master.sh --virtualization-type=NONE
What system and arch did you install it on. You shouldn't lose nothing from the containers everytime you reboot. sounds like you have a misconfiguration somewhere.

OpenVZ is installed fine... I use it already months without problems. It's only the fact that iptables get reset when rebooting the openVZ host. To answer your question: I installed it via 'apt-get install openvz' on the host. Pretty easy indeed
So what I need is a location on the host to place this script (above).
Thx

catkin 10-11-2009 09:39 AM

Quote:

Originally Posted by laurens (Post 3715439)
So what I need is a location on the host to place this script

Depends on which distro you are running. Maybe /etc/rc.d/rc.local, maybe /etc/rc.local. You want to run it as root?

laurens 10-12-2009 02:37 AM

Quote:

Originally Posted by catkin (Post 3715448)
Depends on which distro you are running. Maybe /etc/rc.d/rc.local, maybe /etc/rc.local. You want to run it as root?

Thanks for you reply, I'm running it on an Ubuntu 8.04 Server as root indeed

catkin 10-12-2009 03:21 AM

Then add the lines to /etc/rc.local

laurens 10-12-2009 03:42 AM

Quote:

Originally Posted by catkin (Post 3716167)
Then add the lines to /etc/rc.local

Thx! I did that. I'll try rebooting now


All times are GMT -5. The time now is 04:21 AM.