from pathlib import Path
from datetime import datetime
p=Path('/var/www/config/ampache.cfg.php')
s=p.read_text()
bak=p.with_name(p.name + '.bak.http-auth.' + datetime.now().strftime('%Y%m%d%H%M%S'))
bak.write_text(s)
if 'auth_methods = "http,mysql"' not in s:
    s=s.replace('auth_methods = "mysql"', 'auth_methods = "http,mysql"')
if 'auto_create = "true"' not in s:
    s=s.replace(';auto_create = "true"', 'auto_create = "true"')
p.write_text(s)
print(f'backup={bak}')
