Create/promote the ADMIN_EMAIL account on every start, before the seeds, so the public admin@claper.co/claper default is never created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.1 KiB
Bash
30 lines
1.1 KiB
Bash
# Set any config versions here
|
|
# Docs: https://docs.coopcloud.tech/maintainers/handbook/#manage-configs
|
|
export ABRA_ENTRYPOINT_VERSION=v1
|
|
export PG_BACKUP_VERSION=v1
|
|
export BOOTSTRAP_ADMIN_VERSION=v1
|
|
|
|
# Reset the password of the ADMIN_EMAIL account to the admin_pass secret.
|
|
# Usage: abra app cmd <app-name> app set_admin_password
|
|
set_admin_password() {
|
|
/app/bin/claper rpc '
|
|
email = System.get_env("ADMIN_EMAIL", "") |> String.trim()
|
|
pw = File.read!("/run/secrets/admin_pass") |> String.trim()
|
|
case email != "" && Claper.Accounts.get_user_by_email(email) do
|
|
false -> IO.puts("ADMIN_EMAIL is not set, nothing to do")
|
|
nil -> IO.puts("#{email} does not exist, nothing to do")
|
|
user ->
|
|
{:ok, _} = Claper.Accounts.reset_user_password(user, %{password: pw, password_confirmation: pw})
|
|
IO.puts("Password of #{email} updated")
|
|
end
|
|
'
|
|
}
|
|
|
|
# Run pending database migrations and seeds by hand. They also run on every
|
|
# container start.
|
|
# Usage: abra app cmd <app-name> app migrate
|
|
migrate() {
|
|
. /abra-entrypoint.sh -e
|
|
/app/bin/claper eval 'Claper.Release.migrate(); Claper.Release.seeds()'
|
|
}
|