Leendert Meyer wrote:
Why not start from the skeleton, change the start and stop sections to do something simple, like: echo "$(date +%FT%T%z): FOO started" >> /tmp/FOO.log and echo "$(date +%FT%T%z): FOO stopped" >> /tmp/FOO.log
(log files normally would go to /var/log/, but since your playing, I think /tmp/ is better)
Dear Leendert, I was playing these days with it, understood a lot, but again there is some small problems I have. Here what I have done: In the skeleton I just changed the appropriate parts to _ |case "$1" in | start) | echo "$(date +%FT%T%z): FOO started" >> /tmp/FOO.log | /sbin/startproc $FOO_BIN | rc_status -v | ;; | stop) | echo "$(date +%FT%T%z): FOO stopped" >> /tmp/FOO.log | /sbin/killproc -TERM $FOO_BIN - If I leave the following part uncommented, and there is no FOO in my /usr/bin _ |FOO_BIN=/usr/sbin/FOO |test -x $FOO_BIN || { echo "$FOO_BIN not installed"; | if [ "$1" = "stop" ]; then exit 0; | else exit 5; fi; } | |# Check for existence of needed config file and read it |FOO_CONFIG=/etc/sysconfig/FOO |test -r $FOO_CONFIG || { echo "$FOO_CONFIG not existing"; | if [ "$1" = "stop" ]; then exit 0; | else exit 6; fi; } | |# Read config |. $FOO_CONFIG - after running insserv and chkconfig and restarting it gives, as expected, at booting /usr/sbin/FOO not installed If I comment all the part placed here(from FOO_BIN to $FOO_CONFIG), it gives the following in the dmesg startproc: Usage: startproc [-f] [+/-<prio>] [-s] [-u uid] [-g gid] [-v] [-l log_file|-q] /full/path/to/program failed Failed services in runlevel 3: try(<- my one) But with all that it creates FOO.log in my tmp folder, with correct information in it. And in this case I hadn't to change anything between BEGIN INIT INFO and END INIT INFO. Am I right? If I havent' became boring yet, could you help me, please with it. I am a newbie and got a very little experience with shell scripting, maybe I should leave this for a better times?
Can you point me some good documentation for it?
Carlos already provided you some docs. ;)
I read it, thanks Carlos for that ;) I am learning a lot, thank you very much! Regards, -- Sergey Mkrtchyan Scientific Researcher Department of Molecular Physics, Faculty of Physics, Yerevan State University Tel: (374-10) 55-43-41 Fax: (374-10) 57-76-89