Skip to content

Commit

Permalink
Add root uid judgment before running
Browse files Browse the repository at this point in the history
  • Loading branch information
tzwjkl committed Jun 7, 2020
1 parent a0a1c5a commit 4488a5c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions install-dat-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ V2RAY="/usr/local/lib/v2ray/"
DOWNLOAD_LINK_GEOIP="https://github.com/v2ray/geoip/releases/latest/download/geoip.dat"
DOWNLOAD_LINK_GEOSITE="https://github.com/v2ray/domain-list-community/releases/latest/download/dlc.dat"

check_if_running_as_root() {
if [ $UID != "0" ]; then
echo "error: You must run this script as root!"
exit 1
fi
}

download_geoip() {
curl -L -H 'Cache-Control: no-cache' -o "${V2RAY}geoip.dat.new" "$DOWNLOAD_LINK_GEOIP"
if [ "$?" -ne '0' ]; then
Expand Down Expand Up @@ -64,6 +71,7 @@ rename_new() {
}

main() {
check_if_running_as_root
download_geoip
download_geosite
rename_new
Expand Down
8 changes: 8 additions & 0 deletions install-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
# If the script executes incorrectly, go to:
# https://github.com/v2fly/fhs-install-v2ray/issues

check_if_running_as_root() {
if [ $UID != "0" ]; then
echo "error: You must run this script as root!"
exit 1
fi
}

identify_the_operating_system_and_architecture() {
if [[ "$(uname)" == 'Linux' ]]; then
case "$(uname -m)" in
Expand Down Expand Up @@ -459,6 +466,7 @@ show_help() {
}

main() {
check_if_running_as_root
identify_the_operating_system_and_architecture
judgment_parameters "$@"

Expand Down

0 comments on commit 4488a5c

Please sign in to comment.