#!/usr/bin/env python # From a Samba config file, spit out an NFS exports file that means # approximately the same thing. fi = open("/etc/samba/smb.conf") fo = open("/etc/exports", "w") modules = {} module = None for l in fi.readlines(): l = l.strip() if l == "" or l[0] == "#": pass elif l[0] == "[": module = l[1:-1] elif module != "global": (n, v) = l.split(" = ", 1) if not modules.has_key(module): modules[module] = {"public" : "yes", "writable" : "no"} modules[module][n] = v for m in modules.keys(): args = modules[m] if args["public"] != "yes": continue if args["writable"] == "yes": mode = "rw" else: mode = "ro" print >>fo, args["path"] + "\t192.168.58.0/255.255.255.0(" + mode + ")" fi.close() fo.close()