Changeset 614fd92 in rattail-fabric2
- Timestamp:
- 11/01/2022 06:41:27 PM (3 months ago)
- Branches:
- master
- Children:
- 46440b6
- Parents:
- a2dca4e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
rattail_fabric2/postfix.py
ra2dca4e r614fd92 3 3 # 4 4 # Rattail -- Retail Software Framework 5 # Copyright © 2010-20 19Lance Edgar5 # Copyright © 2010-2022 Lance Edgar 6 6 # 7 7 # This file is part of Rattail. … … 25 25 """ 26 26 27 import shlex 28 27 29 from rattail_fabric2 import apt 28 30 … … 43 45 if c.run("grep '^{}:' /etc/aliases".format(name), warn=True).failed: 44 46 # append new entry 45 c.sudo("""bash -c 'echo "{}: {}" >> /etc/aliases'""".format(name, alias_to)) 47 entry = '{}: {}'.format(name, alias_to) 48 echo = shlex.join(['echo', entry]) 49 cmd = '{} >> /etc/aliases'.format(echo) 50 cmd = shlex.join(['bash', '-c', cmd]) 51 c.sudo(cmd) 46 52 else: 47 53 # update existing entry 48 c.sudo('sed -i.bak -e "s/^{}: .*/{}: {}/" /etc/aliases'.format(name, name, alias_to)) 54 alias_to = alias_to.replace('|', '\\|') 55 sub = "s|^{}: .*|{}: {}|".format(name, name, alias_to) 56 cmd = shlex.join(['sed', '-i.bak', '-E', sub, '/etc/aliases']) 57 c.sudo(cmd) 49 58 50 59 c.sudo('newaliases')
Note: See TracChangeset
for help on using the changeset viewer.