Skip to content

Commit

Permalink
sync mysql data and create user
Browse files Browse the repository at this point in the history
  • Loading branch information
drscream committed Aug 11, 2014
1 parent 2c06bb0 commit 090fea9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion copy/var/zoneinit/includes/50-kumquat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ mdata-put mysql_kumquat_pw "${MYSQL_KUMQUAT}"
ALLOWED_HOST=$(hostname)
SECRET_KEY=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-100})

ADMIN_KUMQUAT=${ADMIN_KUMQUAT:-$(mdata-get kumquat_admin 2>/dev/null)} || \
ADMIN_KUMQUAT=$(od -An -N8 -x /dev/random | head -1 | tr -d ' ');

# check if database exists already
if [ -d /var/mysql/kumquat ]; then
echo 'Database already exists, maybe some migration script will run in the future.'
Expand Down Expand Up @@ -41,7 +44,7 @@ cat >> /opt/kumquat/kumquat_web/settings.py <<EOF
# Make this unique, and don't share it with anybody.
SECRET_KEY = "${SECRET_KEY}"
# Allow only the hostname and localhost to access
# Allow only the hostname and localhost to access
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '${ALLOWED_HOST}']
# Database
Expand Down Expand Up @@ -72,3 +75,10 @@ KUMQUAT_USE_ZFS = ${USE_ZFS}
KUMQUAT_VHOST_DATASET = "${VHOST_DATASET}"
KUMQUAT_WEBSERVER_RELOAD = 'svcadm refresh apache'
EOF

# Init django data and create admin user
/opt/kumquat/manage.py syncdb --noinput

# Create superadmin user
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', admin@example.com', '${ADMIN_KUMQUAT}')" \
| /opt/kumquat/manage.py shell

0 comments on commit 090fea9

Please sign in to comment.