/etc/init.d/appservice.sh内容如下:
#!/bin/bash# chkconfig: 2345 20 80# description: # For SELinux we need to use 'runuser' not 'su'if [ -x "/sbin/runuser" ]; then SU="/sbin/runuser -s /bin/sh"else SU="su -s /bin/sh"fifileroot=/opt/cmbccd/repost/#program=${fileroot}"start-appservice.sh"pidfile=${fileroot}"repost.pid"case "$1" instart) echo "starting repost..." if [ -f $pidfile ]; then echo "service is running!" echo "[fail]" else #sh $program $SU kafka -c ${fileroot}"start-appservice.sh" echo "[success]" fi ;;stop) if [ -f $pidfile ]; then pid=$(cat $pidfile) echo "stopping service,the pid is:" $pid echo $(kill -9 $pid) echo $(rm -r $pidfile) echo "[success]" else echo "service is stopped!" echo "[fail]" fi ;;status) if [ -f $pidfile ]; then pid=$(cat $pidfile) echo "service is running,pid is:" $pid else echo "service is stopped!" fi ;;*) echo "Usage: $0 {start|stop|status}" exit 1esac