bootstrap-vz/bootstrapvz/common/tasks/cleanup.py

33 lines
831 B
Python
Raw Normal View History

from bootstrapvz.base import Task
from .. import phases
2013-07-07 16:59:12 +02:00
import os
import shutil
2013-07-07 16:59:12 +02:00
class ClearMOTD(Task):
description = 'Clearing the MOTD'
phase = phases.system_cleaning
2013-07-07 16:59:12 +02:00
@classmethod
def run(cls, info):
with open('/var/run/motd', 'w'):
pass
2013-07-07 16:59:12 +02:00
class CleanTMP(Task):
description = 'Removing temporary files'
phase = phases.system_cleaning
2013-07-07 16:59:12 +02:00
@classmethod
def run(cls, info):
tmp = os.path.join(info.root, 'tmp')
for tmp_file in [os.path.join(tmp, f) for f in os.listdir(tmp)]:
if os.path.isfile(tmp_file):
os.remove(tmp_file)
else:
shutil.rmtree(tmp_file)
2013-07-07 16:59:12 +02:00
log = os.path.join(info.root, 'var/log/')
os.remove(os.path.join(log, 'bootstrap.log'))
os.remove(os.path.join(log, 'dpkg.log'))