#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.master数据
        share_mount = '/share /etc/auto.share --timeout=1200'
        homes_mount = '/home  /etc/auto.home  --timeout=1200'
        auto_master = '/etc/auto.master'

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