new-service: add import-env support
This commit is contained in:
parent
1f44d351ed
commit
684ed6f515
|
@ -5,7 +5,13 @@ Various runit service files for per-user services. May need to be modified to wo
|
||||||
Helper scripts:
|
Helper scripts:
|
||||||
- `log`: symlink as the `run` script in your service's log directory to enable logging to `~/.local/log/`
|
- `log`: symlink as the `run` script in your service's log directory to enable logging to `~/.local/log/`
|
||||||
- `setup-supervise.zsh`: run to create symlinks for `supervise` directories, so they are created in $XDG_RUNTIME_DIR
|
- `setup-supervise.zsh`: run to create symlinks for `supervise` directories, so they are created in $XDG_RUNTIME_DIR
|
||||||
- `new-service`: create a new service, executing the given command line. Optionally pass `-l` before any other arguments to also create a logging entry. Example:
|
- `new-service`: create a new service, executing the given command line.
|
||||||
|
Accepted options before service name:
|
||||||
|
|
||||||
|
- `-l`, `--log`: create a log directory and symlink `log` script
|
||||||
|
- `-i PROC`, `--import-env PROC`: include import-env script and import environment from process `PROC`
|
||||||
|
|
||||||
|
Example
|
||||||
```
|
```
|
||||||
./new-service -l my-daemon --foreground -a -b -c
|
./new-service -l my-daemon --foreground -a -b -c
|
||||||
```
|
```
|
||||||
|
|
12
new-service
12
new-service
|
@ -1,11 +1,17 @@
|
||||||
#!/bin/zsh
|
#!/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
|
mkdir $1
|
||||||
ln -s ${XDG_RUNTIME_DIR:-/run/user/$UID}/supervise.$1 $1/supervise
|
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
|
chmod +x $1/run
|
||||||
|
|
||||||
if [[ $logs ]]; then
|
if [[ $logs ]]; then
|
||||||
|
|
Loading…
Reference in a new issue