Commit 7deb0470 authored by Fabien Amarger's avatar Fabien Amarger
Browse files

feat(anon): Create a public instance by default

parent 266ea5e621d7
...@@ -293,8 +293,9 @@ ...@@ -293,8 +293,9 @@
f"creating the instance {args.instance_name}. " f"creating the instance {args.instance_name}. "
f"The parameters are in ~/etc/cubicweb.d/{args.instance_name}/" f"The parameters are in ~/etc/cubicweb.d/{args.instance_name}/"
) )
if "CW_DB_DRIVER" not in os.environ: os.environ.setdefault("CW_DB_DRIVER", "sqlite")
os.environ["CW_DB_DRIVER"] = "sqlite" os.environ.setdefault("CW_ANONYMOUS_USER", "anon")
os.environ.setdefault("CW_ANONYMOUS_PASSWORD", "anon")
create_instance = ( create_instance = (
"cubicweb-ctl create " "cubicweb-ctl create "
f"{args.instance_name} {args.instance_name} -a --no-db-create" f"{args.instance_name} {args.instance_name} -a --no-db-create"
...@@ -313,8 +314,19 @@ ...@@ -313,8 +314,19 @@
with open(source_path, "w") as f: with open(source_path, "w") as f:
f.write(replaced_content) f.write(replaced_content)
db_init = "cubicweb-ctl db-create " f"{args.instance_name} -a --drop=y" if os.environ["CW_ANONYMOUS_USER"]:
run_and_print_if_error(db_init, custom_env=os.environ) all_in_one_path = (
Path.home() / "etc" / "cubicweb.d" / args.instance_name / "all-in-one.conf"
)
all_in_one_content = all_in_one_path.read_text()
all_in_one_path.write_text(
all_in_one_content.replace(
"#anonymous-user=", f"anonymous-user={os.environ['CW_ANONYMOUS_USER']}"
).replace(
"#anonymous-password=",
f"anonymous-password={os.environ['CW_ANONYMOUS_PASSWORD']}",
)
)
run_and_print_if_error(f"black {cube_master_folder}") run_and_print_if_error(f"black {cube_master_folder}")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment