2014-03-23 23:12:07 +01:00
|
|
|
from bootstrapvz.base import Task
|
|
|
|
from .. import phases
|
2013-07-07 16:59:12 +02:00
|
|
|
import os
|
2013-12-15 08:31:15 +01:00
|
|
|
import shutil
|
2013-07-07 16:59:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ClearMOTD(Task):
|
|
|
|
description = 'Clearing the MOTD'
|
|
|
|
phase = phases.system_cleaning
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-07-07 16:59:12 +02:00
|
|
|
with open('/var/run/motd', 'w'):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class CleanTMP(Task):
|
|
|
|
description = 'Removing temporary files'
|
|
|
|
phase = phases.system_cleaning
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-07-07 18:07:15 +02:00
|
|
|
tmp = os.path.join(info.root, 'tmp')
|
|
|
|
for tmp_file in [os.path.join(tmp, f) for f in os.listdir(tmp)]:
|
2013-12-15 08:31:15 +01:00
|
|
|
if os.path.isfile(tmp_file):
|
|
|
|
os.remove(tmp_file)
|
|
|
|
else:
|
|
|
|
shutil.rmtree(tmp_file)
|
2013-07-07 16:59:12 +02:00
|
|
|
|
2013-07-07 18:07:15 +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'))
|