diff --git a/README.md b/README.md index a1c54886..42e51dbb 100644 --- a/README.md +++ b/README.md @@ -232,7 +232,7 @@ Do not install the [Clusterio mod](https://mods.factorio.com/mod/clusterio), thi ## Running Clusterio -After completing the installation start up the controller and at least one host separately. +After completing the installation and creating your admin user, start up the controller and at least one host separately. The installer provides the `run-controller` and `run-host` scripts to make this simple. Once the controller process is running you can log into the web interface which is hosted by default on http://localhost:8080/ (adjust the port number if you changed it), use the admin authentication token provided from the installation to log in. diff --git a/packages/controller/controller.ts b/packages/controller/controller.ts index e4299534..c83b3d30 100644 --- a/packages/controller/controller.ts +++ b/packages/controller/controller.ts @@ -281,6 +281,7 @@ async function initialize(): Promise { type: "boolean", nargs: 0, default: false, describe: "Start the controller in recovery mode with all plugins disabled and hosts disconnected", }); + yargs.option("check-user-count", { hidden: true, type: "boolean", nargs: 0, default: true }); yargs.option("dev", { hidden: true, type: "boolean", nargs: 0 }); yargs.option("dev-plugin", { hidden: true, type: "array" }); }) @@ -417,6 +418,14 @@ async function startup() { ...await Controller.bootstrap(controllerConfig) ); + // Refuse to start if there are no users loaded + if (args.checkUserCount && controller.userManager.users.size === 0) { + logger.fatal( + "Cannot start controller, no users loaded.\n" + + "Try `npx clusteriocontroller bootstrap create-admin `"); + process.exit(1); + } + let secondSigint = false; process.on("SIGINT", () => { if (secondSigint) {