mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-18 07:17:32 -05:00
smarter installer
This commit is contained in:
parent
b60f491cec
commit
2de77000ad
@ -29,17 +29,33 @@ fi
|
|||||||
YUM_CMD=$(command -v yum)
|
YUM_CMD=$(command -v yum)
|
||||||
APT_CMD=$(command -v apt-get)
|
APT_CMD=$(command -v apt-get)
|
||||||
|
|
||||||
if [ -n "${YUM_CMD}" ]; then
|
SOFTWARE_UPDATED=0
|
||||||
echo "Installing unzip and daemon via yum."
|
|
||||||
|
function update_software() {
|
||||||
|
if [ ${SOFTWARE_UPDATED} -eq 1 ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [ -n "${YUM_CMD}" ]; then
|
||||||
|
echo "Updating software repo via yum."
|
||||||
${YUM_CMD} -q makecache
|
${YUM_CMD} -q makecache
|
||||||
${YUM_CMD} -y -q install unzip daemon
|
elif [ -n "${APT_CMD}" ]; then
|
||||||
elif [ -n "${APT_CMD}" ]; then
|
echo "Updating software repo via apt-get."
|
||||||
echo "Installing unzip and daemon via apt-get."
|
|
||||||
${APT_CMD} -qq update
|
${APT_CMD} -qq update
|
||||||
${APT_CMD} -y -qq install unzip daemon
|
fi
|
||||||
else
|
SOFTWARE_UPDATED=1
|
||||||
echo "Please make sure unzip and daemon are installed."
|
}
|
||||||
fi
|
|
||||||
|
function install_component() {
|
||||||
|
update_software
|
||||||
|
local COMPONENT=$1
|
||||||
|
if [ -n "${YUM_CMD}" ]; then
|
||||||
|
echo "Installing ${COMPONENT} via yum."
|
||||||
|
${YUM_CMD} -y -q install $COMPONENT
|
||||||
|
elif [ -n "${APT_CMD}" ]; then
|
||||||
|
echo "Installing ${COMPONENT} via apt-get."
|
||||||
|
${APT_CMD} -y -qq install $COMPONENT
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
VER="v1.7"
|
VER="v1.7"
|
||||||
|
|
||||||
@ -59,6 +75,9 @@ DOWNLOAD_LINK="https://github.com/v2ray/v2ray-core/releases/download/${VER}/v2ra
|
|||||||
rm -rf /tmp/v2ray
|
rm -rf /tmp/v2ray
|
||||||
mkdir -p /tmp/v2ray
|
mkdir -p /tmp/v2ray
|
||||||
|
|
||||||
|
install_component "curl"
|
||||||
|
install_component "unzip"
|
||||||
|
|
||||||
if [ -n "${PROXY}" ]; then
|
if [ -n "${PROXY}" ]; then
|
||||||
curl -x ${PROXY} -L -o "/tmp/v2ray/v2ray.zip" ${DOWNLOAD_LINK}
|
curl -x ${PROXY} -L -o "/tmp/v2ray/v2ray.zip" ${DOWNLOAD_LINK}
|
||||||
else
|
else
|
||||||
@ -117,6 +136,7 @@ if [ -n "${SYSTEMCTL_CMD}" ]; then
|
|||||||
fi
|
fi
|
||||||
elif [ -n "${SERVICE_CMD}" ]; then # Configure SysV if necessary.
|
elif [ -n "${SERVICE_CMD}" ]; then # Configure SysV if necessary.
|
||||||
if [ ! -f "/etc/init.d/v2ray" ]; then
|
if [ ! -f "/etc/init.d/v2ray" ]; then
|
||||||
|
install_component "daemon"
|
||||||
cp "/tmp/v2ray/v2ray-${VER}-linux-${VDIS}/systemv/v2ray" "/etc/init.d/v2ray"
|
cp "/tmp/v2ray/v2ray-${VER}-linux-${VDIS}/systemv/v2ray" "/etc/init.d/v2ray"
|
||||||
chmod +x "/etc/init.d/v2ray"
|
chmod +x "/etc/init.d/v2ray"
|
||||||
update-rc.d v2ray defaults
|
update-rc.d v2ray defaults
|
||||||
|
Loading…
Reference in New Issue
Block a user