new-service: add import-env support

This commit is contained in:
crater2150 2023-08-20 18:00:42 +02:00
parent 1f44d351ed
commit 684ed6f515
2 changed files with 18 additions and 6 deletions

View file

@ -1,11 +1,17 @@
#!/bin/zsh
zparseopts -D l=logs -log=logs -enable-log=logs
zparseopts -D l=logs -log=logs -enable-log=logs i:=importenv -import-env:=importenv
mkdir $1
ln -s ${XDG_RUNTIME_DIR:-/run/user/$UID}/supervise.$1 $1/supervise
echo '#!/bin/zsh' > $1/run
echo "exec $*" >> $1/run
{
echo '#!/bin/zsh'
if [[ $importenv ]]; then
echo 'source ${0:a:h:h}/import-env.zsh'
echo "import-env ${importenv[2]}"
fi
echo "exec $*"
} > $1/run
chmod +x $1/run
if [[ $logs ]]; then