|
|
|
@ -1,3 +1,49 @@ |
|
|
|
|
_black() { echo -e "$(tput setaf 0)$*$(tput setaf 9)"; } |
|
|
|
|
_red() { echo -e "$(tput setaf 1)$*$(tput setaf 9)"; } |
|
|
|
|
_green() { echo -e "$(tput setaf 2)$*$(tput setaf 9)"; } |
|
|
|
|
_yellow() { echo -e "$(tput setaf 3)$*$(tput setaf 9)"; } |
|
|
|
|
_blue() { echo -e "$(tput setaf 4)$*$(tput setaf 9)"; } |
|
|
|
|
_magenta() { echo -e "$(tput setaf 5)$*$(tput setaf 9)"; } |
|
|
|
|
_cyan() { echo -e "$(tput setaf 6)$*$(tput setaf 9)"; } |
|
|
|
|
_white() { echo -e "$(tput setaf 7)$*$(tput setaf 9)"; } |
|
|
|
|
|
|
|
|
|
_addtocron () { |
|
|
|
|
local PROG="$1" |
|
|
|
|
local CRONLINE="$2" |
|
|
|
|
|
|
|
|
|
# empty crontab |
|
|
|
|
if ! crontab -l >/dev/null 2>&1; then |
|
|
|
|
echo "$CRONLINE" | crontab |
|
|
|
|
else |
|
|
|
|
# add if $PROG not exists |
|
|
|
|
if ! crontab -l | grep -q "$PROG"; then |
|
|
|
|
(crontab -l; echo "$CRONLINE") | crontab |
|
|
|
|
else |
|
|
|
|
echo "> $PROG exists in cron, skipping." |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_removefromcron () { |
|
|
|
|
local PROG="$1" |
|
|
|
|
if crontab -l | grep -q "$PROG"; then |
|
|
|
|
crontab -l | grep -v "$PROG" | crontab |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_disablecronmail() { |
|
|
|
|
if [[ ! -f /etc/sysconfig/crond ]]; then |
|
|
|
|
return 0 |
|
|
|
|
fi |
|
|
|
|
sed -i '/^CRONDARGS/d' /etc/sysconfig/crond |
|
|
|
|
if crond -h 2>&1 | grep -- '-s'; then |
|
|
|
|
sed -i '$aCRONDARGS="-s -m off"' /etc/sysconfig/crond |
|
|
|
|
else |
|
|
|
|
sed -i '$aCRONDARGS="-m off"' /etc/sysconfig/crond |
|
|
|
|
fi |
|
|
|
|
service crond restart |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_rm() { |
|
|
|
|
rm -rf "$@" |
|
|
|
|
} |
|
|
|
@ -17,15 +63,21 @@ _load() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
get_ip() { |
|
|
|
|
ip=$(curl -s https://ipinfo.io/ip) |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -s https://api.ip.sb/ip) |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -s https://api.ipify.org) |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -s https://ip.seeip.org) |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -s https://ifconfig.co/ip) |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -s https://api.myip.com | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -s icanhazip.com) |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -s myip.ipip.net | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") |
|
|
|
|
ip=$(curl -4 -s https://ipinfo.io/ip) |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -4 -s https://api.ip.sb/ip) |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -4 -s https://api.ipify.org) |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -4 -s https://ip.seeip.org) |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -4 -s https://ifconfig.co/ip) |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -4 -s https://api.myip.com | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -4 -s icanhazip.com) |
|
|
|
|
[[ -z $ip ]] && ip=$(curl -4 -s myip.ipip.net | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") |
|
|
|
|
[[ -z $ip ]] && echo -e "\n$red 这垃圾小鸡扔了吧!$none\n" && exit |
|
|
|
|
|
|
|
|
|
v6ip=$(curl -6 -s https://ifconfig.co/ip) |
|
|
|
|
[[ -z $v6ip ]] && v6ip=$(curl -6 -s https://api.ip.sb/ip) |
|
|
|
|
[[ -z $v6ip ]] && v6ip=$(curl -6 -s https://ip.seeip.org) |
|
|
|
|
[[ -z $v6ip ]] && v6ip=$(curl -6 -s http://icanhazip.com) |
|
|
|
|
[[ -z $v6ip ]] && v6ip=$(curl -6 -s https://api.myip.com | cut -d\" -f4) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
error() { |
|
|
|
|