You are not logged in.
I wanted an excuse to poke around with C, so I rewrote the Bash script presented here with some extra bells and whistles.
Usage:
Show status of all daemons:
serv
Show status of a single daemon:
serv <daemon>
Interact with a daemon's init script:
serv <daemon> <action>
This isn't worthy of the AUR, but here's a PKGBUILD:
# Contributor: Dave Reisner <d@falconindy.com>
pkgname=serv
pkgver=20100409
pkgrel=1
pkgdesc="A daemon tool that should have stayed in Bash"
arch=('i686' 'x86_64')
url="VERSION"
license=('MIT')
depends=()
makedepends=('git')
_gitroot="git://github.com/falconindy/serv.git"
_gitname="serv"
build() {
cd "$srcdir"
msg "Connecting to GIT server...."
if [ -d $_gitname ] ; then
cd $_gitname && git pull origin
msg "The local files are updated."
else
git clone $_gitroot $_gitname
fi
msg "GIT checkout done or server timeout"
msg "Starting make..."
rm -rf "$srcdir/$_gitname-build"
git clone "$srcdir/$_gitname" "$srcdir/$_gitname-build"
cd "$srcdir/$_gitname-build"
make || return 1
install -m755 serv -D ${pkgdir}/usr/bin/serv
}
Offline
this is really nice
it simplifys working with daemons
good work!
MutantTurkey
Offline
a while back i got a bash function from someone on here called service, the real gem was the bash completion function that came with it. you could probably sed s/service/serv the following and use it with your tool as well:
_service_complete()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ "$prev" == service ]; then
COMPREPLY=( $(compgen -W "\
$( for service in /etc/rc.d/*; do
echo ${service##*/}
done )" -- $cur ) )
else
COMPREPLY=( $(compgen -W '\
start
stop
restart
reload' -- $cur ) )
fi
}
complete -F _service_complete service
//github/
Offline
Nifty. bash completion seems pretty straight forward. Going to have to implement this in some of my other projects...
Took your provided script and improved it somewhat:
_serv_complete() {
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
"serv") COMPREPLY=( $(compgen -W "\
$( for service in /etc/rc.d/*; do
echo ${service##*/}
done )" -- $cur ) ) ;;
"start"|"stop"|"restart") ;;
*) [ -f /var/run/daemons/$prev ] &&
COMPREPLY=( $(compgen -W '\
stop
restart' -- $cur ) ) ||
COMPREPLY=( $(compgen -W '\
start' -- $cur ) ) ;;
esac
}
complete -F _serv_complete serv
Running daemons complete only 'stop' and 'reload', and stopped daemons complete only 'start'.
Now to port this to ZSH.
Offline