Commit 79e7303f authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

Added ntp to slapprepare for one-disk and and in boot script

parent 86bc29f4
......@@ -33,6 +33,8 @@ from subprocess import call as subprocessCall
import sys
import urllib2
SLAPOS_MARK='# Added by SlapOS\n'
__import__('pkg_resources').declare_namespace(__name__)
......@@ -138,12 +140,12 @@ def get_ssh(temp_dir):
try:
ssh_key_all = urllib2.urlopen(''.join(ssh_web))
gotten= True
except ValueError, err:
except ValueError:
# add http:// if it is missing (needed by urllib2)
ssh_web = """http://"""+ssh_web
ssh_key_all = urllib2.urlopen(''.join(ssh_web))
gotten= True
except urllib2.URLError,err:
except urllib2.URLError:
print " URL ERROR"
gotten = False
count -= 1
......@@ -300,6 +302,21 @@ log /var/log/openvpn.log""" % dict(
print "SlapOS Image configuration: DONE"
return 0
def configureNtp():
"""Configures NTP daemon"""
server = "server pool.ntp.org"
old_ntp = open('/etc/ntp.conf', 'r').readlines()
new_ntp = open('/etc/ntp.conf', 'w')
for line in old_ntp:
if line.startswith('server'):
continue
new_ntp.write(line)
new_ntp.write(SLAPOS_MARK)
new_ntp.write(server+'\n')
new_ntp.close()
_call(['chkconfig', '--add', 'ntp'])
_call(['systemctl', 'enable', 'ntp.service'])
class Config:
def setConfig(self,mount_dir_path,slapos_configuration,
......@@ -401,6 +418,8 @@ def slapprepare():
computer_id=computer_id)
configureNtp()
# Prepare SlapOS Suse Server confuguration
if config.need_ssh :
......
......@@ -28,6 +28,7 @@
systemctl stop slapos-node.service
systemctl disable slapos-node.service
systemctl restart ntp.service
# clean the system
for service in rpcbind network-remotefs postfix ; do
......
......@@ -159,22 +159,6 @@ def prepareSlapOSPartition(mount_point):
callWithCheck(['mount', '/tmp'])
callWithCheck(['mount', '/srv'])
def configureNtp():
"""Configures NTP daemon"""
server = "server pool.ntp.org"
old_ntp = open('/etc/ntp.conf', 'r').readlines()
new_ntp = open('/etc/ntp.conf', 'w')
for line in old_ntp:
if line.startswith('server'):
continue
new_ntp.write(line)
new_ntp.write(SLAPOS_MARK)
new_ntp.write(server+'\n')
new_ntp.close()
callWithIgnore(['chkconfig', '--add', 'ntp'])
callWithIgnore(['systemctl', 'enable', 'ntp.service'])
callWithIgnore(['systemctl', 'restart', 'ntp.service'])
def getMountedPartitionList():
partition_list = []
for line in open('/etc/mtab', 'r').readlines():
......@@ -299,7 +283,7 @@ def run():
prepareSlapOSPartition(mount_point)
print "Configuring fallback grub information"
configureGrub(mount_point, slapos_label_file)
configureNtp()
if __name__ == '__main__':
try:
......
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