yum安装stunnel -y
openssl genrsa -out privkey.pem 2048openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095cat privkey.pem cacert.pem >> /etc/stunnel/stunnel.pemchmod 600 /etc/stunnel/stunnel.pemchown nobody.nobody /var/run/stunnel
nano -K /etc/stunnel/stunnel.conf
cert = /etc/stunnel/stunnel.pemchroot = /var/run/stunnel/pID = /stunnel.pIDsetuID = nobodysetgID = nobodyoutput = stunnel.log[squID]# Ensure the ‘connect’ line matches your squID port. Default is 3128accept = 8088connect = 127.0.0.1:1945
我的问题是在stunnel安装后没有安装stunnel的服务.
所以我写了这个:
nano -K /etc/init.d/stunnel
#!/bin/bash# /etc/rc.d/init.d/stunnel## Starts the stunnel daemon## chkconfig: 345 70 30# description: Stunnel Server is a ...# processname: stunnel# config: /etc/stunnel/stunnel.conf# Source function library.. /etc/init.d/functionstest -x /usr/sbin/stunnel || exit 0RETVAL=0## See how we were called.#prog="stunnel"start() { # Check if stunnel is already running if [ ! -f /var/lock/subsys/stunnel ]; then echo -n $"Starting $prog: " daemon /usr/sbin/stunnel RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/stunnel echo fi return $RETVAL}stop() { echo -n $"StopPing $prog: " killproc /usr/sbin/stunnel RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/stunnel echo return $RETVAL}restart() { stop start}reload() { restart}status() { status /usr/sbin/stunnel}case "" instart) start ;;stop) stop ;;reload|restart) restart ;;status) status ;;*) echo $"Usage:#!/bin/bash## Script to run stunnel in daemon mode at boot time.## Check http://www.gaztronics.net/ for the# most up-to-date version of this script.## This script is realeased under the terms of the GPL.# You can source a copy at:# http://www.fsf.org/copyleft/copyleft.HTML## Please feel free to modify the script to suite your own needs.# I always welcome email Feedback with suggestions for improvements.# Please do not email for general support. I do not have time to answer# personal help requests.# Author: Gary Myers MIIE MBCS# email: http://www.gaztronics.net/webform/# Revision 1.0 - 4th march 2005#====================================================================# Run level information:## chkconfig: 2345 99 99# description: Secure Tunnel# processname: stunnel## Run "/sbin/chkconfig --add stunnel" to add the Run levels.# This will setup the symlinks and set the process to run at boot.#====================================================================#====================================================================# Paths and variables and system checks.# Source function library (It's a Red Hat thing!). /etc/rc.d/init.d/functions# Check that networking is up.#[ ${NETWORKING} ="yes" ] || exit 0# Path to the executable.#SEXE=`which stunnel`# Path to the configuration file.#CONF=/etc/stunnel/stunnel.conf# Check the configuration file exists.#if [ ! -f $CONF ] ; then echo "The configuration file cannot be found!"exit 0fiCHROOT=`grep '^chroot' /etc/stunnel/stunnel.conf | head -n 1 | sed 's/ //g' | awk -F= '{ print }'`PIDfile=`grep '^pID' /etc/stunnel/stunnel.conf | head -n 1 | sed 's/ //g' | awk -F= '{ print }'`if [ -n "$CHROOT" ]; then PIDfile=$CHROOT/$PIDfilefi# Path to the lock file.#LOCK_file=/var/lock/subsys/stunnel#====================================================================#====================================================================# Run controls:prog=$"stunnel"RETVAL=0# Start stunnel as daemon.#start() { if [ -f $LOCK_file ]; then echo "stunnel is already running!" exit 0 else echo -n $"Starting $prog: " $SEXE $CONF fi RETVAL=$? [ $RETVAL -eq 0 ] && success echo [ $RETVAL -eq 0 ] && touch $LOCK_file return $RETVAL}# Stop stunnel.#stop() { if [ ! -f $LOCK_file ]; then echo "stunnel is not running!" exit 0 else echo -n $"Shutting down $prog: " killproc -p $PIDfile stunnel RETVAL=$? [ $RETVAL -eq 0 ] rm -f $LOCK_file echo return $RETVAL fi}# See how we were called.case "" in start) start ;; stop) stop ;; restart) stop start ;; condrestart) if [ -f $LOCK_file ]; then stop start RETVAL=$? fi ;; status) status -p $PIDfile stunnel RETVAL=$? ;; *) echo $"Usage: {start|stop|restart|condrestart|status}" RETVAL=1esacexit $RETVAL{start|stop|restart|reload|status}" exit 1esacexit $?exit $RETVAL
chmod x /etc/init.d/stunnel
chkconfig –add stunnel
写入服务的启动命令工作正常:服务stunnel start:OK.
但是在停止命令期间我有错误:服务stunnel停止:Failed
我在状态命令期间遇到错误:服务stunnel状态:
/ sbin / service:第66行:7456分段错误env -i LANG =“$LANG”PATH =“$PATH”TERM =“$TERM”“${SERVICEDIR} / ${SERVICE}”${OPTIONS}
我做错了什么,我该如何解决这个问题呢?
获得该服务有更好的方法吗?
提前致谢
解决方法 这是你需要的: 总结以上是内存溢出为你收集整理的linux – 如何在CentOS 5.10上为已安装的STUNNEL创建服务全部内容,希望文章能够帮你解决linux – 如何在CentOS 5.10上为已安装的STUNNEL创建服务所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)