2012-06-30 19:30:36 +00:00
|
|
|
---
|
|
|
|
layout: post
|
|
|
|
title: "Init-Script for pyload on gentoo"
|
|
|
|
date: 2012-06-30 21:14
|
|
|
|
comments: true
|
2012-07-20 12:14:46 +00:00
|
|
|
description: "initscript to run pyload on gentoo as a service"
|
2012-06-30 19:30:36 +00:00
|
|
|
categories:
|
|
|
|
---
|
|
|
|
|
|
|
|
Because I use a custom installation of [pyload](http://pyload.org/) I had to write my own init script.
|
|
|
|
|
|
|
|
my setup:
|
|
|
|
|
|
|
|
- runs as a user with its home directory set to /home/pyload
|
|
|
|
- python files are located in /home/pyload/bin
|
|
|
|
- configuration files are located in /home/pyload/.pyload
|
|
|
|
|
|
|
|
Here is the init script I use:
|
|
|
|
|
|
|
|
``` bash /etc/init.d/pyload
|
|
|
|
#!/sbin/runscript
|
|
|
|
|
|
|
|
depend() {
|
|
|
|
need net
|
|
|
|
}
|
|
|
|
|
|
|
|
PYLOAD_USER=${PYLOAD_USER:-root}
|
|
|
|
PYLOAD_GROUP=${PYLOAD_GROUP:-root}
|
|
|
|
PYLOAD_CONFDIR=${PYLOAD_CONFDIR:-/etc/pyload}
|
|
|
|
PYLOAD_PIDFILE=${PYLOAD_PIDFILE:-/var/run/${SVCNAME}.pid}
|
|
|
|
PYLOAD_EXEC=${PYLOAD_EXEC:-/usr/bin/pyload}
|
|
|
|
|
|
|
|
start() {
|
|
|
|
ebegin "Starting pyload"
|
|
|
|
start-stop-daemon --start --exec "${PYLOAD_EXEC}" \
|
|
|
|
--pidfile $PYLOAD_PIDFILE \
|
|
|
|
--user $PYLOAD_USER:$PYLOAD_GROUP \
|
|
|
|
-- -p $PYLOAD_PIDFILE --daemon ${PYLOAD_OPTIONS}
|
|
|
|
eend $? "Failed to start pyload"
|
|
|
|
}
|
|
|
|
stop() {
|
|
|
|
ebegin "Stopping pyload"
|
|
|
|
start-stop-daemon --stop \
|
|
|
|
--pidfile $PYLOAD_PIDFILE \
|
|
|
|
--exec "${PYLOAD_EXEC}"
|
|
|
|
eend $? "Failed to stop pyload"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Here is the configuration:
|
|
|
|
|
|
|
|
``` bash /etc/conf.d/pyload
|
|
|
|
PYLOAD_USER=pyload
|
|
|
|
PYLOAD_GROUP=pyload
|
|
|
|
PYLOAD_EXEC=/home/pyload/bin/pyLoadCore.py
|
|
|
|
PYLOAD_CONFDIR=/home/pyload/.pyload
|
|
|
|
PYLOAD_PIDFILE=/home/pyload/${SVCNAME}.pid
|
|
|
|
PYLOAD_OPTIONS=
|
|
|
|
```
|