#!/bin/bash set -eu if ! [ -e "/app/data/nginx.conf" ]; then cp -a "/app/code/nginx.conf.default" "/app/data/nginx.conf" fi if ! [ -e "/app/data/config.sh" ]; then cp -a "/app/code/config.sh.default" "/app/data/config.sh" fi if ! [ -e "/app/data/ssh" ]; then mkdir -p /app/data/ssh cp /app/code/ssh.config.default /app/data/ssh/config ssh-keygen -f /app/data/ssh/id_rsa -q -N "" fi if ! [ -e "/app/data/token.txt" ]; then token="$(pwgen 20 1)" echo "$token" > /app/data/token.txt fi if ! [ -e "/app/data/htpasswd" ]; then token="$(cat /app/data/token.txt)" echo "$token" > /app/data/token.txt htpasswd -bc /app/data/htpasswd token "$token" fi chown -R cloudron:cloudron /app/data cp -a "/app/code/public.default" "/run/html" token="$(cat /app/data/token.txt)" sed -i -e "s/%TOKEN%/$token/g" /run/html/index.html ssh_key="$(cat /app/data/ssh/id_rsa.pub | sed 's/\//\\\//g')" sed -i -e "s/%SSH_KEY%/$ssh_key/g" /run/html/index.html chown cloudron:cloudron /run/html /run export HOME=/app/data exec /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i Zola