2022-05-18 09:06:32 +02:00
|
|
|
{ stdenv
|
|
|
|
, pkgs
|
|
|
|
}:
|
|
|
|
{ binDir
|
|
|
|
, user
|
|
|
|
}:
|
|
|
|
{ TtrssPostgresDB
|
2022-09-09 04:28:47 +02:00
|
|
|
, TtrssConfig
|
2022-05-18 09:06:32 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "dbupgrade";
|
|
|
|
|
|
|
|
src = pkgs.writeTextDir "wrapper" ''
|
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
sudo -u ${user} bash <<HERE
|
|
|
|
case "$1" in
|
|
|
|
activate)
|
|
|
|
${pkgs.php}/bin/php ${binDir}/update.php --update-schema=force-yes
|
|
|
|
;;
|
|
|
|
lock)
|
|
|
|
if [ -f /tmp/wrapper.lock ]
|
|
|
|
then
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "1" > /tmp/wrapper.lock
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
unlock)
|
|
|
|
rm -f /tmp/wrapper.lock
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
HERE
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
cp $src/wrapper $out/bin
|
|
|
|
chmod +x $out/bin/*
|
|
|
|
'';
|
|
|
|
}
|