mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 09:04:12 +02:00
migrate scripts to nushell
This commit is contained in:
parent
266b70339b
commit
0a16737398
10 changed files with 148 additions and 190 deletions
87
nix/image/bootstrap
Executable file
87
nix/image/bootstrap
Executable file
|
|
@ -0,0 +1,87 @@
|
||||||
|
#!/bin/nu
|
||||||
|
|
||||||
|
touch /var/log/nginx/access.log
|
||||||
|
touch /var/log/nginx/error.log
|
||||||
|
touch /var/log/cron/owncloud.log
|
||||||
|
|
||||||
|
mkdir /config
|
||||||
|
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 -s /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)"
|
||||||
|
|
||||||
|
mkdir /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
|
||||||
|
chown -R $"($HAZE_UID):($HAZE_GID)" /var/www/html/data /var/www/html/config
|
||||||
|
chown $"($HAZE_UID):($HAZE_GID)" /var/www/html/core/skeleton /var/www/html/build/integration/vendor /var/www/html/build/integration/composer.lock /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
|
||||||
|
|
||||||
|
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_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
|
||||||
|
|
||||||
|
if ("/var/run/docker.sock" | path exists) {
|
||||||
|
let dockerGid = stat --format "%g" /var/run/docker.sock
|
||||||
|
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
|
||||||
|
|
@ -1,94 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
touch /var/log/nginx/access.log
|
|
||||||
touch /var/log/nginx/error.log
|
|
||||||
touch /var/log/cron/owncloud.log
|
|
||||||
|
|
||||||
mkdir -p /config
|
|
||||||
echo "# Options in here overwrite the builtin php.ini" > /config/php.ini
|
|
||||||
echo "# xdebug.mode = debug" >> /config/php.ini
|
|
||||||
echo "# xdebug.start_with_request = yes" >> /config/php.ini
|
|
||||||
chmod 0777 /config/php.ini
|
|
||||||
PHP_INI_DIR="$(php --ini | grep 'Scan' | cut -d ' ' -f7 | tr -d '"')"
|
|
||||||
ln -s /config/php.ini "$PHP_INI_DIR/zz_extra.ini"
|
|
||||||
|
|
||||||
HAZE_UID=${HAZE_UID:-www-data}
|
|
||||||
HAZE_GID=${HAZE_GID:-www-data}
|
|
||||||
|
|
||||||
nc-auto-config
|
|
||||||
shadow-setup
|
|
||||||
|
|
||||||
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
|
|
||||||
chown -R "$HAZE_UID":"$HAZE_GID" /var/www/html/data /var/www/html/config
|
|
||||||
chown "$HAZE_UID":"$HAZE_GID" /var/www/html/core/skeleton /var/www/html/build/integration/vendor /var/www/html/build/integration/composer.lock /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
|
|
||||||
|
|
||||||
echo "{}" > /var/www/html/build/integration/composer.lock
|
|
||||||
|
|
||||||
echo "Starting server using $SQL database…"
|
|
||||||
|
|
||||||
chmod +sx /sbin/sudo
|
|
||||||
|
|
||||||
mkdir -p /var/log/nginx /tmp /var/run/blackfire
|
|
||||||
touch /var/log/nginx/access.log
|
|
||||||
touch /var/log/nginx/error.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 -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
|
|
||||||
|
|
||||||
if [ -n "${REDIS_TLS:-}" ]
|
|
||||||
then
|
|
||||||
cp /etc/supervisor/redis-tls.conf /etc/supervisor/enabled/
|
|
||||||
else
|
|
||||||
cp /etc/supervisor/redis-plain.conf /etc/supervisor/enabled/
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${BLACKFIRE_SERVER_ID:-}" ]
|
|
||||||
then
|
|
||||||
blackfire agent:config --server-id="$BLACKFIRE_SERVER_ID" --server-token="$BLACKFIRE_SERVER_TOKEN"
|
|
||||||
cp /etc/supervisor/blackfire.conf /etc/supervisor/enabled/
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${PROXY_BASE:-}" ]; then
|
|
||||||
UPSTREAM_DNS=$(cat /etc/resolv.conf | grep nameserver | cut -d' ' -f 2)
|
|
||||||
(
|
|
||||||
RC=$(sed '/nameserver/d' /etc/resolv.conf)
|
|
||||||
echo "$RC" > /etc/resolv.conf
|
|
||||||
)
|
|
||||||
echo 'nameserver 127.0.0.22' >> /etc/resolv.conf
|
|
||||||
|
|
||||||
echo "s/UPSTREAM_DNS/${UPSTREAM_DNS}"
|
|
||||||
sed -i "s/UPSTREAM_DNS/${UPSTREAM_DNS}/" /etc/dnsmasq.conf
|
|
||||||
echo "s/PROXY_BASE/${PROXY_BASE}"
|
|
||||||
sed -i "s/PROXY_BASE/${PROXY_BASE}/" /etc/dnsmasq.conf
|
|
||||||
echo "s/HOST_IP/${HOST_IP}"
|
|
||||||
sed -i "s/HOST_IP/${HOST_IP}/" /etc/dnsmasq.conf
|
|
||||||
|
|
||||||
cp /etc/supervisor/dnsmasq.conf /etc/supervisor/enabled/
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${FRANKENPHP:-}" ]; then
|
|
||||||
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/
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec supervisord -c /etc/supervisor/supervisord.conf
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
'redis' => ['host' => 'localhost'],
|
'redis' => ['host' => 'localhost'],
|
||||||
//PLACEHOLDER
|
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,3 @@
|
||||||
'verify_peer_name' => false,
|
'verify_peer_name' => false,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
//PLACEHOLDER
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ logfile = /dev/stdout
|
||||||
logfile_maxbytes = 0
|
logfile_maxbytes = 0
|
||||||
nodaemon = true
|
nodaemon = true
|
||||||
pidfile = /var/run/supervisord.pid
|
pidfile = /var/run/supervisord.pid
|
||||||
|
user = root
|
||||||
|
|
||||||
[unix_http_server]
|
[unix_http_server]
|
||||||
file = /var/run/supervisor.sock
|
file = /var/run/supervisor.sock
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
blackfire,
|
blackfire,
|
||||||
coreutils,
|
coreutils,
|
||||||
getent,
|
getent,
|
||||||
|
writers,
|
||||||
shadow,
|
shadow,
|
||||||
runCommand,
|
runCommand,
|
||||||
callPackage,
|
callPackage,
|
||||||
|
|
@ -44,11 +45,7 @@
|
||||||
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 = writeShellApplication {
|
bootstrap = writers.writeNuBin "bootstrap" (readFile ./bootstrap);
|
||||||
name = "bootstrap";
|
|
||||||
runtimeInputs = [getent];
|
|
||||||
text = readFile ./bootstrap.sh;
|
|
||||||
};
|
|
||||||
shadowSetupScript = writeShellApplication {
|
shadowSetupScript = writeShellApplication {
|
||||||
name = "shadow-setup";
|
name = "shadow-setup";
|
||||||
text = dockerTools.shadowSetup;
|
text = dockerTools.shadowSetup;
|
||||||
|
|
@ -144,6 +141,7 @@
|
||||||
python3Packages.supervisor
|
python3Packages.supervisor
|
||||||
dnsmasq
|
dnsmasq
|
||||||
nushell
|
nushell
|
||||||
|
getent
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,22 @@
|
||||||
#!/bin/sh
|
#!/bin/nu
|
||||||
|
|
||||||
USER=$1
|
def main [username: string, password: string] {
|
||||||
PASSWORD=$2
|
cd $env.WEBROOT;
|
||||||
|
let sql = match $env.SQL {
|
||||||
|
"oracle" => "oci"
|
||||||
|
"mariadb" => "mysql"
|
||||||
|
_ => $env.SQL
|
||||||
|
}
|
||||||
|
let dbName = match $env.SQL {
|
||||||
|
"oracle" => "xe"
|
||||||
|
_ => "haze"
|
||||||
|
}
|
||||||
|
let dbUser = match $env.SQL {
|
||||||
|
"oracle" => "system"
|
||||||
|
_ => "haze"
|
||||||
|
}
|
||||||
|
let dbPass = "haze"
|
||||||
|
let dbHost = $env.SQL
|
||||||
|
|
||||||
if [ -z "$USER" ] || [ -z "$PASSWORD" ]; then
|
occ maintenance:install --admin-user $username --admin-pass $password --database $sql --database-name $dbName --database-host $dbHost --database-user $dbUser --database-pass $dbPass
|
||||||
echo "Usage: install \$USER \$PASSWORD"
|
}
|
||||||
exit;
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $WEBROOT
|
|
||||||
|
|
||||||
if [ "$SQL" = "oracle" ]; then
|
|
||||||
# oracle is a special snowflake
|
|
||||||
occ maintenance:install --admin-user=$USER --admin-pass=$PASSWORD --database=oci --database-name=xe --database-host=$SQL --database-user=system --database-pass=haze
|
|
||||||
elif [ "$SQL" = "mariadb" ]; then
|
|
||||||
occ maintenance:install --admin-user=$USER --admin-pass=$PASSWORD --database=mysql --database-name=haze --database-host=$SQL --database-user=haze --database-pass=haze
|
|
||||||
else
|
|
||||||
occ maintenance:install --admin-user=$USER --admin-pass=$PASSWORD --database=$SQL --database-name=haze --database-host=$SQL --database-user=haze --database-pass=haze
|
|
||||||
fi;
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/bin/nu
|
||||||
|
|
||||||
touch /var/log/nginx/access.log
|
touch /var/log/nginx/access.log
|
||||||
touch /var/log/nginx/error.log
|
touch /var/log/nginx/error.log
|
||||||
|
|
@ -7,64 +7,30 @@ touch /var/log/cron/owncloud.log
|
||||||
cp /etc/nc/config.php /var/www/html/config/config.php
|
cp /etc/nc/config.php /var/www/html/config/config.php
|
||||||
chmod 0755 /var/www/html/config/config.php
|
chmod 0755 /var/www/html/config/config.php
|
||||||
|
|
||||||
if [ "$SQL" = "mysql" ]
|
let configName = match $env.SQL {
|
||||||
then
|
"oracle" => "oci"
|
||||||
cp /etc/nc/autoconfig_mysql.php /var/www/html/config/autoconfig.php
|
_ => $env.SQL
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$SQL" = "mariadb" ]
|
}
|
||||||
then
|
let configPath = $"/etc/nc/autoconfig_($configName).php"
|
||||||
cp /etc/nc/autoconfig_mariadb.php /var/www/html/config/autoconfig.php
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$SQL" = "pgsql" ]
|
if ($configPath | path exists) {
|
||||||
then
|
cp $configPath /var/www/html/config/autoconfig.php
|
||||||
cp /etc/nc/autoconfig_pgsql.php /var/www/html/config/autoconfig.php
|
}
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$SQL" = "oci" ]
|
def loadExtraConfig [name: string] {
|
||||||
then
|
sed -i $'/\/\/PLACEHOLDER/ r /etc/nc/($name).php' /var/www/html/config/config.php
|
||||||
cp /etc/nc/autoconfig_oci.php /var/www/html/config/autoconfig.php
|
}
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${S3:-}" ]
|
let extraConfigs = ["S3", "S3S", "S3MB", "S3M", "SWIFT", "SWIFTV3", "AZURE"];
|
||||||
then
|
$extraConfigs | each {
|
||||||
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/s3.php' /var/www/html/config/config.php
|
if ($in in $env) {
|
||||||
fi
|
loadExtraConfig ($in | str downcase)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if [ -n "${S3S:-}" ]
|
if ("REDIS_TLS" in $env) {
|
||||||
then
|
loadExtraConfig "redis-tls"
|
||||||
sed -i '/\/\/PLACEHOLDER/ r /etc/nc/s3s.php' /var/www/html/config/config.php
|
} else {
|
||||||
fi
|
loadExtraConfig "redis-default"
|
||||||
|
}
|
||||||
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
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/nu
|
||||||
|
|
||||||
export XDEBUG_SESSION=haze
|
def --wrapped main [...rest] {
|
||||||
|
XDEBUG_SESSION=haze php $"($env.WEBROOT)/occ" ...$rest
|
||||||
php $WEBROOT/occ "$@"
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/nu
|
||||||
|
|
||||||
cd $WEBROOT
|
def main [...rest] {
|
||||||
|
cd $env.WEBROOT
|
||||||
|
|
||||||
export XDEBUG_SESSION=haze
|
XDEBUG_SESSION=haze phpunit --configuration $"($env.WEBROOT)/tests/phpunit-autotest.xml" ...$rest
|
||||||
|
}
|
||||||
phpunit --configuration $WEBROOT/tests/phpunit-autotest.xml $@
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue