Some checks failed
Docker Build & Push SugarCRM 6.5 CE / build-and-push (push) Has been cancelled
- PHP 5.6 Apache Dockerfile (Debian Jessie, archive repos) - Source from bklein01/sugarcrm GitHub mirror - MySQL 5.7 database with healthcheck - Silent install via init.sh (AdminWizard disabled) - REST v4.1 API test script (test_api.py) - Gitea Actions CI/CD for registry push - Full README with API docs and pitfall notes
42 lines
991 B
Python
42 lines
991 B
Python
#!/usr/bin/env python
|
|
import os, sys, getopt
|
|
from string import Template
|
|
|
|
def main(argv):
|
|
inputfile = ''
|
|
outputfile = ''
|
|
try:
|
|
opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])
|
|
except getopt.GetoptError:
|
|
print 'envtemplate.py -i <inputfile> -o <outputfile>'
|
|
sys.exit(2)
|
|
for opt, arg in opts:
|
|
if opt == '-h':
|
|
print 'envtemplate.py -i <inputfile> -o <outputfile>'
|
|
sys.exit()
|
|
elif opt in ("-i", "--ifile"):
|
|
inputfile = arg
|
|
elif opt in ("-o", "--ofile"):
|
|
outputfile = arg
|
|
|
|
# Populate case-insensitive env var dictionary
|
|
values = dict()
|
|
for k in os.environ:
|
|
v = os.environ.get(k)
|
|
values[k] = v
|
|
values[k.lower()] = v
|
|
|
|
# Read template and substitute
|
|
with open(inputfile) as f:
|
|
templatestr = f.read()
|
|
|
|
out = Template(templatestr).substitute(values)
|
|
|
|
print "Writing output to {}".format(outputfile)
|
|
|
|
with open(outputfile, "w") as f:
|
|
f.write(out)
|
|
|
|
if __name__ == "__main__":
|
|
main(sys.argv[1:])
|