mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 18:00:35 +00:00
Merge pull request #281 from srivasta/master
[set localtime]: Set /etc/localtime by either copying or symlinking
This commit is contained in:
commit
b681ae8c0e
2 changed files with 36 additions and 6 deletions
|
@ -33,7 +33,7 @@ def get_standard_groups(manifest):
|
|||
group.extend(get_network_group(manifest))
|
||||
group.extend(get_apt_group(manifest))
|
||||
group.extend(security_group)
|
||||
group.extend(locale_group)
|
||||
group.extend(get_locale_group(manifest))
|
||||
group.extend(get_bootloader_group(manifest))
|
||||
group.extend(cleanup_group)
|
||||
return group
|
||||
|
@ -133,10 +133,19 @@ def get_apt_group(manifest):
|
|||
|
||||
security_group = [security.EnableShadowConfig]
|
||||
|
||||
locale_group = [locale.LocaleBootstrapPackage,
|
||||
locale.GenerateLocale,
|
||||
locale.SetTimezone,
|
||||
]
|
||||
|
||||
def get_locale_group(manifest):
|
||||
from bootstrapvz.common.releases import jessie
|
||||
group = [
|
||||
locale.LocaleBootstrapPackage,
|
||||
locale.GenerateLocale,
|
||||
locale.SetTimezone,
|
||||
]
|
||||
if manifest.release > jessie:
|
||||
group.append(locale.SetLocalTimeLink)
|
||||
else:
|
||||
group.append(locale.SetLocalTimeCopy)
|
||||
return group
|
||||
|
||||
|
||||
def get_bootloader_group(manifest):
|
||||
|
|
|
@ -43,11 +43,32 @@ class SetTimezone(Task):
|
|||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from shutil import copy
|
||||
tz_path = os.path.join(info.root, 'etc/timezone')
|
||||
timezone = info.manifest.system['timezone']
|
||||
with open(tz_path, 'w') as tz_file:
|
||||
tz_file.write(timezone)
|
||||
|
||||
|
||||
class SetLocalTimeLink(Task):
|
||||
description = 'Setting the selected local timezone (link)'
|
||||
phase = phases.system_modification
|
||||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
timezone = info.manifest.system['timezone']
|
||||
localtime_path = os.path.join(info.root, 'etc/localtime')
|
||||
os.unlink(localtime_path)
|
||||
os.symlink(os.path.join('/usr/share/zoneinfo', timezone), localtime_path)
|
||||
|
||||
|
||||
class SetLocalTimeCopy(Task):
|
||||
description = 'Setting the selected local timezone (copy)'
|
||||
phase = phases.system_modification
|
||||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from shutil import copy
|
||||
timezone = info.manifest.system['timezone']
|
||||
zoneinfo_path = os.path.join(info.root, '/usr/share/zoneinfo', timezone)
|
||||
localtime_path = os.path.join(info.root, 'etc/localtime')
|
||||
copy(zoneinfo_path, localtime_path)
|
||||
|
|
Loading…
Add table
Reference in a new issue