#!/bin/nu touch /var/log/nginx/access.log touch /var/log/nginx/error.log touch /var/log/cron/owncloud.log mkdir /config if not ("/config/php.ini" | path exists) { echo "# Options in here overwrite the builtin php.ini\n" | save /config/php.ini echo "# xdebug.mode = debug\n" | save -a /config/php.ini echo "# xdebug.start_with_request = yes\n\n" | save -a /config/php.ini } chmod 0777 /config/php.ini let PHP_INI_DIR = php --ini | grep 'Scan' | cut -d ' ' -f7 | tr -d '"' ln -sf /config/php.ini $"($PHP_INI_DIR)/zz_extra.ini" let HAZE_UID = $env.HAZE_UID | default "1000" let HAZE_GID = $env.HAZE_GID | default "1000" nc-auto-config shadow-setup echo $"Running as ($HAZE_UID):($HAZE_GID)" let dirs = [ ["condition", "path"]; ["/", "/var/www/html/data"], ["/", "/var/www/html/config"], ["/", "/var/www/html/build/integration/vendor"], ["/", "/var/www/html/build/integration/output"], ["/", "/var/www/html/build/integration/work"], ["/var/www/html/apps/spreed", "/var/www/html/apps/spreed/tests/integration/vendor/composer"], ]; let files = [ ["condition", "path"]; ["/", "/var/www/html/build/integration/composer.lock"], ] $dirs | each { |dir| if ($dir.condition | path exists) { mkdir $dir.path } } $files | each { |file| if ($file.condition | path exists) { touch $file.path } } $dirs | append $files | each { |item| if ($item.path | path exists) { chown -R $"($HAZE_UID):($HAZE_GID)" $item.path } } echo "{}\n" | save -f /var/www/html/build/integration/composer.lock echo $"Starting server using ($env.SQL) database…" chmod +sx /sbin/sudo mkdir /var/log/nginx /tmp /var/run/blackfire touch /var/log/nginx/access.log touch /var/log/nginx/error.log if ((getent group "haze" | length) == 0) { if ((getent group $HAZE_GID | length) > 0) { groupadd haze useradd -u $HAZE_UID -g $HAZE_GID -G haze haze } else { groupadd -g $HAZE_GID haze useradd -u $HAZE_UID -g $HAZE_GID haze } } chown -R $"haze:($HAZE_GID)" /home/haze ls -af /etc/home | each {|file| ln -sf $file.name $"/home/haze/($file.name | path basename)" } if ("/var/run/docker.sock" | path exists) { let dockerGid = stat --format "%g" /var/run/docker.sock if ((getent group "docker" | length) == 0) { groupadd docker -g $dockerGid } usermod -a -G docker haze } if ("REDIS_TLS" in $env) { cp /etc/supervisor/redis-tls.conf /etc/supervisor/enabled/ } else { cp /etc/supervisor/redis-plain.conf /etc/supervisor/enabled/ } if ("BLACKFIRE_SERVER_ID" in $env) { blackfire agent:config --server-id $env.BLACKFIRE_SERVER_ID --server-token $env.BLACKFIRE_SERVER_TOKEN cp /etc/supervisor/blackfire.conf /etc/supervisor/enabled/ } if ("PROXY_BASE" in $env) { let UPSTREAM_DNS = cat /etc/resolv.conf | grep nameserver | cut -d' ' -f 2 let RC = sed '/nameserver/d' /etc/resolv.conf echo $RC | save -f /etc/resolv.conf echo "\nnameserver 127.0.0.22\n" | save -a /etc/resolv.conf echo $"s/UPSTREAM_DNS/($UPSTREAM_DNS)" sed -i $"s/UPSTREAM_DNS/($UPSTREAM_DNS)/" /etc/dnsmasq.conf echo $"s/PROXY_BASE/($env.PROXY_BASE)" sed -i $"s/PROXY_BASE/($env.PROXY_BASE)/" /etc/dnsmasq.conf echo $"s/HOST_IP/($env.HOST_IP)" sed -i $"s/HOST_IP/($env.HOST_IP)/" /etc/dnsmasq.conf cp /etc/supervisor/dnsmasq.conf /etc/supervisor/enabled/ } if ("FRANKENPHP" in $env) { cp /etc/supervisor/frankenphp.conf /etc/supervisor/enabled/ } else { cp /etc/supervisor/php-fpm.conf /etc/supervisor/enabled/ cp /etc/supervisor/nginx.conf /etc/supervisor/enabled/ } exec supervisord -c /etc/supervisor/supervisord.conf