Skip to content

Commit

Permalink
# 新增 ROOT 账号权限判断
Browse files Browse the repository at this point in the history
  • Loading branch information
Toyo authored Jul 29, 2018
1 parent 7f5ea45 commit 5eb0cf2
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 1 deletion.
4 changes: 4 additions & 0 deletions aria2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"

check_root(){
[[ $EUID != 0 ]] && echo -e "${Error} 当前非ROOT账号(或没有ROOT权限),无法继续操作,请更换ROOT账号或使用 ${Green_background_prefix}sudo su${Font_color_suffix} 命令获取临时ROOT权限(执行后可能会提示输入当前账号的密码)。" && exit 1
}
#检查系统
check_sys(){
if [[ -f /etc/redhat-release ]]; then
Expand Down Expand Up @@ -156,6 +159,7 @@ Installation_dependency(){
fi
}
Install_aria2(){
check_root
[[ -e ${aria2c} ]] && echo -e "${Error} Aria2 已安装,请检查 !" && exit 1
check_sys
echo -e "${Info} 开始安装/配置 依赖..."
Expand Down
2 changes: 1 addition & 1 deletion bbr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ filepath=$(cd "$(dirname "$0")"; pwd)
file=$(echo -e "${filepath}"|awk -F "$0" '{print $1}')

check_root(){
[[ $EUID != 0 ]] && echo -e "${Error} 当前账号非ROOT(或没有ROOT权限),无法继续操作,请使用${Green_background_prefix} sudo su ${Font_color_suffix}来获取临时ROOT权限(执行后会提示输入当前账号的密码)。" && exit 1
[[ $EUID != 0 ]] && echo -e "${Error} 当前非ROOT账号(或没有ROOT权限),无法继续操作,请更换ROOT账号或使用 ${Green_background_prefix}sudo su${Font_color_suffix} 命令获取临时ROOT权限(执行后可能会提示输入当前账号的密码)。" && exit 1
}
#检查系统
check_sys(){
Expand Down
4 changes: 4 additions & 0 deletions brook-pf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"

check_root(){
[[ $EUID != 0 ]] && echo -e "${Error} 当前非ROOT账号(或没有ROOT权限),无法继续操作,请更换ROOT账号或使用 ${Green_background_prefix}sudo su${Font_color_suffix} 命令获取临时ROOT权限(执行后可能会提示输入当前账号的密码)。" && exit 1
}
#检查系统
check_sys(){
if [[ -f /etc/redhat-release ]]; then
Expand Down Expand Up @@ -470,6 +473,7 @@ Modify_Enabled_pf(){
fi
}
Install_brook(){
check_root
[[ -e ${brook_file} ]] && echo -e "${Error} 检测到 Brook 已安装 !" && exit 1
echo -e "${Info} 开始安装/配置 依赖..."
Installation_dependency
Expand Down
4 changes: 4 additions & 0 deletions brook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"

check_root(){
[[ $EUID != 0 ]] && echo -e "${Error} 当前非ROOT账号(或没有ROOT权限),无法继续操作,请更换ROOT账号或使用 ${Green_background_prefix}sudo su${Font_color_suffix} 命令获取临时ROOT权限(执行后可能会提示输入当前账号的密码)。" && exit 1
}
#检查系统
check_sys(){
if [[ -f /etc/redhat-release ]]; then
Expand Down Expand Up @@ -330,6 +333,7 @@ Modify_protocol(){
Restart_brook
}
Install_brook(){
check_root
[[ -e ${brook_file} ]] && echo -e "${Error} 检测到 Brook 已安装 !" && exit 1
echo -e "${Info} 开始设置 用户配置..."
Set_port
Expand Down
4 changes: 4 additions & 0 deletions caddy_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ caddy_file="/usr/local/caddy/caddy"
caddy_conf_file="/usr/local/caddy/Caddyfile"
Info_font_prefix="\033[32m" && Error_font_prefix="\033[31m" && Info_background_prefix="\033[42;37m" && Error_background_prefix="\033[41;37m" && Font_suffix="\033[0m"

check_root(){
[[ $EUID != 0 ]] && echo -e "${Error} 当前非ROOT账号(或没有ROOT权限),无法继续操作,请更换ROOT账号或使用 ${Green_background_prefix}sudo su${Font_color_suffix} 命令获取临时ROOT权限(执行后可能会提示输入当前账号的密码)。" && exit 1
}
check_sys(){
if [[ -f /etc/redhat-release ]]; then
release="centos"
Expand Down Expand Up @@ -83,6 +86,7 @@ Service_caddy(){
fi
}
install_caddy(){
check_root
if [[ -e ${caddy_file} ]]; then
echo && echo -e "${Error_font_prefix}[信息]${Font_suffix} 检测到 Caddy 已安装,是否继续安装(覆盖更新)?[y/N]"
stty erase '^H' && read -p "(默认: n):" yn
Expand Down
4 changes: 4 additions & 0 deletions cloudt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"

check_root(){
[[ $EUID != 0 ]] && echo -e "${Error} 当前非ROOT账号(或没有ROOT权限),无法继续操作,请更换ROOT账号或使用 ${Green_background_prefix}sudo su${Font_color_suffix} 命令获取临时ROOT权限(执行后可能会提示输入当前账号的密码)。" && exit 1
}
#检查系统
check_sys(){
if [[ -f /etc/redhat-release ]]; then
Expand Down Expand Up @@ -203,6 +206,7 @@ Set_ct(){
Restart_ct
}
Install_ct(){
check_root
[[ -e ${ct_file} ]] && echo -e "${Error} 检测到 Cloud Torrent 已安装 !" && exit 1
check_sys
echo -e "${Info} 开始设置 用户配置..."
Expand Down
5 changes: 5 additions & 0 deletions dowsdns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ dowsdns_log="/tmp/dowsdns.log"
Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m"
Info="${Green_font_prefix}[信息]${Font_color_suffix}" && Error="${Red_font_prefix}[错误]${Font_color_suffix}" && Tip="${Green_font_prefix}[注意]${Font_color_suffix}"


check_root(){
[[ $EUID != 0 ]] && echo -e "${Error} 当前非ROOT账号(或没有ROOT权限),无法继续操作,请更换ROOT账号或使用 ${Green_background_prefix}sudo su${Font_color_suffix} 命令获取临时ROOT权限(执行后可能会提示输入当前账号的密码)。" && exit 1
}
#检查系统
check_sys(){
if [[ -f /etc/redhat-release ]]; then
Expand Down Expand Up @@ -423,6 +427,7 @@ Modify_wrcd(){
Restart_dowsdns
}
Install_dowsdns(){
check_root
[[ -e ${file} ]] && echo -e "${Error} 检测到 DowsDNS 已安装 !" && exit 1
check_sys
echo -e "${Info} 开始设置 用户配置..."
Expand Down
4 changes: 4 additions & 0 deletions goflyway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"

check_root(){
[[ $EUID != 0 ]] && echo -e "${Error} 当前非ROOT账号(或没有ROOT权限),无法继续操作,请更换ROOT账号或使用 ${Green_background_prefix}sudo su${Font_color_suffix} 命令获取临时ROOT权限(执行后可能会提示输入当前账号的密码)。" && exit 1
}
#检查系统
check_sys(){
if [[ -f /etc/redhat-release ]]; then
Expand Down Expand Up @@ -253,6 +256,7 @@ Set_goflyway(){
fi
}
Install_goflyway(){
check_root
[[ -e ${File} ]] && echo -e "${Error} 检测到 GoFlyway 已安装 !" && exit 1
echo -e "${Info} 开始设置 用户配置..."
Set_conf
Expand Down
4 changes: 4 additions & 0 deletions lightsocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"

check_root(){
[[ $EUID != 0 ]] && echo -e "${Error} 当前非ROOT账号(或没有ROOT权限),无法继续操作,请更换ROOT账号或使用 ${Green_background_prefix}sudo su${Font_color_suffix} 命令获取临时ROOT权限(执行后可能会提示输入当前账号的密码)。" && exit 1
}
#检查系统
check_sys(){
if [[ -f /etc/redhat-release ]]; then
Expand Down Expand Up @@ -232,6 +235,7 @@ Modify_config_password(){
fi
}
Install_lightsocks(){
check_root
[[ -e ${lightsocks_file} ]] && echo -e "${Error} 检测到 Lightsocks 已安装 !" && exit 1
echo -e "${Info} 开始设置 用户配置..."
Set_port
Expand Down
4 changes: 4 additions & 0 deletions mtproxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"

check_root(){
[[ $EUID != 0 ]] && echo -e "${Error} 当前非ROOT账号(或没有ROOT权限),无法继续操作,请更换ROOT账号或使用 ${Green_background_prefix}sudo su${Font_color_suffix} 命令获取临时ROOT权限(执行后可能会提示输入当前账号的密码)。" && exit 1
}
#检查系统
check_sys(){
if [[ -f /etc/redhat-release ]]; then
Expand Down Expand Up @@ -232,6 +235,7 @@ Set_mtproxy(){
fi
}
Install_mtproxy(){
check_root
[[ -e ${mtproxy_file} ]] && echo -e "${Error} 检测到 MTProxy 已安装 !" && exit 1
echo -e "${Info} 开始设置 用户配置..."
Set_port
Expand Down
4 changes: 4 additions & 0 deletions ocserv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"

check_root(){
[[ $EUID != 0 ]] && echo -e "${Error} 当前非ROOT账号(或没有ROOT权限),无法继续操作,请更换ROOT账号或使用 ${Green_background_prefix}sudo su${Font_color_suffix} 命令获取临时ROOT权限(执行后可能会提示输入当前账号的密码)。" && exit 1
}
#检查系统
check_sys(){
if [[ -f /etc/redhat-release ]]; then
Expand Down Expand Up @@ -158,6 +161,7 @@ Installation_dependency(){
fi
}
Install_ocserv(){
check_root
[[ -e ${file} ]] && echo -e "${Error} ocserv 已安装,请检查 !" && exit 1
echo -e "${Info} 开始安装/配置 依赖..."
Installation_dependency
Expand Down

0 comments on commit 5eb0cf2

Please sign in to comment.