mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 09:50:37 +00:00

Up until now I didn't see the point of using spaces for indentation. However, the previous commit (a18bec3) was quite eye opening. Given that python is an indentation aware language, the amount of mistakes that went unnoticed because tabs and spaces were used at the same time (tabs for indentation and spaces for alignment) were unacceptable. E101,W191 have been re-enable in the tox flake8 checker and the documentation has been modified accordingly. The following files have been left as-is: * bootstrapvz/common/assets/extlinux/extlinux.conf * bootstrapvz/common/assets/init.d/expand-root * bootstrapvz/common/assets/init.d/generate-ssh-hostkeys * bootstrapvz/common/assets/init.d/squeeze/generate-ssh-hostkeys * bootstrapvz/plugins/docker_daemon/assets/init.d/docker * bootstrapvz/providers/ec2/assets/bin/growpart * bootstrapvz/providers/ec2/assets/grub.d/40_custom * bootstrapvz/providers/ec2/assets/init.d/ec2-get-credentials * bootstrapvz/providers/ec2/assets/init.d/ec2-run-user-data * docs/_static/taskoverview.coffee * docs/_static/taskoverview.less * tests/unit/subprocess.sh
80 lines
2.7 KiB
Python
80 lines
2.7 KiB
Python
from bootstrapvz.base import Task
|
|
from .. import phases
|
|
from ..tools import log_check_call
|
|
from . import assets
|
|
import os.path
|
|
|
|
|
|
class InstallInitScripts(Task):
|
|
description = 'Installing startup scripts'
|
|
phase = phases.system_modification
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
import stat
|
|
rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
|
|
stat.S_IRGRP | stat.S_IXGRP |
|
|
stat.S_IROTH | stat.S_IXOTH)
|
|
from shutil import copy
|
|
for name, src in info.initd['install'].iteritems():
|
|
dst = os.path.join(info.root, 'etc/init.d', name)
|
|
copy(src, dst)
|
|
os.chmod(dst, rwxr_xr_x)
|
|
log_check_call(['chroot', info.root, 'insserv', '--default', name])
|
|
|
|
for name in info.initd['disable']:
|
|
log_check_call(['chroot', info.root, 'insserv', '--remove', name])
|
|
|
|
|
|
class AddExpandRoot(Task):
|
|
description = 'Adding init script to expand the root volume'
|
|
phase = phases.system_modification
|
|
successors = [InstallInitScripts]
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
init_scripts_dir = os.path.join(assets, 'init.d')
|
|
info.initd['install']['expand-root'] = os.path.join(init_scripts_dir, 'expand-root')
|
|
|
|
|
|
class RemoveHWClock(Task):
|
|
description = 'Removing hardware clock init scripts'
|
|
phase = phases.system_modification
|
|
successors = [InstallInitScripts]
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
from bootstrapvz.common.releases import squeeze
|
|
info.initd['disable'].append('hwclock.sh')
|
|
if info.manifest.release == squeeze:
|
|
info.initd['disable'].append('hwclockfirst.sh')
|
|
|
|
|
|
class AdjustExpandRootScript(Task):
|
|
description = 'Adjusting the expand-root script'
|
|
phase = phases.system_modification
|
|
predecessors = [InstallInitScripts]
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
from ..tools import sed_i
|
|
script = os.path.join(info.root, 'etc/init.d/expand-root')
|
|
|
|
root_idx = info.volume.partition_map.root.get_index()
|
|
root_index_line = 'root_index="{idx}"'.format(idx=root_idx)
|
|
sed_i(script, '^root_index="0"$', root_index_line)
|
|
|
|
root_device_path = 'root_device_path="{device}"'.format(device=info.volume.device_path)
|
|
sed_i(script, '^root_device_path="/dev/xvda"$', root_device_path)
|
|
|
|
|
|
class AdjustGrowpartWorkaround(Task):
|
|
description = 'Adjusting expand-root for growpart-workaround'
|
|
phase = phases.system_modification
|
|
predecessors = [AdjustExpandRootScript]
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
from ..tools import sed_i
|
|
script = os.path.join(info.root, 'etc/init.d/expand-root')
|
|
sed_i(script, '^growpart="growpart"$', 'growpart-workaround')
|