mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-02 05:44:03 +02:00
Create default user
https://github.com/alexbelgium/hassio-addons/issues/528
This commit is contained in:
@@ -1,11 +1,37 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
#!/usr/bin/with-contenv bashio
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
# Staring redis
|
#################
|
||||||
|
# Staring redis #
|
||||||
|
#################
|
||||||
exec redis-server & bashio::log.info "Starting redis"
|
exec redis-server & bashio::log.info "Starting redis"
|
||||||
|
|
||||||
# Avoid overcommit memory
|
###########################
|
||||||
|
# Avoid overcommit memory #
|
||||||
|
###########################
|
||||||
bashio::log.info "Avoid overcommit memory"
|
bashio::log.info "Avoid overcommit memory"
|
||||||
sysctl vm.overcommit_memory=1
|
sysctl vm.overcommit_memory=1
|
||||||
|
|
||||||
|
###############################
|
||||||
|
# Create user if not existing #
|
||||||
|
###############################
|
||||||
|
# Origin : https://github.com/linuxserver/docker-paperless-ngx/blob/main/root/etc/cont-init.d/99-migrations
|
||||||
|
bashio::log.info "Creating default user"
|
||||||
|
cat << EOF | python3 /app/paperless/src/manage.py shell
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
|
# see ref. below
|
||||||
|
UserModel = get_user_model()
|
||||||
|
|
||||||
|
if len(UserModel.objects.all()) == 1:
|
||||||
|
print("Creating new user")
|
||||||
|
user = UserModel.objects.create_user('admin', password='admin')
|
||||||
|
user.is_superuser = True
|
||||||
|
user.is_staff = True
|
||||||
|
user.save()
|
||||||
|
EOF
|
||||||
|
|
||||||
|
#########
|
||||||
|
# Start #
|
||||||
|
#########
|
||||||
bashio::log.info "Initial username and password are admin. Please change in the administration panel of the webUI after login."
|
bashio::log.info "Initial username and password are admin. Please change in the administration panel of the webUI after login."
|
||||||
|
|||||||
Reference in New Issue
Block a user