Merge pull request #116 from v2fly/develop

pull/123/head
IceCodeNew 2020-09-20 00:39:48 +08:00 committed by GitHub
commit b4197dd807
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 503 additions and 451 deletions

View File

@ -41,7 +41,6 @@ download_files() {
fi
}
check_sum() {
(
cd "${dir_tmp}" || exit

View File

@ -12,11 +12,20 @@
# If the script executes incorrectly, go to:
# https://github.com/v2fly/fhs-install-v2ray/issues
# If you modify the following variables, you also need to modify the unit file yourself:
# You can modify it to /usr/local/lib/v2ray
DAT_PATH='/usr/local/share/v2ray'
# You can modify it to /etc/v2ray
JSON_PATH='/usr/local/etc/v2ray'
# You can set this variable whatever you want in shell session right before running this script by issuing:
# export DAT_PATH='/usr/local/share/v2ray'
DAT_PATH=${DAT_PATH:-/usr/local/share/v2ray}
# You can set this variable whatever you want in shell session right before running this script by issuing:
# export JSON_PATH='/usr/local/etc/v2ray'
JSON_PATH=${JSON_PATH:-/usr/local/etc/v2ray}
# Set this variable only if you are starting v2ray with multiple configuration files:
# export JSONS_PATH='/usr/local/etc/v2ray'
red=$(tput setaf 1)
green=$(tput setaf 2)
reset=$(tput sgr0)
check_if_running_as_root() {
# If you want to run as another user, please modify $UID to be owned by this user
@ -298,12 +307,21 @@ install_v2ray() {
fi
# Install V2Ray configuration file to $JSON_PATH
if [[ ! -d "$JSON_PATH" ]]; then
if [[ -z "$JSONS_PATH" ]] && [[ ! -d "$JSON_PATH" ]]; then
install -d "$JSON_PATH"
echo "{}" >"${JSON_PATH}/config.json"
CONFIG_NEW='1'
fi
# Install V2Ray configuration file to $JSONS_PATH
if [[ -n "$JSONS_PATH" ]] && [[ ! -d "$JSONS_PATH" ]]; then
install -d "$JSONS_PATH"
for BASE in 00_log 01_api 02_dns 03_routing 04_policy 05_inbounds 06_outbounds 07_transport 08_stats 09_reverse; do
echo '{}' >"${JSONS_PATH}$BASE.json"
done
CONFDIR='1'
fi
# Used to store V2Ray log files
if [[ ! -d '/var/log/v2ray/' ]]; then
if [[ -n "$(id nobody | grep nogroup)" ]]; then
@ -322,6 +340,41 @@ install_v2ray() {
install_startup_service_file() {
install -m 644 "${TMP_DIRECTORY}/systemd/system/v2ray.service" /etc/systemd/system/v2ray.service
install -m 644 "${TMP_DIRECTORY}/systemd/system/v2ray@.service" /etc/systemd/system/v2ray@.service
mkdir -p '/etc/systemd/system/v2ray.service.d'
mkdir -p '/etc/systemd/system/v2ray@.service.d/'
if [[ -n "$JSONS_PATH" ]]; then
echo "# Duplicate this file in the same directory and make your customizes there. Or all changes you made will be lost!
## Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
ExecStart=
ExecStart=/usr/local/bin/v2ray -confdir $JSONS_PATH" |
tee '/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf' > \
'/etc/systemd/system/v2ray@.service.d/10-donot_touch_multi_conf.conf'
else
echo "${red}~~~~~~~~~~~~~~~~ ${green}/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf ${red}~~~~~~~~~~~~~~~~${reset}"
echo 'info: The following are the actual parameters for the v2ray service startup.'
echo 'info: Please make sure the configuration file path is correctly set.'
echo "# Duplicate this file in the same directory and make your customizes there. Or all changes you made will be lost!
## Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
ExecStart=
ExecStart=/usr/local/bin/v2ray -config ${JSON_PATH}/config.json" |
tee '/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf'
echo
echo
echo "${red}~~~~~~~~~~~~~~~~ ${green}/etc/systemd/system/v2ray@.service.d/10-donot_touch_single_conf ${red}~~~~~~~~~~~~~~~~${reset}"
echo 'info: The following are the actual parameters for the v2ray service startup.'
echo 'info: Please make sure the configuration file path is correctly set.'
echo "# Duplicate this file in the same directory and make your customizes there. Or all changes you made will be lost!
## Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
ExecStart=
ExecStart=/usr/local/bin/v2ray -config ${JSON_PATH}/%i.json" |
tee '/etc/systemd/system/v2ray@.service.d/10-donot_touch_single_conf.conf'
echo
echo
fi
systemctl daemon-reload
SYSTEMD='1'
}