Last active
August 29, 2015 14:14
-
-
Save juliedavila/030cac374f8ead59c543 to your computer and use it in GitHub Desktop.
Convert sudo to su for installer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parser.add_option('--no-sudo', dest='nosudo', default=False, action='store_true') | |
if cli_opts.nosudo: | |
replacements = { | |
'sudo: True' : 'su: True', | |
'sudo: true' : 'su: True', | |
'sudo: yes' : 'su: True', | |
'sudo: no' : 'su: no', | |
'sudo_user: awx' : '', | |
'sudo_user: postgres' : '', | |
'sudo cp' : 'cp', | |
'--sudo' : '--su' | |
} | |
installer_root = os.getcwd() | |
for dname, dirs, files in os.walk(installer_root): | |
for fname in files: | |
fpath = os.path.join(dname, fname) | |
if fpath != (installer_root + 'configure'): | |
with open(fpath) as f: | |
s = f.read() | |
for pattern, replacement in replacements.iteritems(): | |
s = s.replace(pattern, replacement) | |
with open(fpath, "w") as f: | |
f.write(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment