put systemd unit file into /etc/systemd/system. fix #623

pull/700/head
Darien Raymond 2017-11-07 15:25:58 +01:00
parent 1b6b39faad
commit e1c8ffd378
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 23 additions and 5 deletions

View File

@ -171,7 +171,7 @@ stopV2ray(){
SERVICE_CMD=$(command -v service) SERVICE_CMD=$(command -v service)
colorEcho ${BLUE} "Shutting down V2Ray service." colorEcho ${BLUE} "Shutting down V2Ray service."
if [[ -n "${SYSTEMCTL_CMD}" ]] || [[ -f "/lib/systemd/system/v2ray.service" ]]; then if [[ -n "${SYSTEMCTL_CMD}" ]] || [[ -f "/lib/systemd/system/v2ray.service" ]] || [[ -f "/etc/systemd/system/v2ray.service" ]]; then
${SYSTEMCTL_CMD} stop v2ray ${SYSTEMCTL_CMD} stop v2ray
elif [[ -n "${SERVICE_CMD}" ]] || [[ -f "/etc/init.d/v2ray" ]]; then elif [[ -n "${SERVICE_CMD}" ]] || [[ -f "/etc/init.d/v2ray" ]]; then
${SERVICE_CMD} v2ray stop ${SERVICE_CMD} v2ray stop
@ -185,6 +185,8 @@ startV2ray(){
if [ -n "${SYSTEMCTL_CMD}" ] && [ -f "/lib/systemd/system/v2ray.service" ]; then if [ -n "${SYSTEMCTL_CMD}" ] && [ -f "/lib/systemd/system/v2ray.service" ]; then
${SYSTEMCTL_CMD} start v2ray ${SYSTEMCTL_CMD} start v2ray
elif [ -n "${SYSTEMCTL_CMD}" ] && [ -f "/etc/systemd/system/v2ray.service" ]; then
${SYSTEMCTL_CMD} start v2ray
elif [ -n "${SERVICE_CMD}" ] && [ -f "/etc/init.d/v2ray" ]; then elif [ -n "${SERVICE_CMD}" ] && [ -f "/etc/init.d/v2ray" ]; then
${SERVICE_CMD} v2ray start ${SERVICE_CMD} v2ray start
fi fi
@ -244,10 +246,12 @@ installInitScrip(){
SERVICE_CMD=$(command -v service) SERVICE_CMD=$(command -v service)
if [[ -n "${SYSTEMCTL_CMD}" ]];then if [[ -n "${SYSTEMCTL_CMD}" ]];then
if [[ ! -f "/etc/systemd/system/v2ray.service" ]]; then
if [[ ! -f "/lib/systemd/system/v2ray.service" ]]; then if [[ ! -f "/lib/systemd/system/v2ray.service" ]]; then
cp "/tmp/v2ray/v2ray-${NEW_VER}-linux-${VDIS}/systemd/v2ray.service" "/lib/systemd/system/" cp "/tmp/v2ray/v2ray-${NEW_VER}-linux-${VDIS}/systemd/v2ray.service" "/etc/systemd/system/"
systemctl enable v2ray.service systemctl enable v2ray.service
fi fi
fi
return return
elif [[ -n "${SERVICE_CMD}" ]] && [[ ! -f "/etc/init.d/v2ray" ]]; then elif [[ -n "${SERVICE_CMD}" ]] && [[ ! -f "/etc/init.d/v2ray" ]]; then
installSoftware "daemon" installSoftware "daemon"
@ -273,7 +277,21 @@ Help(){
remove(){ remove(){
SYSTEMCTL_CMD=$(command -v systemctl) SYSTEMCTL_CMD=$(command -v systemctl)
SERVICE_CMD=$(command -v service) SERVICE_CMD=$(command -v service)
if [[ -n "${SYSTEMCTL_CMD}" ]] && [[ -f "/lib/systemd/system/v2ray.service" ]];then if [[ -n "${SYSTEMCTL_CMD}" ]] && [[ -f "/etc/systemd/system/v2ray.service" ]];then
if pgrep "v2ray" > /dev/null ; then
stopV2ray
fi
systemctl disable v2ray.service
rm -rf "/usr/bin/v2ray" "/etc/systemd/system/v2ray.service"
if [[ $? -ne 0 ]]; then
colorEcho ${RED} "Failed to remove V2Ray."
exit
else
colorEcho ${GREEN} "Removed V2Ray successfully."
colorEcho ${GREEN} "If necessary, please remove configuration file and log file manually."
exit
fi
elif [[ -n "${SYSTEMCTL_CMD}" ]] && [[ -f "/lib/systemd/system/v2ray.service" ]];then
if pgrep "v2ray" > /dev/null ; then if pgrep "v2ray" > /dev/null ; then
stopV2ray stopV2ray
fi fi