#coding:utf-8

import os
import sunhpc
class Plugin(sunhpc.commands.Plugin):
    """Relocates home directories to location on file server and fixes autofs.share"""

    def run(self, args):
        """修复auto.share文件"""

        # 默认auto.share数据
        hostname    = '%s.%s' % (self.db.getFrontendName(),
                    self.db.getHostAttr('localhost', 'Kickstart_PrivateDNSDomain'))

        shared      = '/etc/auto.share'
        content     = 'apps %s:/export/&' % (hostname)

        if self.cmd.matchText(shared, content):
            with open(shared, 'w') as f:
                f.write('%s\n' % content)
