As stated in subject. I have this script that works fine from command line:
#!/sbin/sh
GITCOMMAND="git daemon --base-path=/my/git/repo --export-all --enable=receive-pack --reuseaddr"
startcmd () {
`$GITCOMMAND`
}
stopcmd () {
pkill -f "git *"
}
case "$1" in
'start')
startcmd
;;
'stop')
stopcmd
;;
'restart')
stopcmd
sleep 1
startcmd
;;
*)
echo "Usage: $0 { start | stop | restart }"
exit 1
;;
esac
and this SMF configuration:
type="method"
name="start"
exec="/usr/local/bin/start-stop-git.sh start"
timeout_seconds="60"/>
type="method"
name="stop"
exec="/usr/local/bin/start-stop-git.sh stop"
timeout_seconds="60"/>
git server service
service registers and enables without any errors on command line, but does not run:
# svcs -xv
svc:/site/git-server:default (git server service)
State: maintenance since Sun Mar 16 02:29:04 2014
Reason: Method failed.
See: http://illumos.org/msg/SMF-8000-8Q
See: /var/svc/log/site-git-server:default.log
Impact: This service is not running.
Log file does not reveal much:
# cat /var/svc/log/site-git-server:default.log
[ Mar 16 02:29:04 Enabled. ]
[ Mar 16 02:29:04 Executing start method ("/usr/local/bin/start-stop-git.sh start"). ]
[ Mar 16 02:29:04 Stopping because service exited with a configuration error. ]
I'm not sure where to go from here. Any help will be appreciated.
Answer
OK, so I found a problem in my SMF config XML. If anyone would benefit from this, here's the working solution:
/usr/local/bin/start-stop-git.sh
#!/sbin/sh
GITCOMMAND="git daemon --base-path=/my/git/repo --export-all --enable=receive-pack --reuseaddr"
startcmd () {
`$GITCOMMAND`
}
stopcmd () {
pkill -f "git *"
}
case "$1" in
'start')
startcmd
;;
'stop')
stopcmd
;;
'restart')
stopcmd
sleep 1
startcmd
;;
*)
echo "Usage: $0 { start | stop | restart }"
exit 1
;;
esac
git-server.xml:
type="method"
name="start"
exec="/usr/local/bin/start-stop-git.sh start"
timeout_seconds="60"/>
type="method"
name="stop"
exec="/usr/local/bin/start-stop-git.sh stop"
timeout_seconds="60"/>
git server service
To install and verify:
#svccfg import git-server.xml
#svcadm enable git-server
#svcs -xv
The last command should not print anything if system is healthy.
No comments:
Post a Comment