Add dev init script with auto-created admin user (admin/admin) on first boot
This commit is contained in:
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
# Mattermost init script — creates admin user on first boot.
|
||||
# This is mounted into the container and replaces the default command.
|
||||
|
||||
set -e
|
||||
|
||||
# Start Mattermost server in the background.
|
||||
/entrypoint.sh mattermost server &
|
||||
MM_PID=$!
|
||||
|
||||
# Wait for the server to be ready.
|
||||
echo "init: waiting for Mattermost to start..."
|
||||
for i in $(seq 1 30); do
|
||||
if curl -sf http://localhost:8065/api/v4/system/ping > /dev/null 2>&1; then
|
||||
echo "init: Mattermost is ready"
|
||||
break
|
||||
fi
|
||||
if [ "$i" = "30" ]; then
|
||||
echo "init: Mattermost failed to start within 60s"
|
||||
exit 1
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Create admin user (idempotent — ignores if already exists).
|
||||
echo "init: creating admin user..."
|
||||
/mattermost/bin/mattermost user create \
|
||||
--email admin@example.com \
|
||||
--username admin \
|
||||
--password admin \
|
||||
--system_admin 2>/dev/null && echo "init: admin user created" \
|
||||
|| echo "init: admin user already exists (or creation skipped)"
|
||||
|
||||
# Bring Mattermost to the foreground.
|
||||
wait $MM_PID
|
||||
Reference in New Issue
Block a user