Merge remote-tracking branch 'origin/sheepdogtestbed'
[slapos.git] / software / zencart / configure.py
1 import sys
2 import os
3 import fileinput
4
5 def setup(args):
6 mysql_port, mysql_host, mysql_user, mysql_password, mysql_database, base_url, htdocs = args
7
8 admin_dir = "admin-" + mysql_user
9 admin_include_file = os.path.join(htdocs, admin_dir + "/includes/configure.php")
10 searchPattern = "/admin"
11 replacePattern = "/" + admin_dir
12 os.chmod(admin_include_file, 0744)
13 for line in fileinput.input(admin_include_file, inplace=1):
14 if searchPattern in line:
15 line = line.replace(searchPattern, replacePattern)
16 sys.stdout.write(line)
17 os.chmod(admin_include_file, 0444)
18
19 if __name__ == '__main__':
20 setup(sys.argv[1:])