Commit b0e52529 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

Cron doesn't include lxc by default, have to be choosen in slapprepare

Slapprepare now propose default parameters
parent 6b4d9629
...@@ -7,5 +7,3 @@ MAILTO=root ...@@ -7,5 +7,3 @@ MAILTO=root
0 0 * * * root /opt/slapos/bin/slapgrid-ur --verbose --logfile=/opt/slapos/slapgrid-ur.log --pidfile=/opt/slapos/slapgrid-ur.pid /etc/opt/slapos/slapos.cfg >> /opt/slapos/slapgrid-ur.log 2>&1 0 0 * * * root /opt/slapos/bin/slapgrid-ur --verbose --logfile=/opt/slapos/slapgrid-ur.log --pidfile=/opt/slapos/slapgrid-ur.pid /etc/opt/slapos/slapos.cfg >> /opt/slapos/slapgrid-ur.log 2>&1
0 0 * * * root /opt/slapos/bin/slapformat --verbose --log_file=/opt/slapos/slapformat.log -c /etc/opt/slapos/slapos.cfg >> /opt/slapos/slapformat.log 2>&1 0 0 * * * root /opt/slapos/bin/slapformat --verbose --log_file=/opt/slapos/slapformat.log -c /etc/opt/slapos/slapos.cfg >> /opt/slapos/slapformat.log 2>&1
# XXX: SlapContainer
*/5 * * * * root if [ -x /opt/slapgrid/843c2b4de8c5579427b072d00ec2ec9e/bin/slapcontainer ] ; then /opt/slapgrid/843c2b4de8c5579427b072d00ec2ec9e/bin/slapcontainer --pid /opt/slapos/slapcontainer.pid /etc/opt/slapos/slapos.cfg /opt/slapos/slapcontainer.db > /opt/slapos/slapcontainer.log 2>&1 ; fi
...@@ -71,12 +71,19 @@ def _call(cmd_args, stdout=None, stderr=None, dry_run=False): ...@@ -71,12 +71,19 @@ def _call(cmd_args, stdout=None, stderr=None, dry_run=False):
(str(e), ' '.join(cmd_args))) (str(e), ' '.join(cmd_args)))
# Utility fonction to get yes/no answers # Utility fonction to get yes/no answers
def get_yes_no (prompt): def get_yes_no (prompt,default=None):
ok= 0 if default :
while not ok: def_value = '/ Default yes'
answer=raw_input( prompt + " [y,n]: " ) elif default == False :
def_value = '/ Default no'
else :
def_value = ''
while True:
answer=raw_input( prompt + " [y,n] %s: " % def_value )
if answer.upper() in [ 'Y','YES' ]: return True if answer.upper() in [ 'Y','YES' ]: return True
if answer.upper() in [ 'N', 'NO' ]: return False if answer.upper() in [ 'N', 'NO' ]: return False
if not default == None :
if answer == '' : return default
# Return OpenSUSE version if it is SuSE # Return OpenSUSE version if it is SuSE
def suse_version(): def suse_version():
...@@ -260,6 +267,12 @@ log /var/log/openvpn.log""" % dict( ...@@ -260,6 +267,12 @@ log /var/log/openvpn.log""" % dict(
if not dry_run: if not dry_run:
open(os.path.join(config.slapos_configuration,'openvpn-needed'),'w') open(os.path.join(config.slapos_configuration,'openvpn-needed'),'w')
# Put file to force VPN if user asked
if config.force_slapcontainer :
if not dry_run:
open(os.path.join(config.slapos_configuration,'SlapContainer-needed'),'w')
# Removing line in slapos script activating kvm in virtual # Removing line in slapos script activating kvm in virtual
if config.virtual: if config.virtual:
if not dry_run: if not dry_run:
...@@ -309,21 +322,24 @@ class Config: ...@@ -309,21 +322,24 @@ class Config:
def userConfig(self): def userConfig(self):
self.certificates = get_yes_no("Automatically register new computer to Vifib?") self.certificates = get_yes_no("Automatically register new computer to Vifib?",True)
if self.certificates: if self.certificates:
self.computer_name = raw_input("Define a unique name for this computer: ") self.computer_name = raw_input("Define a unique name for this computer: ")
self.partition_amount = raw_input("""Number of SlapOS partitions for this computer? """) self.partition_amount = raw_input("""Number of SlapOS partitions for this computer? Default is 20 :""")
self.virtual = get_yes_no("Is this a virtual Machine?") if self.partition_amount == '':
self.partition_amount = 20
self.virtual = get_yes_no("Is this a virtual Machine?",False)
if not self.virtual: if not self.virtual:
self.one_disk = not get_yes_no ("Do you want to use SlapOS with a second disk?") self.one_disk = not get_yes_no ("Do you want to use SlapOS with a second disk?",True)
else: else:
self.one_disk=True self.one_disk=True
self.force_vpn = get_yes_no ("Do you want to force the use of vpn to provide ipv6?") self.force_vpn = get_yes_no ("Do you want to force the use of vpn to provide ipv6?",True)
self.force_vpn = get_yes_no ("Do you want to force the use lxc on this computer?",False)
if self.force_vpn : if self.force_vpn :
self.ipv6_interface = "tapVPN" self.ipv6_interface = "tapVPN"
else : else :
self.ipv6_interface = "" self.ipv6_interface = ""
self.need_ssh = get_yes_no("Do you want a remote ssh access?") self.need_ssh = get_yes_no("Do you want a remote ssh access?",True)
def displayUserConfig(self): def displayUserConfig(self):
if self.certificates: if self.certificates:
...@@ -347,7 +363,7 @@ def slapprepare(): ...@@ -347,7 +363,7 @@ def slapprepare():
config.userConfig() config.userConfig()
print "\nThis your configuration: \n" print "\nThis your configuration: \n"
config.displayUserConfig() config.displayUserConfig()
if get_yes_no("\nDo you confirm?"): if get_yes_no("\nDo you confirm?",True):
break break
if config.certificates: if config.certificates:
...@@ -408,3 +424,12 @@ def slapprepare(): ...@@ -408,3 +424,12 @@ def slapprepare():
print "Deleting directory: %s" % temp_directory print "Deleting directory: %s" % temp_directory
_call(['rm','-rf',temp_directory]) _call(['rm','-rf',temp_directory])
sys.exit(return_code) sys.exit(return_code)
if __name__ == "__main__" :
config= Config()
while True :
config.userConfig()
print "\nThis your configuration: \n"
config.displayUserConfig()
if get_yes_no("\nDo you confirm?"):
break
...@@ -113,20 +113,27 @@ mkdir -v -p -m 0755 $repo ...@@ -113,20 +113,27 @@ mkdir -v -p -m 0755 $repo
# software detected, ready to run # software detected, ready to run
# Set up cron # Set up cron
# Fix path in case of old config:
SLAPOS_GOOD_CONFIGURATION=/etc/opt/slapos/
if [ $SLAPOS_GOOD_CONFIGURATION != $SLAPOS_CONFIGURATION ]; then
sed -i "s|$SLAPOS_GOOD_CONFIGURATION|$SLAPOS_CONFIGURATION|g" /etc/cron.d/slapos-node
# Remove default route for ipv6 in case of openvpn-needed
echo """# BEWARE: This file will be automatically regenerated on each boot echo """# BEWARE: This file will be automatically regenerated on each boot
SHELL=/bin/sh SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root MAILTO=root
0 0 * * * root /opt/slapos/bin/slapformat --verbose --log_file=/opt/slapos/slapformat.log -c ${SLAPOS_CONFIGURATION}slapos.cfg >> /opt/slapos/slapformat.log 2>&1
*/5 * * * * root /opt/slapos/bin/slapgrid-cp --verbose --logfile=/opt/slapos/slapgrid-cp.log --pidfile=/opt/slapos/slapgrid-cp.pid ${SLAPOS_CONFIGURATION}slapos.cfg >> /opt/slapos/slapgrid-cp.log 2>&1
*/5 * * * * root /opt/slapos/bin/slapgrid-sr --verbose --logfile=/opt/slapos/slapgrid-sr.log --pidfile=/opt/slapos/slapgrid-sr.pid ${SLAPOS_CONFIGURATION}slapos.cfg >> /opt/slapos/slapgrid-sr.log 2>&1
0 0 * * * root /opt/slapos/bin/slapgrid-ur --verbose --logfile=/opt/slapos/slapgrid-ur.log --pidfile=/opt/slapos/slapgrid-ur.pid ${SLAPOS_CONFIGURATION}slapos.cfg >> /opt/slapos/slapgrid-ur.log 2>&1
0/10 * * * * root if [[ -f ${SLAPOS_CONFIGURATION}/openvpn-needed ]]; then ip -6 route del dev br0 ; fi 0/10 * * * * root if [[ -f ${SLAPOS_CONFIGURATION}/openvpn-needed ]]; then ip -6 route del dev br0 ; fi
"""> /etc/cron.d/slapos
if [ -f ${SLAPOS_CONFIGURATION}/SlapContainer-needed ]; then
echo """
# XXX: SlapContainer # XXX: SlapContainer
*/5 * * * * root if [ -x /opt/slapgrid/843c2b4de8c5579427b072d00ec2ec9e/bin/slapcontainer ] ; then /opt/slapgrid/843c2b4de8c5579427b072d00ec2ec9e/bin/slapcontainer --pid /opt/slapos/slapcontainer.pid ${SLAPOS_CONFIGURATION}slapos.cfg /opt/slapos/slapcontainer.db > /opt/slapos/slapcontainer.log 2>&1 ; fi */5 * * * * root if [ -x /opt/slapgrid/c436b64d40a48507801d06c53cc27fec/bin/slapcontainer ] ; then /opt/slapgrid/c436b64d40a48507801d06c53cc27fec/bin/slapcontainer --pid /opt/slapos/slapcontainer.pid ${SLAPOS_CONFIGURATION}slapos.cfg /opt/slapos/slapcontainer.db > /opt/slapos/slapcontainer.log 2>&1 ; fi
""" > /etc/cron.d/slapos-node """ >> /etc/cron.d/slapos
fi
# Setup more server like network parameters in order to avoid # Setup more server like network parameters in order to avoid
# "Neighbour table overflow." # "Neighbour table overflow."
......
...@@ -7,5 +7,3 @@ MAILTO=root ...@@ -7,5 +7,3 @@ MAILTO=root
0 0 * * * root /opt/slapos/bin/slapgrid-ur --verbose --logfile=/opt/slapos/slapgrid-ur.log --pidfile=/opt/slapos/slapgrid-ur.pid /etc/opt/slapos/slapos.cfg >> /opt/slapos/slapgrid-ur.log 2>&1 0 0 * * * root /opt/slapos/bin/slapgrid-ur --verbose --logfile=/opt/slapos/slapgrid-ur.log --pidfile=/opt/slapos/slapgrid-ur.pid /etc/opt/slapos/slapos.cfg >> /opt/slapos/slapgrid-ur.log 2>&1
0 0 * * * root /opt/slapos/bin/slapformat --verbose --log_file=/opt/slapos/slapformat.log -c /etc/opt/slapos/slapos.cfg >> /opt/slapos/slapformat.log 2>&1 0 0 * * * root /opt/slapos/bin/slapformat --verbose --log_file=/opt/slapos/slapformat.log -c /etc/opt/slapos/slapos.cfg >> /opt/slapos/slapformat.log 2>&1
# XXX: SlapContainer
*/5 * * * * root if [ -x /opt/slapgrid/843c2b4de8c5579427b072d00ec2ec9e/bin/slapcontainer ] ; then /opt/slapgrid/843c2b4de8c5579427b072d00ec2ec9e/bin/slapcontainer --pid /opt/slapos/slapcontainer.pid /etc/opt/slapos/slapos.cfg /opt/slapos/slapcontainer.db > /opt/slapos/slapcontainer.log 2>&1 ; fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment