2014-03-23 23:12:07 +01:00
|
|
|
from bootstrapvz.base import Task
|
|
|
|
from .. import phases
|
|
|
|
from ..tools import log_check_call
|
2013-12-29 23:21:50 +01:00
|
|
|
from . import assets
|
2013-08-10 16:51:42 +02:00
|
|
|
import os.path
|
|
|
|
|
|
|
|
|
|
|
|
class InstallInitScripts(Task):
|
|
|
|
description = 'Installing startup scripts'
|
|
|
|
phase = phases.system_modification
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-08-10 16:51:42 +02:00
|
|
|
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)
|
2014-02-23 22:16:10 +01:00
|
|
|
log_check_call(['chroot', info.root, 'insserv', '--default', name])
|
2013-08-10 16:51:42 +02:00
|
|
|
|
|
|
|
for name in info.initd['disable']:
|
2014-02-23 22:16:10 +01:00
|
|
|
log_check_call(['chroot', info.root, 'insserv', '--remove', name])
|
2013-11-21 16:58:21 +01:00
|
|
|
|
|
|
|
|
2013-12-01 14:34:38 +01:00
|
|
|
class AddExpandRoot(Task):
|
|
|
|
description = 'Adding init script to expand the root volume'
|
|
|
|
phase = phases.system_modification
|
|
|
|
successors = [InstallInitScripts]
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-12-29 23:21:50 +01:00
|
|
|
init_scripts_dir = os.path.join(assets, 'init.d')
|
2013-12-01 14:34:38 +01:00
|
|
|
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]
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2015-04-29 20:55:55 +02:00
|
|
|
from bootstrapvz.common.releases import squeeze
|
2013-12-01 14:34:38 +01:00
|
|
|
info.initd['disable'].append('hwclock.sh')
|
2015-04-29 20:55:55 +02:00
|
|
|
if info.manifest.release == squeeze:
|
2013-12-01 14:34:38 +01:00
|
|
|
info.initd['disable'].append('hwclockfirst.sh')
|
|
|
|
|
|
|
|
|
2013-11-21 16:58:21 +01:00
|
|
|
class AdjustExpandRootScript(Task):
|
|
|
|
description = 'Adjusting the expand-root script'
|
|
|
|
phase = phases.system_modification
|
|
|
|
predecessors = [InstallInitScripts]
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2014-05-04 11:48:03 +02:00
|
|
|
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()
|
2015-06-30 15:14:41 -03:00
|
|
|
root_index_line = 'root_index="{idx}"'.format(idx=root_idx)
|
|
|
|
sed_i(script, '^root_index="0"$', root_index_line)
|