mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Move some of the ec2 initd stuff to common tasks
This commit is contained in:
parent
9de7793a92
commit
5ae3d92a22
6 changed files with 60 additions and 40 deletions
48
common/tasks/initd.py
Normal file
48
common/tasks/initd.py
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
from base import Task
|
||||||
|
from common import phases
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
|
||||||
|
class ResolveInitScripts(Task):
|
||||||
|
description = 'Determining which startup scripts to install or disable'
|
||||||
|
phase = phases.system_modification
|
||||||
|
|
||||||
|
def run(self, info):
|
||||||
|
init_scripts = {'expand-volume': 'expand-volume'}
|
||||||
|
|
||||||
|
init_scripts['generate-ssh-hostkeys'] = 'generate-ssh-hostkeys'
|
||||||
|
if info.manifest.system['release'] == 'squeeze':
|
||||||
|
init_scripts['generate-ssh-hostkeys'] = 'squeeze/generate-ssh-hostkeys'
|
||||||
|
|
||||||
|
disable_scripts = ['hwclock.sh']
|
||||||
|
if info.manifest.system['release'] == 'squeeze':
|
||||||
|
disable_scripts.append('hwclockfirst.sh')
|
||||||
|
|
||||||
|
init_scripts_dir = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/init.d'))
|
||||||
|
for name, path in init_scripts.iteritems():
|
||||||
|
init_scripts[name] = os.path.join(init_scripts_dir, path)
|
||||||
|
|
||||||
|
info.initd = {'install': init_scripts,
|
||||||
|
'disable': disable_scripts}
|
||||||
|
|
||||||
|
|
||||||
|
class InstallInitScripts(Task):
|
||||||
|
description = 'Installing startup scripts'
|
||||||
|
phase = phases.system_modification
|
||||||
|
after = [ResolveInitScripts]
|
||||||
|
|
||||||
|
def run(self, 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
|
||||||
|
from common.tools import log_check_call
|
||||||
|
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(['/usr/sbin/chroot', info.root, '/sbin/insserv', '-d', name])
|
||||||
|
|
||||||
|
for name in info.initd['disable']:
|
||||||
|
log_check_call(['/usr/sbin/chroot', info.root, '/sbin/insserv', '-r', name])
|
|
@ -15,6 +15,7 @@ from common.tasks import boot as common_boot
|
||||||
from tasks import security
|
from tasks import security
|
||||||
from common.tasks import network
|
from common.tasks import network
|
||||||
from tasks import initd
|
from tasks import initd
|
||||||
|
from common.tasks import initd as common_initd
|
||||||
from common.tasks import cleanup
|
from common.tasks import cleanup
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,8 +54,9 @@ def tasks(tasklist, manifest):
|
||||||
network.RemoveDNSInfo(),
|
network.RemoveDNSInfo(),
|
||||||
network.ConfigureNetworkIF(),
|
network.ConfigureNetworkIF(),
|
||||||
network.ConfigureDHCP(),
|
network.ConfigureDHCP(),
|
||||||
initd.ResolveInitScripts(),
|
common_initd.ResolveInitScripts(),
|
||||||
initd.InstallInitScripts(),
|
initd.AddEC2InitScripts(),
|
||||||
|
common_initd.InstallInitScripts(),
|
||||||
cleanup.ClearMOTD(),
|
cleanup.ClearMOTD(),
|
||||||
cleanup.ShredHostkeys(),
|
cleanup.ShredHostkeys(),
|
||||||
cleanup.CleanTMP(),
|
cleanup.CleanTMP(),
|
||||||
|
|
|
@ -1,49 +1,19 @@
|
||||||
from base import Task
|
from base import Task
|
||||||
from common import phases
|
from common import phases
|
||||||
|
from common.tasks import initd
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
|
|
||||||
class ResolveInitScripts(Task):
|
class AddEC2InitScripts(Task):
|
||||||
description = 'Determining which startup scripts to install or disable'
|
description = 'Adding EC2 startup scripts'
|
||||||
phase = phases.system_modification
|
phase = phases.system_modification
|
||||||
|
after = [initd.ResolveInitScripts]
|
||||||
|
before = [initd.InstallInitScripts]
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
init_scripts = {'ec2-get-credentials': 'ec2-get-credentials',
|
init_scripts = {'ec2-get-credentials': 'ec2-get-credentials',
|
||||||
'ec2-run-user-data': 'ec2-run-user-data',
|
'ec2-run-user-data': 'ec2-run-user-data'}
|
||||||
'expand-volume': 'expand-volume'}
|
|
||||||
|
|
||||||
init_scripts['generate-ssh-hostkeys'] = 'generate-ssh-hostkeys'
|
|
||||||
if info.manifest.system['release'] == 'squeeze':
|
|
||||||
init_scripts['generate-ssh-hostkeys'] = 'squeeze/generate-ssh-hostkeys'
|
|
||||||
|
|
||||||
disable_scripts = ['hwclock.sh']
|
|
||||||
if info.manifest.system['release'] == 'squeeze':
|
|
||||||
disable_scripts.append('hwclockfirst.sh')
|
|
||||||
|
|
||||||
|
init_scripts_dir = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/init.d'))
|
||||||
for name, path in init_scripts.iteritems():
|
for name, path in init_scripts.iteritems():
|
||||||
init_scripts[name] = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/init.d', path))
|
info.initd['install'][name] = os.path.join(init_scripts_dir, path)
|
||||||
|
|
||||||
info.initd = {'install': init_scripts,
|
|
||||||
'disable': disable_scripts}
|
|
||||||
|
|
||||||
|
|
||||||
class InstallInitScripts(Task):
|
|
||||||
description = 'Installing startup scripts'
|
|
||||||
phase = phases.system_modification
|
|
||||||
after = [ResolveInitScripts]
|
|
||||||
|
|
||||||
def run(self, 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
|
|
||||||
from common.tools import log_check_call
|
|
||||||
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(['/usr/sbin/chroot', info.root, '/sbin/insserv', '-d', name])
|
|
||||||
|
|
||||||
for name in info.initd['disable']:
|
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/sbin/insserv', '-r', name])
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue