X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=secnet.git;a=blobdiff_plain;f=make-secnet-sites;h=f9c249bb7ac904dfc610e64bed99ef15fa9a5503;hp=93bfc10e427c6cf778a317fac7490c06b3b32d07;hb=e8344e4877576df778013d8837780001d0994ef8;hpb=4740ac68ef030c1f16996fb3d20ddbbae3df01fc diff --git a/make-secnet-sites b/make-secnet-sites index 93bfc10..f9c249b 100755 --- a/make-secnet-sites +++ b/make-secnet-sites @@ -299,7 +299,10 @@ class OpBase(): else: self.inputlines = pfilepath(self.inputfile) def write_out(self): - f=open(self.sitesfile+"-tmp",'w') + if self.sitesfile is None: + f=sys.stdout + else: + f=open(self.sitesfile+"-tmp",'w') f.write("# sites file autogenerated by make-secnet-sites\n") f.write("# generated %s, invoked by %s\n"% (time.asctime(time.localtime(time.time())), @@ -308,11 +311,13 @@ class OpBase(): f.write("# valid /etc/secnet/sites.conf file\n\n") self.write_out_contents(f) f.write("# end of sites file\n") - f.close() - os.rename(self.sitesfile+"-tmp",self.sitesfile) + if self.sitesfile is not None: + f.close() + os.rename(self.sitesfile+"-tmp",self.sitesfile) class OpConf(OpBase): - def is_service(self): return 0 + opts = ['--conf'] + help = 'sites.conf generation mode (default)' def positional_args(self, av): if len(av.arg)>3: print("Too many arguments") @@ -332,7 +337,6 @@ class OpConf(OpBase): class OpUserv(OpBase): opts = ['--userv','-u'] help = 'userv service fragment update mode' - def is_service(self): return 1 def positional_args(self, av): if len(av.arg)!=4: print("Wrong number of arguments") @@ -388,7 +392,6 @@ class OpUserv(OpBase): def parse_args(): global opmode - global service global prefix global key_prefix global debug_level @@ -402,6 +405,7 @@ def parse_args(): nargs=0, fn=(lambda v,ns,*x: setattr(ns,'opmode',how)), help=how().help) + add_opmode(OpConf) add_opmode(OpUserv) ap.add_argument('--conf-key-prefix', action=ActionNoYes, default=True, @@ -428,7 +432,6 @@ def parse_args(): debug_level = av.debug debugrepr('av',av) opmode = getattr(av,'opmode',OpConf)() - service = opmode.is_service() prefix = '' if av.prefix is None else av.prefix[0] key_prefix = av.conf_key_prefix output_version = av.output_version[0]