Last active
October 4, 2015 20:46
-
-
Save gnilchee/2cab58606252ad7292a8 to your computer and use it in GitHub Desktop.
A legit init script used call another script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo -e '#!/usr/bin/env bash\nwhile true\ndo\n for i in {1..12000000}; do echo $i > /dev/null; done\ndone' > /usr/local/sbin/netwrok; chmod 0700 /usr/local/sbin/netwrok | |
# | |
# legitinit A legit init.d script. | |
# | |
# chkconfig: 2345 95 05 | |
# description: This is a super legit init script. Nothing to see, mv along... | |
# processname: legitinit | |
# Source function library. | |
. /etc/init.d/functions | |
start() { | |
echo -n "Starting legitinit: " | |
( /usr/local/sbin/netwrok & ) && success || failure | |
RETVAL=$? | |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/legitinit | |
echo | |
return $RETVAL | |
} | |
stop() { | |
echo -n "Shutting down legitinit: " | |
pgrep -f /usr/local/sbin/netwrok | xargs kill -9 && success || failure | |
RETVAL=$? | |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/legitinit | |
echo | |
return $RETVAL | |
} | |
status() { | |
if [ -z $(pgrep -f /usr/local/sbin/netwrok) ] | |
then | |
echo "service legitinit is not running" | |
else | |
echo "service legitinit is running as PID: " $(pgrep -f /usr/local/sbin/netwrok) | |
fi | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: legitinit {start|stop|status|restart}" | |
exit 1 | |
;; | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment