Enterprise Practice Question 16:
Enterprise Case: Write Network Service standalone process mode rsync system startup script
For example:/etc/init.d/rsyncd{start|stop|restart}.
Requirements:
1. To use the System function library technique.
2. To use a function, not a lump of Shi's way.
3. Can be managed by chkconfig.
Script 1:
#!/bin/bash
Pidfile= "/var/run/rsyncd.pid"
result= ' PS aux|grep rsync|grep-v ' grep '
Rstatus () {
if [$resultX = = X];then
echo "RSYNCD is down"
Else
echo "RSYNCD is running"
Fi
}
Rstart () {
if [$resultX = = X];then
/usr/bin/rsync--daemon--config=/etc/rsyncd/rsyncd.conf
Else
echo "RSYNCD is running"
Fi
}
Rstop () {
if [$resultX = = X];then
echo "Rsync service is not running!"
Exit 1
Else
kill-9 $ (cat $pidfile)
Rstatus2= ' $ (ps-ef | egrep "Rsync--daemon.*rsyncd.conf" | grep-v ' grep ') '
if [$RstatusX = X];then
Rm-f $pidfile
echo "Rsync service stop .... OK "
Fi
Fi
}
Rrestart () {
Rstop
Rstart
}
Brother even Enterprise shell pen question 16-31