diff --git a/.env.example b/.env.example
new file mode 100644
index 0000000..07d1d0f
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,18 @@
+# How long a user stays signed in, in seconds
+SESSION_LIFETIME=86400
+
+# Whether to use the 'Secure' attribute on the session cookie
+USE_SECURE=true
+
+# Set to true if you're running this behing a reverse proxy (you should, given there is no built-in SSL support)
+USE_REVERSE_PROXY=true
+
+# Name of the header containing the request's emitter's IP adress. No effect is USE_REVERSE_PROXY is false.
+REAL_IP_HEADER=X-Forwarded-For
+
+# Uncomment to choose your own default admin password (you should change it afterwards regardless)
+# Else, a random one will be generated and printed to logs and written to ./data/default_admin_pass.txt
+# DEFAULT_ADMIN_PASS=changeme
+
+# Prefix for the tabs' titles
+PUBLIC_SITE_NAME=WOL Panel
diff --git a/src/hooks.server.ts b/src/hooks.server.ts
index b46c511..f4ad403 100644
--- a/src/hooks.server.ts
+++ b/src/hooks.server.ts
@@ -1,3 +1,4 @@
+import { env } from '$env/dynamic/private';
import { initRepos, users } from '$lib/server/db';
import { Guard } from '$lib/server/guard';
import { getUserFromSession } from '$lib/server/sessions';
@@ -10,7 +11,16 @@ export const init: ServerInit = async () => {
await initRepos();
if (!(await users.any())) {
- const pass = nanoid();
+ let pass = env.DEFAULT_ADMIN_PASS;
+
+ if (!pass) {
+ pass = nanoid();
+
+ console.log(`default admin password: ${pass}`);
+ console.log("saved to ./default_admin_pass.txt, don't share it and change it asap");
+
+ writeFileSync('./data/default_admin_pass.txt', pass);
+ }
await users.create({
name: 'admin',
@@ -19,11 +29,6 @@ export const init: ServerInit = async () => {
groups: [],
devices: [],
});
-
- console.log(`default admin password: ${pass}`);
- console.log("saved to ./default_admin_pass.txt, don't share it and change it asap");
-
- writeFileSync('./data/default_admin_pass.txt', pass);
}
};
diff --git a/src/routes/dash/+layout.svelte b/src/routes/dash/+layout.svelte
index 7ab4a52..bc2314e 100644
--- a/src/routes/dash/+layout.svelte
+++ b/src/routes/dash/+layout.svelte
@@ -1,5 +1,6 @@