runit-user-services/new-service

23 lines
516 B
Plaintext
Raw Normal View History

2022-02-10 10:27:50 +00:00
#!/bin/zsh
2023-08-20 16:00:42 +00:00
zparseopts -D l=logs -log=logs -enable-log=logs i:=importenv -import-env:=importenv
2022-02-10 10:27:50 +00:00
mkdir $1
ln -s ${XDG_RUNTIME_DIR:-/run/user/$UID}/supervise.$1 $1/supervise
2023-08-20 16:00:42 +00:00
{
echo '#!/bin/zsh'
if [[ $importenv ]]; then
echo 'source ${0:a:h:h}/import-env.zsh'
echo "import-env ${importenv[2]} || exit 1"
2023-08-20 16:00:42 +00:00
fi
2023-10-24 15:11:15 +00:00
echo 'exec 2>&1'
2023-08-20 16:00:42 +00:00
echo "exec $*"
} > $1/run
2022-02-10 10:27:50 +00:00
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