移除路径变量末尾的斜杠
我个人更倾向于这样的风格,一方面我认为路径变量就应该使用目录的名字,而既然目录名里不会有 `/`,那所以变量里也不应该带。 另一方面我是真的担心会出现转义导致的问题,一个目录不可能以 `/` 结尾,但可以以 `\` 结尾。变量名里保证不去多此一举加上 `/` 的话,对于 `ugly\` 这样的目录名,我们就可以在之后用到这个变量的时候再来处理转义问题,而不需要对着变量值 `ugly\/` 头疼。pull/81/head
parent
77dc4df227
commit
55fe32f505
|
@ -340,9 +340,9 @@ decompression() {
|
||||||
install_file() {
|
install_file() {
|
||||||
NAME="$1"
|
NAME="$1"
|
||||||
if [[ "$NAME" == 'v2ray' ]] || [[ "$NAME" == 'v2ctl' ]]; then
|
if [[ "$NAME" == 'v2ray' ]] || [[ "$NAME" == 'v2ctl' ]]; then
|
||||||
install -m 755 "${TMP_DIRECTORY}$NAME" "/usr/local/bin/$NAME"
|
install -m 755 "${TMP_DIRECTORY}/$NAME" "/usr/local/bin/$NAME"
|
||||||
elif [[ "$NAME" == 'geoip.dat' ]] || [[ "$NAME" == 'geosite.dat' ]]; then
|
elif [[ "$NAME" == 'geoip.dat' ]] || [[ "$NAME" == 'geosite.dat' ]]; then
|
||||||
install -m 644 "${TMP_DIRECTORY}$NAME" "${DAT_PATH}$NAME"
|
install -m 644 "${TMP_DIRECTORY}/$NAME" "${DAT_PATH}$NAME"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,9 +381,9 @@ install_v2ray() {
|
||||||
|
|
||||||
install_startup_service_file() {
|
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
|
||||||
cat > "${TMP_DIRECTORY}systemd/system/v2ray.service" <<-EOF
|
cat > "${TMP_DIRECTORY}/systemd/system/v2ray.service" <<-EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=V2Ray Service
|
Description=V2Ray Service
|
||||||
After=network.target nss-lookup.target
|
After=network.target nss-lookup.target
|
||||||
|
@ -400,7 +400,7 @@ Restart=on-failure
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
cat > "${TMP_DIRECTORY}systemd/system/v2ray@.service" <<-EOF
|
cat > "${TMP_DIRECTORY}/systemd/system/v2ray@.service" <<-EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=V2Ray Service
|
Description=V2Ray Service
|
||||||
After=network.target nss-lookup.target
|
After=network.target nss-lookup.target
|
||||||
|
@ -417,8 +417,8 @@ Restart=on-failure
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
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'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -525,8 +525,8 @@ main() {
|
||||||
[[ "$REMOVE" -eq '1' ]] && remove_v2ray
|
[[ "$REMOVE" -eq '1' ]] && remove_v2ray
|
||||||
|
|
||||||
# Two very important variables
|
# Two very important variables
|
||||||
TMP_DIRECTORY="$(mktemp -du)/"
|
TMP_DIRECTORY="$(mktemp -du)"
|
||||||
ZIP_FILE="${TMP_DIRECTORY}v2ray-linux-$MACHINE.zip"
|
ZIP_FILE="${TMP_DIRECTORY}/v2ray-linux-$MACHINE.zip"
|
||||||
|
|
||||||
# Install V2Ray from a local file, but still need to make sure the network is available
|
# Install V2Ray from a local file, but still need to make sure the network is available
|
||||||
if [[ "$LOCAL_INSTALL" -eq '1' ]]; then
|
if [[ "$LOCAL_INSTALL" -eq '1' ]]; then
|
||||||
|
|
Loading…
Reference in New Issue