diff --git a/documentation/gw.rst b/documentation/gw.rst index 0464578..0d65431 100644 --- a/documentation/gw.rst +++ b/documentation/gw.rst @@ -14,7 +14,7 @@ The following commands will set up a gateway instance named ``mygw`` on a Linux # generate a simple configuration file sudo python -m p4p.gw --example-config /etc/pvagw/mygw.conf - # generate a systemd unit file to support the gateway + # generate a systemd unit file template to support the gateway sudo python -m p4p.gw --example-systemd \ /etc/systemd/system/pvagw@.service # start the gateway diff --git a/src/p4p/gw.py b/src/p4p/gw.py index fca7b33..f4291ef 100644 --- a/src/p4p/gw.py +++ b/src/p4p/gw.py @@ -745,21 +745,28 @@ def main(args=None): args = getargs().parse_args(args) catfile = None + I = '%i' + conf = '/etc/pvagw/%i.conf' if args.example_config: catfile = 'example.conf' + I = os.path.splitext(os.path.basename(args.config))[0] + conf = os.path.abspath(args.config) elif args.example_systemd: catfile = 'pvagw@.service' + inst = os.path.splitext(os.path.basename(args.config))[0].split('@') + if len(inst) == 2 and inst[1]: + I = inst[1] + conf = '/etc/pvagw/{0}.conf'.format(I) if catfile is not None: if args.config=='-': O = sys.stdout - I = '%i' - conf = '/etc/pvagw/%i.conf' - print('# eg. save as /etc/systemd/system/pvagw@.service', file=sys.stderr) + if args.example_config: + print('# eg. save as /etc/pvagw/.conf', file=sys.stderr) + elif args.example_systemd: + print('# eg. save as /etc/systemd/system/pvagw@.service', file=sys.stderr) else: O = open(args.config, 'w') - I = os.path.splitext(os.path.basename(args.config))[0] - conf = os.path.abspath(args.config) pythonpath=os.environ.get('PYTHONPATH','').split(os.pathsep) modroot = os.path.dirname(os.path.dirname(__file__)) # directory containing p4p/gw.py