mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 09:04:12 +02:00
clenaup bootstrap a bit
This commit is contained in:
parent
07c0f477e1
commit
666b58a773
5 changed files with 97 additions and 109 deletions
|
|
@ -1,39 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
NGINX_CONFIG="$1"
|
|
||||||
FPM_CONFIG="$2"
|
|
||||||
|
|
||||||
shadow-setup
|
|
||||||
|
|
||||||
chmod +sx /sbin/sudo
|
|
||||||
|
|
||||||
echo "nginx: $NGINX_CONFIG"
|
|
||||||
echo "fpm: $FPM_CONFIG"
|
|
||||||
|
|
||||||
mkdir -p /var/log/nginx /tmp
|
|
||||||
touch /var/log/nginx/access.log
|
|
||||||
touch /var/log/nginx/error.log
|
|
||||||
|
|
||||||
tail --follow --retry /var/log/nginx/*.log &
|
|
||||||
|
|
||||||
HAZE_UID=${HAZE_UID:-1000}
|
|
||||||
HAZE_GID=${HAZE_GID:-1000}
|
|
||||||
|
|
||||||
if [ "$(getent group "$HAZE_GID")" ]; then
|
|
||||||
groupadd haze
|
|
||||||
EXTRA_GROUP=" -G haze"
|
|
||||||
else
|
|
||||||
groupadd -g "$HAZE_GID" haze
|
|
||||||
EXTRA_GROUP=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
useradd -m -u "$HAZE_UID" -g "$HAZE_GID""$EXTRA_GROUP" haze
|
|
||||||
chown -R haze:"$HAZE_GID" /home/haze
|
|
||||||
|
|
||||||
if [ -f "/var/run/docker.sock" ]; then
|
|
||||||
groupadd docker -g "$(stat --format "%g" /var/run/docker.sock)"
|
|
||||||
usermod -a -G docker haze
|
|
||||||
fi
|
|
||||||
|
|
||||||
php-fpm --fpm-config "$FPM_CONFIG" &
|
|
||||||
nginx -c "$NGINX_CONFIG"
|
|
||||||
|
|
@ -4,32 +4,12 @@ touch /var/log/nginx/access.log
|
||||||
touch /var/log/nginx/error.log
|
touch /var/log/nginx/error.log
|
||||||
touch /var/log/cron/owncloud.log
|
touch /var/log/cron/owncloud.log
|
||||||
|
|
||||||
cp /etc/nc/config.php /var/www/html/config/config.php
|
|
||||||
chmod 0755 /var/www/html/config/config.php
|
|
||||||
|
|
||||||
if [ "$SQL" = "mysql" ]
|
|
||||||
then
|
|
||||||
cp /etc/nc/autoconfig_mysql.php /var/www/html/config/autoconfig.php
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$SQL" = "mariadb" ]
|
|
||||||
then
|
|
||||||
cp /etc/nc/autoconfig_mariadb.php /var/www/html/config/autoconfig.php
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$SQL" = "pgsql" ]
|
|
||||||
then
|
|
||||||
cp /etc/nc/autoconfig_pgsql.php /var/www/html/config/autoconfig.php
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$SQL" = "oci" ]
|
|
||||||
then
|
|
||||||
cp /etc/nc/autoconfig_oci.php /var/www/html/config/autoconfig.php
|
|
||||||
fi
|
|
||||||
|
|
||||||
HAZE_UID=${HAZE_UID:-www-data}
|
HAZE_UID=${HAZE_UID:-www-data}
|
||||||
HAZE_GID=${HAZE_GID:-www-data}
|
HAZE_GID=${HAZE_GID:-www-data}
|
||||||
|
|
||||||
|
nc-auto-config
|
||||||
|
shadow-setup
|
||||||
|
|
||||||
echo "Running as $HAZE_UID:$HAZE_GID"
|
echo "Running as $HAZE_UID:$HAZE_GID"
|
||||||
|
|
||||||
mkdir -p /var/www/html/core/skeleton /var/www/html/build/integration/vendor /var/www/html/build/integration/output /var/www/html/build/integration/work /var/www/html/core/skeleton /var/www/.composer/cache /var/www/html/apps/spreed/tests/integration/vendor/composer
|
mkdir -p /var/www/html/core/skeleton /var/www/html/build/integration/vendor /var/www/html/build/integration/output /var/www/html/build/integration/work /var/www/html/core/skeleton /var/www/.composer/cache /var/www/html/apps/spreed/tests/integration/vendor/composer
|
||||||
|
|
@ -40,58 +20,33 @@ echo "{}" > /var/www/html/build/integration/composer.lock
|
||||||
|
|
||||||
echo "Starting server using $SQL database…"
|
echo "Starting server using $SQL database…"
|
||||||
|
|
||||||
tail --follow --retry /var/log/nginx/*.log /var/log/cron/owncloud.log &
|
# tail --follow --retry /var/log/nginx/*.log /var/log/cron/owncloud.log &
|
||||||
|
|
||||||
if [ -n "${S3:-}" ]
|
chmod +sx /sbin/sudo
|
||||||
then
|
|
||||||
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/s3.php' /var/www/html/config/config.php
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${S3MB:-}" ]
|
mkdir -p /var/log/nginx /tmp /var/run/blackfire
|
||||||
then
|
touch /var/log/nginx/access.log
|
||||||
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/s3mb.php' /var/www/html/config/config.php
|
touch /var/log/nginx/error.log
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${S3M:-}" ]
|
HAZE_UID=${HAZE_UID:-1000}
|
||||||
then
|
HAZE_GID=${HAZE_GID:-1000}
|
||||||
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/s3m.php' /var/www/html/config/config.php
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${SWIFT:-}" ]
|
if [ "$(getent group "$HAZE_GID")" ]; then
|
||||||
then
|
groupadd haze
|
||||||
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/swift.php' /var/www/html/config/config.php
|
EXTRA_GROUP=" -G haze"
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${SWIFTV3:-}" ]
|
|
||||||
then
|
|
||||||
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/swiftv3.php' /var/www/html/config/config.php
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${AZURE:-}" ]
|
|
||||||
then
|
|
||||||
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/azure.php' /var/www/html/config/config.php
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${REDIS_TLS:-}" ]
|
|
||||||
then
|
|
||||||
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/redis-tls.php' /var/www/html/config/config.php
|
|
||||||
else
|
else
|
||||||
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/redis-default.php' /var/www/html/config/config.php
|
groupadd -g "$HAZE_GID" haze
|
||||||
|
EXTRA_GROUP=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${BLACKFIRE_SERVER_ID:-}" ]
|
useradd -u "$HAZE_UID" -g "$HAZE_GID""$EXTRA_GROUP" haze
|
||||||
then
|
chown -R haze:"$HAZE_GID" /home/haze
|
||||||
sh -c '
|
|
||||||
yes | blackfire agent:config --server-id=$BLACKFIRE_SERVER_ID --server-token=$BLACKFIRE_SERVER_TOKEN
|
if [ -f "/var/run/docker.sock" ]; then
|
||||||
mkdir /var/run/blackfire/
|
groupadd docker -g "$(stat --format "%g" /var/run/docker.sock)"
|
||||||
BLACKFIRE_LOG_LEVEL=4 BLACKFIRE_LOG_FILE=/var/log/agent.log blackfire agent &
|
usermod -a -G docker haze
|
||||||
'&
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# crontab /etc/oc-cron.conf
|
|
||||||
|
|
||||||
# crond -f & # todo
|
|
||||||
|
|
||||||
if [ -n "${REDIS_TLS:-}" ]
|
if [ -n "${REDIS_TLS:-}" ]
|
||||||
then
|
then
|
||||||
redis-server --protected-mode no \
|
redis-server --protected-mode no \
|
||||||
|
|
@ -103,4 +58,14 @@ else
|
||||||
redis-server --protected-mode no &
|
redis-server --protected-mode no &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bootstrap-nginx "$@"
|
if [ -n "${BLACKFIRE_SERVER_ID:-}" ]
|
||||||
|
then
|
||||||
|
sh -c '
|
||||||
|
yes | blackfire agent:config --server-id=$BLACKFIRE_SERVER_ID --server-token=$BLACKFIRE_SERVER_TOKEN
|
||||||
|
BLACKFIRE_LOG_LEVEL=4 BLACKFIRE_LOG_FILE=/var/log/agent.log blackfire agent &
|
||||||
|
'&
|
||||||
|
fi
|
||||||
|
|
||||||
|
php-fpm --fpm-config /etc/php-fpm.conf&
|
||||||
|
|
||||||
|
nginx -c /etc/nginx.conf
|
||||||
|
|
@ -7,4 +7,6 @@ runCommand "configs" {} ''
|
||||||
cp ${./configs/nginx-app.conf} $out/conf/nginx-app.conf
|
cp ${./configs/nginx-app.conf} $out/conf/nginx-app.conf
|
||||||
cp ${./configs/sudoers} $out/etc/sudoers.d/haze
|
cp ${./configs/sudoers} $out/etc/sudoers.d/haze
|
||||||
cp -r ${./configs/nc} $out/etc/nc
|
cp -r ${./configs/nc} $out/etc/nc
|
||||||
|
cp ${./php-fpm.conf} $out/etc/php-fpm.conf
|
||||||
|
cp ${./nginx.conf} $out/etc/nginx.conf
|
||||||
''
|
''
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,6 @@
|
||||||
phpVersion = concatStringsSep "." (take 2 (splitString "." php.version));
|
phpVersion = concatStringsSep "." (take 2 (splitString "." php.version));
|
||||||
phpEnv = callPackage ./php.nix {inherit debug php;};
|
phpEnv = callPackage ./php.nix {inherit debug php;};
|
||||||
|
|
||||||
bootstrap-nginx = writeShellApplication {
|
|
||||||
name = "bootstrap-nginx";
|
|
||||||
text = readFile ./bootstrap-nginx.sh;
|
|
||||||
};
|
|
||||||
bootstrap = writeShellApplication {
|
bootstrap = writeShellApplication {
|
||||||
name = "bootstrap";
|
name = "bootstrap";
|
||||||
runtimeInputs = [getent];
|
runtimeInputs = [getent];
|
||||||
|
|
@ -169,7 +165,6 @@ in
|
||||||
fromImage = phpImage;
|
fromImage = phpImage;
|
||||||
contents = [
|
contents = [
|
||||||
tmpDir
|
tmpDir
|
||||||
bootstrap-nginx
|
|
||||||
bootstrap
|
bootstrap
|
||||||
configs
|
configs
|
||||||
scripts
|
scripts
|
||||||
|
|
@ -187,7 +182,7 @@ in
|
||||||
chmod -R 0755 etc/nc
|
chmod -R 0755 etc/nc
|
||||||
'';
|
'';
|
||||||
config = {
|
config = {
|
||||||
Cmd = [(getExe bootstrap) ./nginx.conf ./php-fpm.conf];
|
Cmd = getExe bootstrap;
|
||||||
Env = ["EDITOR=hx" "WEBROOT=/var/www/html"];
|
Env = ["EDITOR=hx" "WEBROOT=/var/www/html"];
|
||||||
WorkingDir = "/var/www/html";
|
WorkingDir = "/var/www/html";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
65
nix/image/scripts/nc-auto-config
Executable file
65
nix/image/scripts/nc-auto-config
Executable file
|
|
@ -0,0 +1,65 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
touch /var/log/nginx/access.log
|
||||||
|
touch /var/log/nginx/error.log
|
||||||
|
touch /var/log/cron/owncloud.log
|
||||||
|
|
||||||
|
cp /etc/nc/config.php /var/www/html/config/config.php
|
||||||
|
chmod 0755 /var/www/html/config/config.php
|
||||||
|
|
||||||
|
if [ "$SQL" = "mysql" ]
|
||||||
|
then
|
||||||
|
cp /etc/nc/autoconfig_mysql.php /var/www/html/config/autoconfig.php
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SQL" = "mariadb" ]
|
||||||
|
then
|
||||||
|
cp /etc/nc/autoconfig_mariadb.php /var/www/html/config/autoconfig.php
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SQL" = "pgsql" ]
|
||||||
|
then
|
||||||
|
cp /etc/nc/autoconfig_pgsql.php /var/www/html/config/autoconfig.php
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SQL" = "oci" ]
|
||||||
|
then
|
||||||
|
cp /etc/nc/autoconfig_oci.php /var/www/html/config/autoconfig.php
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${S3:-}" ]
|
||||||
|
then
|
||||||
|
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/s3.php' /var/www/html/config/config.php
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${S3MB:-}" ]
|
||||||
|
then
|
||||||
|
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/s3mb.php' /var/www/html/config/config.php
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${S3M:-}" ]
|
||||||
|
then
|
||||||
|
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/s3m.php' /var/www/html/config/config.php
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${SWIFT:-}" ]
|
||||||
|
then
|
||||||
|
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/swift.php' /var/www/html/config/config.php
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${SWIFTV3:-}" ]
|
||||||
|
then
|
||||||
|
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/swiftv3.php' /var/www/html/config/config.php
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${AZURE:-}" ]
|
||||||
|
then
|
||||||
|
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/azure.php' /var/www/html/config/config.php
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${REDIS_TLS:-}" ]
|
||||||
|
then
|
||||||
|
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/redis-tls.php' /var/www/html/config/config.php
|
||||||
|
else
|
||||||
|
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/redis-default.php' /var/www/html/config/config.php
|
||||||
|
fi
|
||||||
Loading…
Add table
Add a link
Reference in a new issue