mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 09:50:37 +00:00
Implemented cleanup tasks
This commit is contained in:
parent
5949c3c9cc
commit
4180f16656
2 changed files with 49 additions and 1 deletions
|
@ -12,6 +12,7 @@ from tasks import boot
|
|||
from tasks import security
|
||||
from tasks import network
|
||||
from tasks import initd
|
||||
from tasks import cleanup
|
||||
|
||||
|
||||
def initialize():
|
||||
|
@ -54,7 +55,10 @@ def tasks(tasklist, manifest):
|
|||
network.ConfigureNetworkIF(),
|
||||
network.ConfigureDHCP(),
|
||||
initd.ResolveInitScripts(),
|
||||
initd.InstallInitScripts())
|
||||
initd.InstallInitScripts(),
|
||||
cleanup.ClearMOTD(),
|
||||
cleanup.ShredHostkeys(),
|
||||
cleanup.CleanTMP())
|
||||
|
||||
from common.tasks import TriggerRollback
|
||||
tasklist.add(TriggerRollback())
|
||||
|
|
44
providers/ec2/tasks/cleanup.py
Normal file
44
providers/ec2/tasks/cleanup.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
import os
|
||||
|
||||
|
||||
class ClearMOTD(Task):
|
||||
description = 'Clearing the MOTD'
|
||||
phase = phases.system_cleaning
|
||||
|
||||
def run(self, info):
|
||||
with open('/var/run/motd', 'w'):
|
||||
pass
|
||||
|
||||
|
||||
class ShredHostkeys(Task):
|
||||
description = 'Securely deleting ssh hostkeys'
|
||||
phase = phases.system_cleaning
|
||||
|
||||
def run(self, info):
|
||||
ssh_hostkeys = ['ssh_host_dsa_key',
|
||||
'ssh_host_rsa_key']
|
||||
if info.manifest.system['release'] != 'squeeze':
|
||||
ssh_hostkeys.append('ssh_host_ecdsa_key')
|
||||
|
||||
private = [os.path.join(info.root, 'etc/ssh', name) for name in ssh_hostkeys]
|
||||
public = [path + '.pub' for path in private]
|
||||
|
||||
from common.tools import log_check_call
|
||||
log_check_call(['/usr/bin/shred', '--remove'] + private + public)
|
||||
|
||||
|
||||
class CleanTMP(Task):
|
||||
description = 'Removing temporary files'
|
||||
phase = phases.system_cleaning
|
||||
|
||||
def run(self, info):
|
||||
import glob
|
||||
tmp_files = glob.glob(os.path.join(info.root, 'tmp/*'))
|
||||
for tmp_file in tmp_files:
|
||||
os.remove(tmp_file)
|
||||
|
||||
log_files = glob.glob(os.path.join(info.root, 'var/log/{bootstrap,dpkg}.log'))
|
||||
for log_file in log_files:
|
||||
os.remove(log_file)
|
Loading…
Add table
Reference in a new issue