from pathlib import Path import subprocess app=Path('/home/dunerealms/apps/oscommerce') sql="""CREATE TABLE IF NOT EXISTS dunerealms_oscommerce.dune_account_links(account_id CHAR(36) PRIMARY KEY,customer_id INT NOT NULL UNIQUE); CREATE TABLE IF NOT EXISTS dunerealms_oscommerce.dune_sso_states(state_hash CHAR(64) PRIMARY KEY,nonce_hash CHAR(64) NOT NULL,next_path VARCHAR(2048) NOT NULL,expires_at BIGINT NOT NULL); CREATE TABLE IF NOT EXISTS dunerealms_oscommerce.dune_sso_sessions(token_hash CHAR(64) PRIMARY KEY,account_id CHAR(36) NOT NULL,session_ref CHAR(64) NOT NULL,expires_at BIGINT NOT NULL); """ subprocess.run(['mysql'],input=sql,text=True,capture_output=True,check=True) entry=app/'lib/frontend/web/index.php';s=entry.read_text() if 'DuneAccount' not in s:s=s.replace('$application->run();',"require __DIR__.'/../components/DuneAccount.php';\n(new \\frontend\\components\\DuneAccount())->bootstrap($application);\n$application->run();") entry.write_text(s) (app/'dune-login.php').write_text("