create systemd locally
create systemd locally fix typo; match coding style modify json path fix typo; match coding style modify json path modify messages fix typo in path switch back to single config fix typo fix typo fix typopull/60/head
parent
56049fdee5
commit
c11c2282ef
|
@ -360,12 +360,19 @@ install_v2ray() {
|
||||||
# Install V2Ray configuration file to $JSON_PATH
|
# Install V2Ray configuration file to $JSON_PATH
|
||||||
if [[ ! -d "$JSON_PATH" ]]; then
|
if [[ ! -d "$JSON_PATH" ]]; then
|
||||||
install -d "$JSON_PATH"
|
install -d "$JSON_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 "{}" > "${JSON_PATH}config.json"
|
||||||
echo '{}' > "${JSON_PATH}$BASE.json"
|
CONFIG_NEW='1'
|
||||||
done
|
|
||||||
CONFDIR='1'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Install V2Ray configuration file to $JSONS_PATH
|
||||||
|
#if [[ ! -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
|
# Used to store V2Ray log files
|
||||||
if [[ ! -d '/var/log/v2ray/' ]]; then
|
if [[ ! -d '/var/log/v2ray/' ]]; then
|
||||||
if [[ -n "$(id nobody | grep nogroup)" ]]; then
|
if [[ -n "$(id nobody | grep nogroup)" ]]; then
|
||||||
|
@ -385,14 +392,40 @@ install_startup_service_file() {
|
||||||
if [[ ! -f '/etc/systemd/system/v2ray.service' ]]; then
|
if [[ ! -f '/etc/systemd/system/v2ray.service' ]]; then
|
||||||
mkdir "${TMP_DIRECTORY}systemd/system/"
|
mkdir "${TMP_DIRECTORY}systemd/system/"
|
||||||
install_software curl
|
install_software curl
|
||||||
if ! curl ${PROXY} -s -o "${TMP_DIRECTORY}systemd/system/v2ray.service" 'https://raw.githubusercontent.workers.dev/v2fly/fhs-install-v2ray/master/systemd/system/v2ray.service'; then
|
cat > "${TMP_DIRECTORY}systemd/system/v2ray.service" <<-EOF
|
||||||
echo 'error: Failed to start service file download! Please check your network or try again.'
|
[Unit]
|
||||||
exit 1
|
Description=V2Ray Service
|
||||||
fi
|
After=network.target nss-lookup.target
|
||||||
if ! curl ${PROXY} -s -o "${TMP_DIRECTORY}systemd/system/v2ray@.service" 'https://raw.githubusercontent.workers.dev/v2fly/fhs-install-v2ray/master/systemd/system/v2ray@.service'; then
|
|
||||||
echo 'error: Failed to start service file download! Please check your network or try again.'
|
[Service]
|
||||||
exit 1
|
User=nobody
|
||||||
fi
|
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
|
||||||
|
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
|
||||||
|
NoNewPrivileges=true
|
||||||
|
Environment=V2RAY_LOCATION_ASSET=/usr/local/share/v2ray/
|
||||||
|
ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
cat > "${TMP_DIRECTORY}systemd/system/v2ray@.service" <<-EOF
|
||||||
|
[Unit]
|
||||||
|
Description=V2Ray Service
|
||||||
|
After=network.target nss-lookup.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=nobody
|
||||||
|
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
|
||||||
|
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
|
||||||
|
NoNewPrivileges=true
|
||||||
|
Environment=V2RAY_LOCATION_ASSET=/usr/local/share/v2ray/
|
||||||
|
ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/%i.json
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
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
|
||||||
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
|
||||||
SYSTEMD='1'
|
SYSTEMD='1'
|
||||||
|
@ -548,6 +581,9 @@ main() {
|
||||||
echo "installed: ${DAT_PATH}geoip.dat"
|
echo "installed: ${DAT_PATH}geoip.dat"
|
||||||
echo "installed: ${DAT_PATH}geosite.dat"
|
echo "installed: ${DAT_PATH}geosite.dat"
|
||||||
fi
|
fi
|
||||||
|
if [[ "$CONFIG_NEW" -eq '1' ]]; then
|
||||||
|
echo "installed: ${JSON_PATH}config.json"
|
||||||
|
fi
|
||||||
if [[ "$CONFDIR" -eq '1' ]]; then
|
if [[ "$CONFDIR" -eq '1' ]]; then
|
||||||
echo "installed: ${JSON_PATH}00_log.json"
|
echo "installed: ${JSON_PATH}00_log.json"
|
||||||
echo "installed: ${JSON_PATH}01_api.json"
|
echo "installed: ${JSON_PATH}01_api.json"
|
||||||
|
|
Loading…
Reference in New Issue