Stretch (9.0) patch #3 - EC2: fixing insserv & +

ssh keys removal for releases after Jessie
This commit is contained in:
Marcin Kulisz 2016-09-20 18:59:54 +01:00
parent ee64a87889
commit 18f31df2f4
2 changed files with 12 additions and 3 deletions

View file

@ -12,6 +12,7 @@ class InstallInitScripts(Task):
@classmethod
def run(cls, info):
import stat
from bootstrapvz.common.releases import jessie
rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
stat.S_IRGRP | stat.S_IXGRP |
stat.S_IROTH | stat.S_IXOTH)
@ -20,10 +21,16 @@ class InstallInitScripts(Task):
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])
if info.manifest.release > jessie:
log_check_call(['chroot', info.root, 'systemctl', 'enable', name])
else:
log_check_call(['chroot', info.root, 'insserv', '--default', name])
for name in info.initd['disable']:
log_check_call(['chroot', info.root, 'insserv', '--remove', name])
if info.manifest.release > jessie:
log_check_call(['chroot', info.root, 'systemctl', 'mask', name])
else:
log_check_call(['chroot', info.root, 'insserv', '--remove', name])
class AddExpandRoot(Task):

View file

@ -101,6 +101,7 @@ class ShredHostkeys(Task):
def run(cls, info):
ssh_hostkeys = ['ssh_host_dsa_key',
'ssh_host_rsa_key']
from bootstrapvz.common.releases import wheezy
if info.manifest.release >= wheezy:
ssh_hostkeys.append('ssh_host_ecdsa_key')
@ -109,4 +110,5 @@ class ShredHostkeys(Task):
public = [path + '.pub' for path in private]
from ..tools import log_check_call
log_check_call(['shred', '--remove'] + private + public)
log_check_call(['shred', '--remove'] + [key for key in private + public
if os.path.isfile(key)])