New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could write a server installation script which supports the centos? #101
Comments
Please consider upgrading to CentOS 7 or later. CentOS (with Systemd) is supported by the script. CentOS 6.x is too old and should not be used anymore. |
This script may help. 😃 #!/bin/sh
#
# v2ray Startup script for v2ray
#
# chkconfig: - 24 76
# processname: v2ray
# pidfile: /var/run/v2ray.pid
# description: V2Ray proxy services
#
### BEGIN INIT INFO
# Provides: v2ray
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: V2Ray proxy services
# Description: V2Ray proxy services
### END INIT INFO
DESC=v2ray
NAME=v2ray
DAEMON=/usr/bin/v2ray/v2ray
PIDFILE=/var/run/$NAME.pid
LOCKFILE=/var/lock/subsys/$NAME
SCRIPTNAME=/etc/init.d/$NAME
RETVAL=0
DAEMON_OPTS="-config /etc/v2ray/config.json"
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Source function library.
. /etc/rc.d/init.d/functions
start() {
local pids=$(pgrep -f $DAEMON)
if [ -n "$pids" ]; then
echo "$NAME (pid $pids) is already running"
RETVAL=0
return 0
fi
echo -n $"Starting $NAME: "
mkdir -p /var/log/v2ray
$DAEMON $DAEMON_OPTS 1>/dev/null 2>&1 &
echo $! > $PIDFILE
sleep 2
pgrep -f $DAEMON >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
success; echo
touch $LOCKFILE
else
failure; echo
fi
return $RETVAL
}
stop() {
local pids=$(pgrep -f $DAEMON)
if [ -z "$pids" ]; then
echo "$NAME is not running"
RETVAL=0
return 0
fi
echo -n $"Stopping $NAME: "
killproc -p ${PIDFILE} ${NAME}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
}
reload() {
echo -n $"Reloading $NAME: "
killproc -p ${PIDFILE} ${NAME} -HUP
RETVAL=$?
echo
}
rh_status() {
status -p ${PIDFILE} ${DAEMON}
}
# See how we were called.
case "$1" in
start)
rh_status >/dev/null 2>&1 && exit 0
start
;;
stop)
stop
;;
status)
rh_status
RETVAL=$?
;;
restart)
stop
start
;;
reload)
reload
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|reload|restart}" >&2
RETVAL=2
;;
esac
exit $RETVAL Save as $ sudo chmod +x /etc/init.d/v2ray
$ sudo chkconfig v2ray on
$ sudo service v2ray start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It took me serveral hours to install v2ray on centos located in a vps ,but failed anyway.It could not find the /lib/init/vars.sh and /lib/lsb/init-functions.After I searched on Google , I got that those files are not located on centos.
The text was updated successfully, but these errors were encountered: