Created
June 19, 2020 16:07
-
-
Save p120ph37/5b473f9cbb8f7801c2db9f397a96f997 to your computer and use it in GitHub Desktop.
Stuntman install for CentOS
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
yum install -y curl make gcc-c++ boost-devel openssl-devel | |
curl http://www.stunprotocol.org/stunserver-1.2.16.tgz | tar -xz | |
cd stunserver | |
make | |
cp stunserver /usr/sbin | |
cat - >/etc/init.d/stunserver <<'END' | |
#!/bin/sh | |
# chkconfig: 345 91 09 | |
### BEGIN INIT INFO | |
# Provides: stunserver | |
# Required-Start: $network | |
# Default-Start: 3 4 5 | |
# Default-Stop: 0 1 2 6 | |
# Description: Suntman STUN server | |
### END INIT INFO | |
PROG_BIN=/usr/sbin/stunserver | |
PROG_ARGS= | |
PROG_NAME=$(basename $PROG_BIN) | |
PID_FILE=/var/run/$PROG_NAME.pid | |
RUN_USER=root | |
. /etc/rc.d/init.d/functions | |
case "$1" in | |
start) | |
echo -n "Starting $PROG_NAME: " | |
daemon --user "$RUN_USER" --pidfile "$PID_FILE" " | |
nohup $PROG_BIN $PROG_ARGS >/dev/null 2>&1 & | |
echo \$! >$PID_FILE | |
" | |
if [ $? = 0 ]; then | |
success | |
else | |
failure | |
fi | |
echo | |
;; | |
stop) | |
echo -n "Shutting down $PROG_NAME: " | |
killproc -p $PID_FILE -b $PROG_BIN $PROG_NAME | |
;; | |
restart) | |
$0 stop | |
$0 start | |
;; | |
status) | |
status -p $PID_FILE -b $PROG_BIN $PROG_NAME | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|status}" | |
exit 1 | |
esac | |
exit $? | |
END | |
chmod 755 /etc/init.d/stunserver | |
chkconfig --add stunserver | |
service stunserver start | |
./stunclient 127.0.0.1 # just to check that it's responding |
nice
Very nice!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can run this in one line as follows (assuming you have curl installed):