Created
July 15, 2016 00:43
-
-
Save mayli/c6b23439142f4ad3ed0d3d4c67516242 to your computer and use it in GitHub Desktop.
/etc/init.d/socat
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
#!/bin/bash | |
### BEGIN INIT INFO | |
# Provides: socat | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: | |
# Short-Description: socat service | |
### END INIT INFO | |
USER=nobody | |
GROUP=nogroup | |
TARGET=10.0.0.29 | |
INPORT=22 | |
DSTPORT=22 | |
PIDFILE=/var/run/socat-$INPORT.pid | |
LOGFILE=/var/log/socat-$INPORT.log | |
SOCAT=/usr/bin/socat | |
start() { | |
$SOCAT TCP4-LISTEN:$INPORT,fork,reuseaddr TCP4:$TARGET:$DSTPORT </dev/null > $LOGFILE & | |
echo $! >$PIDFILE | |
} | |
stop() { | |
/bin/kill $(/bin/cat $PIDFILE) | |
} | |
restart() { | |
stop | |
start | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo $"Use this options $0 {start|stop|restart}" | |
exit 1 | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment