runit-user-services/new-service
2023-08-20 18:00:42 +02:00

22 lines
488 B
Bash
Executable file

#!/bin/zsh
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'
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
mkdir $1/log
ln -sr ./log $1/log/run
ln -s ${XDG_RUNTIME_DIR:-/run/user/$UID}/supervise.${1}-log $1/log/supervise
fi