2014-03-23 23:12:07 +01:00
|
|
|
from bootstrapvz.base import Task
|
|
|
|
from .. import phases
|
2013-12-01 23:50:32 +01:00
|
|
|
import os.path
|
2015-01-02 14:50:05 +01:00
|
|
|
from . import assets
|
2013-08-10 16:18:48 +02:00
|
|
|
|
|
|
|
|
2015-01-24 08:17:34 +00:00
|
|
|
class UpdateInitramfs(Task):
|
|
|
|
description = 'Updating initramfs'
|
|
|
|
phase = phases.system_modification
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
|
|
|
from ..tools import log_check_call
|
|
|
|
log_check_call(['chroot', info.root, 'update-initramfs', '-u'])
|
|
|
|
|
|
|
|
|
2013-08-10 16:18:48 +02:00
|
|
|
class BlackListModules(Task):
|
|
|
|
description = 'Blacklisting kernel modules'
|
|
|
|
phase = phases.system_modification
|
2015-01-24 08:17:34 +00:00
|
|
|
successors = [UpdateInitramfs]
|
2013-08-10 16:18:48 +02:00
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-08-10 16:18:48 +02:00
|
|
|
blacklist_path = os.path.join(info.root, 'etc/modprobe.d/blacklist.conf')
|
|
|
|
with open(blacklist_path, 'a') as blacklist:
|
2015-01-24 08:17:34 +00:00
|
|
|
blacklist.write(('# disable pc speaker and floppy\n'
|
|
|
|
'blacklist pcspkr\n'
|
|
|
|
'blacklist floppy\n'))
|
2013-08-10 16:18:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
class DisableGetTTYs(Task):
|
|
|
|
description = 'Disabling getty processes'
|
|
|
|
phase = phases.system_modification
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2015-04-29 20:55:55 +02:00
|
|
|
# Forward compatible check for jessie
|
|
|
|
from bootstrapvz.common.releases import jessie
|
|
|
|
if info.manifest.release < jessie:
|
2014-12-31 15:24:30 +01:00
|
|
|
from ..tools import sed_i
|
|
|
|
inittab_path = os.path.join(info.root, 'etc/inittab')
|
|
|
|
tty1 = '1:2345:respawn:/sbin/getty 38400 tty1'
|
|
|
|
sed_i(inittab_path, '^' + tty1, '#' + tty1)
|
|
|
|
ttyx = ':23:respawn:/sbin/getty 38400 tty'
|
|
|
|
for i in range(2, 7):
|
|
|
|
i = str(i)
|
|
|
|
sed_i(inittab_path, '^' + i + ttyx + i, '#' + i + ttyx + i)
|
|
|
|
else:
|
2015-01-02 14:50:05 +01:00
|
|
|
from shutil import copy
|
|
|
|
logind_asset_path = os.path.join(assets, 'systemd/logind.conf')
|
|
|
|
logind_destination = os.path.join(info.root, 'etc/systemd/logind.conf')
|
|
|
|
copy(logind_asset_path, logind_destination)
|