LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-11-2009, 08:29 AM   #1
laurens
Member
 
Registered: Mar 2009
Posts: 65

Rep: Reputation: 15
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!!

Last edited by laurens; 10-11-2009 at 08:31 AM.
 
Old 10-11-2009, 09:09 AM   #2
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7
Posts: 872

Rep: Reputation: 112Reputation: 112
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.

Last edited by jmc1987; 10-11-2009 at 10:47 AM.
 
Old 10-11-2009, 10:32 AM   #3
laurens
Member
 
Registered: Mar 2009
Posts: 65

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jmc1987 View Post
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

Last edited by laurens; 10-11-2009 at 10:33 AM.
 
Old 10-11-2009, 10:39 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by laurens View Post
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?
 
Old 10-12-2009, 03:37 AM   #5
laurens
Member
 
Registered: Mar 2009
Posts: 65

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by catkin View Post
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
 
Old 10-12-2009, 04:21 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Then add the lines to /etc/rc.local
 
Old 10-12-2009, 04:42 AM   #7
laurens
Member
 
Registered: Mar 2009
Posts: 65

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by catkin View Post
Then add the lines to /etc/rc.local
Thx! I did that. I'll try rebooting now
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
X startup script? grayFalcon Linux - Newbie 2 08-18-2006 04:18 PM
'cannot stat' script in /etc/rc.d/, try to run script at startup quintan Linux - Software 1 11-21-2005 03:53 AM
How to call a script from a system startup script? jonatito Linux - Newbie 7 11-11-2005 10:40 PM
Startup script Larsza SUSE / openSUSE 7 10-21-2005 07:59 AM
startup script Circuit Monkey Linux - Newbie 2 04-13-2005 02:45 PM


All times are GMT -5. The time now is 11:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration