├── README.md └── scripts ├── docker-enter ├── flexgettt ├── iperfff ├── ipv6 ├── mountall ├── my-alias ├── r8168 ├── syslog └── torrent-rename /README.md: -------------------------------------------------------------------------------- 1 | # aBox 2 | Bash scripts for dedicated seedbox with root privilege. 3 | 4 | 有些就是我把原先的自用脚本给放出来,因此懒得写什么使用教程和交互界面。 5 | 6 | IPv6 配置脚本 7 | ``` 8 | bash <(wget -qO- https://github.com/Aniverse/aBox/raw/master/scripts/ipv6) 9 | ``` 10 | 11 | iperf 测速脚本 12 | ``` 13 | bash <(wget -qO- https://github.com/Aniverse/aBox/raw/master/scripts/iperfff) 14 | ``` 15 | 16 | 螃蟹卡换 8168 驱动(成功几率不是很高) 17 | ``` 18 | bash <(wget -qO- https://github.com/Aniverse/aBox/raw/master/scripts/r8168) 19 | ``` 20 | 21 | flexget 配置脚本 22 | ``` 23 | bash <(wget -qO- https://github.com/Aniverse/aBox/raw/master/scripts/flexgettt) -i 24 | flexgettt 25 | ``` 26 | 27 | ------------------- 28 | 29 | bench 测试脚本,支持硬盘 4K 性能测试、独服硬盘通电时间检测 30 | ``` 31 | bash <(wget -qO- git.io/ceshi) 32 | ``` 33 | 34 | 锐速、bbr、魔改 bbr、bbrplus 脚本 35 | ``` 36 | bash <(wget -qO- git.io/AccTCP) 37 | ``` 38 | 39 | inexistence 客户端安装脚本 40 | ``` 41 | bash <(wget -qO- git.io/abcde) 42 | ``` 43 | 44 | 自动挂载 ISO、扫 BDinfo、截图脚本 45 | ``` 46 | bash <(wget -qO- git.io/bluray) -u 47 | bluray 48 | ``` 49 | -------------------------------------------------------------------------------- /scripts/docker-enter: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Don't know who is the original author. 3 | # See also 4 | # https://github.com/sequenceiq/docker-enter 5 | # https://github.com/Pithikos/docker-enter 6 | # https://github.com/BradleyA/docker-security-infrastructure/blob/dev/swarm/docker-enter 7 | 8 | 9 | if [ -e $(dirname "$0")/nsenter ]; then 10 | # with boot2docker, nsenter is not in the PATH but it is in the same folder 11 | NSENTER=$(dirname "$0")/nsenter 12 | else 13 | NSENTER=nsenter 14 | fi 15 | 16 | if [ -z "$1" ]; then 17 | echo "Usage: `basename "$0"` CONTAINER [COMMAND [ARG]...]" 18 | echo "" 19 | echo "Enters the Docker CONTAINER and executes the specified COMMAND." 20 | echo "If COMMAND is not specified, runs an interactive shell in CONTAINER." 21 | else 22 | PID=$(docker inspect --format "{{.State.Pid}}" "$1") 23 | if [ -z "$PID" ]; then 24 | exit 1 25 | fi 26 | shift 27 | 28 | OPTS="--target $PID --mount --uts --ipc --net --pid --" 29 | 30 | if [ -z "$1" ]; then 31 | # No command given. 32 | # Use su to clear all host environment variables except for TERM, 33 | # initialize the environment variables HOME, SHELL, USER, LOGNAME, PATH, 34 | # and start a login shell. 35 | "$NSENTER" $OPTS su - root 36 | else 37 | # Use env to clear all host environment variables. 38 | "$NSENTER" $OPTS env --ignore-environment -- "$@" 39 | fi 40 | fi 41 | -------------------------------------------------------------------------------- /scripts/flexgettt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: Aniverse 3 | # https://github.com/Aniverse/aBox 4 | 5 | script_update=2020.08.20 6 | script_version=r21133 7 | 8 | ######################################################################################################## 9 | 10 | usage_guide() { 11 | bash <(wget -qO- https://github.com/Aniverse/aBox/raw/master/scripts/flexgettt) -i 12 | s=/usr/local/bin/flexgettt ; rm -f $s ; nano $s ; chmod 755 $s 13 | } 14 | 15 | ######################################################################################################## 16 | 17 | OPTS=$(getopt -o nlcxtis:u: --long "install,normal,log,cron,learn,test,log-backup,log-clean,search:,user:,ll,clean-db,edit,check,conf" -- "$@") 18 | eval set -- "$OPTS" 19 | [ ! $? = 0 ] && { echo -e "Invalid option: $1" ; mode=usage ; } 20 | 21 | while true; do 22 | case "$1" in 23 | -i | --install ) mode=install ; shift ;; 24 | -n | --normal ) mode=normal ; shift ;; 25 | -l | --log ) mode=show_log ; shift ;; 26 | --ll ) mode=tail_f_log ; shift ;; 27 | -c | --cron ) mode=add2cron ; shift ;; 28 | -x | --learn ) mode=fg_learn ; shift ;; 29 | -t | --test ) mode=fg_test ; shift ;; 30 | -s | --search ) keyword="$2" ; mode=log_search ; shift 2 ;; 31 | -u | --user ) iUser=$2 ; shift 2 ;; 32 | --log-backup) mode=log_bak ; shift ;; 33 | --log-clean ) mode=log_clean ; shift ;; 34 | --clean-db ) mode=clean_db ; shift ;; 35 | --edit ) mode=edit_conf ; shift ;; 36 | --check ) mode=check ; shift ;; 37 | --conf ) mode=show_conf ; shift ;; 38 | # -- ) shift; break ;; 39 | * ) break ;; 40 | esac 41 | done 42 | 43 | [[ -z $mode ]] && mode=usage 44 | [[ $EUID != 0 ]] && echo -e "This script is designed for user with ROOT privilege" && exit 1 45 | 46 | function export_inexistence_info() { 47 | CODENAME=$(cat /etc/os-release | grep VERSION= | tr '[A-Z]' '[a-z]' | sed 's/\"\|(\|)\|[0-9.,]\|version\|lts//g' | awk '{print $2}' | head -1) 48 | inexistence_ver=$( cat /log/inexistence/info/version.txt 2>/dev/null | grep inexistence.version | awk '{print $NF}' | head -1) 49 | inexistence_date=$(cat /log/inexistence/info/version.txt 2>/dev/null | grep inexistence.update | awk '{print $NF}' | head -1) 50 | asnnnnn=$(cat $LogBase/info/asn.txt 2>/dev/null) 51 | serveripv4=$(cat $LogBase/info/serveripv4.txt 2>/dev/null) 52 | serveripv6=$(cat $LogBase/info/serveripv6.txt 2>/dev/null) 53 | [[ -f /log/inexistence/.lock/tweaks.lock ]] && tweaks_enabled=1 54 | 55 | DefaultiUser=$(cat /log/inexistence/info/installed.user.list.txt 2>/dev/null | head -1) 56 | [[ -z $iUser ]] && iUser=$DefaultiUser 57 | iHome=$(eval echo "~$iUser") 58 | passphrase=$(cat /root/.ssh/users/${iUser} 2>/dev/null) 59 | passtext=$(cat /log/inexistence/users/${iUser}.info 2>/dev/null | cut -d: -f2) 60 | if [[ "$CODENAME" =~ (jessie|xenial) ]]; then 61 | iPass=$(echo ${passtext} | openssl enc -aes-128-ecb -a -d -pass pass:${passphrase} -nosalt 2>/dev/null) 62 | else 63 | iPass=$(echo ${passtext} | openssl enc -aes-128-ecb -pbkdf2 -a -d -pass pass:${passphrase} -nosalt 2>/dev/null) 64 | fi 65 | } 66 | export_inexistence_info 67 | 68 | ######################################################################################################## 69 | 70 | config=$iHome/.config/flexget 71 | config_file=$iHome/.config/flexget/config.yml 72 | config_flag="-c $config_file" 73 | log=/log/script/flexget/0.log 74 | log_folder=/log/script/flexgettt 75 | flexget_log=$iHome/.config/flexget/flexget.log 76 | flexget_cmd=/usr/local/bin/flexget 77 | 78 | user=$(whoami) 79 | S_dirrname="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 80 | S_filename="$( basename $BASH_SOURCE )" 81 | S_Path="$S_dirrname/$S_filename" 82 | S_Path_sed="$(echo $S_Path | sed -e 's/\//\\\//g')" 83 | 84 | black='\033[0;30m' ; red='\033[0;31m' ; green='\033[0;32m' ; yellow='\033[0;33m' ; blue='\033[0;34m' 85 | magenta='\033[0;35m' ; cyan='\033[0;36m'; white='\033[0;37m' ; normal='\033[0m' ; bold='\033[1m' 86 | on_red='\033[41;37m' ; on_cyan='\033[46;37m' ; heihuangse='\033[43;30m' 87 | 88 | [[ ! -w "$log" ]] && { mkdir -p "$(dirname "$log")" ; touch "$log" ; chmod -R 644 "$(dirname "$log")" ; } 89 | 90 | # split -b 65535000 -d -a 4 input ouptput_$(date "+%Y-%m-%d") 91 | # $(date "+%Y-%m-%d %H:%M") 92 | 93 | ######################################################################################################## 94 | 95 | lines() { printf "%-100s\n" "-" | sed 's/\s/-/g' ; } 96 | logs_rm_lock() { echo -e "${on_red}${bold}$(date "+%Y-%m-%d %H:%M:%S") ANIVERSE script DELETED $config/.config-lock${normal}" ; } 97 | logs_mv_bak () { echo -e "${on_red}${bold}$(date "+%Y-%m-%d %H:%M:%S") ANIVERSE script MOVE $config/$bak${normal}" ; } 98 | logs_execute() { lines ; echo -e "\n\n\n${on_cyan}${bold}$(date "+%Y-%m-%d %H:%M:%S") ANIVERSE script execute${normal}" ; lines ; } 99 | 100 | ######################################################################################################## 101 | 102 | #flexget_rm_lock 103 | if [[ -f $config/.config-lock ]]; then 104 | rm -f $config/.config-lock >> $log 2>&1 105 | logs_rm_lock >> $log 106 | fi 107 | 108 | #flexget_mv_config_bak 109 | if ls $config | grep config.*bak -q ; then 110 | mkdir -p $config/config_backup 111 | mv -f $config/config*bak $config/config_backup >> $log 2>&1 112 | bak=$(ls $config | grep config.*bak) 113 | logs_mv_bak >> $log 114 | fi 115 | 116 | flexget_learn() { runuser -l $iUser -c "flexget execute --learn" ; } 117 | flexget_test () { runuser -l $iUser -c "flexget --test --loglevel debug execute" ; } 118 | 119 | install_script() { 120 | if [[ $EUID == 0 ]]; then 121 | wget -qO /usr/local/bin/flexgettt https://github.com/Aniverse/aBox/raw/master/scripts/flexgettt 122 | chmod 755 /usr/local/bin/flexgettt 123 | else 124 | mkdir -p $HOME/.local/bin 125 | wget -qO $HOME/.local/bin/flexgettt https://github.com/Aniverse/aBox/raw/master/scripts/flexgettt 126 | chmod 755 $HOME/.local/bin/flexgettt 127 | fi 128 | } 129 | 130 | flexget_log() { 131 | tail -1000 $log #| sed -r -e "s|(\b20[0-9:-]+ [0-9:]+\b) VERBOSE |${yellow}\1${normal}|g" -e "s/REJECTED/${red}REJECTED${normal}/g" -e "s/ACCEPTED/${red}ACCEPTED${normal}/g" 132 | echo -e "${bold}\ngrep -C100 23:33 $log\ngrep --color=never -C100 'DELETED $config/.config-lock' $log\n${normal}" 133 | } 134 | 135 | clean_db() { 136 | rm -f $config/db-config.sqlite 137 | runuser -l $iUser -c "flexget web passwd $iPass" 138 | } 139 | 140 | tail_f_log() { 141 | tail -f $log 142 | } 143 | 144 | log_serach() { 145 | grep -i "$keyword" $log | head -100 146 | echo ; lines ; echo 147 | grep -i "$keyword" $(cat /log/script/flexgettt/lastlog.name) | head -100 148 | echo -e "\n${on_red}grep -C5 \"$keyword\" $log${normal}\n" 149 | } 150 | 151 | log_backup_daily() { 152 | mkdir -p $log_folder 153 | cp -f $log $log_folder/$(date "+%Y-%m-%d").log 154 | echo -n > $log 155 | echo -e "$log_folder/$(date "+%Y-%m-%d").log" > /log/script/flexgettt/lastlog.name 156 | } 157 | 158 | log_clean() { 159 | rm -rf $log_folder/* 160 | rm -f $config/flexget.*.log $config/crash_report.*.log config-*.bak 161 | echo -n > $log 162 | echo "ll $config" 163 | } 164 | 165 | flexget_execute() { 166 | logs_execute >> $log 167 | # From FlexGet 3.1.7, log colors are stripped when redirecting output 168 | # https://github.com/Flexget/Flexget/compare/v3.1.6...v3.1.7 169 | # https://github.com/Flexget/Flexget/commit/6ead240174e1c95af4fcbf58e56e97bed569a777 170 | # /usr/bin/time -f "Time used: %e" -a -o $log "$flexget_cmd" $config_flag execute --no-cache >> $log 2>&1 171 | 172 | # So we use script to cap all original output to logfile 173 | # https://stackoverflow.com/questions/3515208/can-colorized-output-be-captured-via-shell-redirect 174 | # /usr/bin/time -f "Time used: %e" -a -o $log script --flush --quiet --command "$flexget_cmd $config_flag execute --no-cache" >> $log 2>&1 175 | /usr/bin/time -f "Time used: %e" -a -o $log /usr/sbin/runuser -l $iUser -c "script --flush --quiet --command '$flexget_cmd execute --no-cache'" >> $log 2>&1 176 | } 177 | 178 | edit_conf() { 179 | echo -n > $config_file 180 | nano $config_file 181 | } 182 | 183 | show_conf() { 184 | cat $config_file 185 | echo -e "\n$config_file\n" 186 | } 187 | 188 | flexget_check() { 189 | runuser -l $iUser -c "flexget check" 190 | } 191 | 192 | flexget_add2cron() { 193 | echo 194 | crontab -u $user -l 2>1 | grep -q "$S_Path" || NoCron=1 195 | 196 | if [[ $NoCron == 1 ]]; then 197 | echo -ne "${yellow}${bold}How many minutes of intervals would you like?${normal} " ; read -e interval 198 | if [[ $interval -gt 0 ]] ; then 199 | cronline="*/$interval * * * * $S_Path -n" 200 | cronline2="0 0 * * * $S_Path --log-backup" 201 | ( crontab -u $user -l ; echo "$cronline" ) | crontab -u $user - 202 | ( crontab -u $user -l ; echo "$cronline2" ) | crontab -u $user - 203 | echo -e "\n${green}${bold}FlexGet crontab enabled${normal}\n" 204 | else 205 | echo -e "\n${bold}Nothing to do, exit${normal}\n" 206 | fi 207 | else 208 | interval2=$(crontab -u $user -l | grep -a "$S_Path" | grep -v "log-backup" | awk '{print $1}' | grep -oE "[0-9]+") 209 | echo -e "${bold}FlexGet RSS enabled, current interval is ${heihuangse}$interval2${jiacu} minute(s)${normal}" 210 | echo -e "${bold}Press enter to do nothing, 0 to disable Flexget, or other numbers to be wanted interval${normal}" 211 | echo -ne "${yellow}${bold}How many minutes of intervals would you like?${normal} " ; read -e interval 212 | if [[ $interval -gt 0 ]] ; then 213 | cronline="*/$interval * * * * $S_Path -n" 214 | ( crontab -u $user -l | sed "/.*$S_Path_sed/"d ) | crontab -u $user - 215 | ( crontab -u $user -l ; echo "$cronline" ) | crontab -u $user - 216 | echo -e "\n${green}${bold}Changed interval to $interval${normal}\n" 217 | elif [[ $interval = 0 ]] ; then 218 | ( crontab -u $user -l | sed "/.*$S_Path_sed/"d ) | crontab -u $user - 219 | echo -e "\n${green}${bold}Disabled Flexget cron${normal}\n" 220 | else 221 | echo -e "\n${bold}Nothing to do, exit${normal}\n" 222 | fi 223 | fi 224 | } 225 | 226 | show_usage() { 227 | echo " 228 | flexgettt $script_version ($script_update) 229 | 230 | -i install script 231 | -n flexget execute 232 | -c Enable or Disable flexget cron 233 | -l tail -1000 $log 234 | --ll tail -f $log 235 | -x flexget execute --learn 236 | -t flexget --test --loglevel debug execute 237 | echo -n > $log 238 | -s search log, eg. flexgettt -s 23:33 239 | -u specify user for flexget running, eg. flexgettt -u $iUser -n 240 | 241 | --clean-db Clean database file, reset web password 242 | --log-clean clean $log_folder/* and clean $log 243 | --log-backup cp -f $log $log_folder/$(date "+%Y-%m-%d").log 244 | --edit Clean $config_file and use nano to edit it 245 | --check check $config_file 246 | --conf Show $config_file 247 | " 248 | } 249 | 250 | case $mode in 251 | install ) install_script ;; 252 | normal ) flexget_execute ;; 253 | show_log ) flexget_log ;; 254 | add2cron ) flexget_add2cron ;; 255 | fg_test ) flexget_test ;; 256 | fg_learn ) flexget_learn ;; 257 | log_bak ) log_backup_daily ;; 258 | log_clean ) log_clean ;; 259 | usage ) show_usage ;; 260 | log_search ) log_serach ;; 261 | tail_f_log ) tail_f_log ;; 262 | clean_db ) clean_db ;; 263 | edit_conf ) edit_conf ;; 264 | check ) flexget_check ;; 265 | show_conf ) show_conf ;; 266 | esac 267 | -------------------------------------------------------------------------------- /scripts/iperfff: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: Aniverse 3 | # https://github.com/Aniverse/aBox 4 | 5 | script_update=2020.02.20 6 | script_version=r10006 7 | 8 | ######################################################################################################## 9 | 10 | usage_guide() { 11 | bash <(wget -qO- https://github.com/Aniverse/aBox/raw/master/scripts/iperfff) 12 | s=/usr/local/bin/iperfff ; rm -f $s ; nano $s ; chmod 755 $s 13 | } 14 | 15 | # https://iperf.fr/iperf-servers.php 16 | # https://iperf.cc/ 17 | 18 | ######################################################################################################## 19 | 20 | iperf_cmd=$(which iperf) 21 | iperf3_cmd=$(which iperf3) 22 | times=10 23 | parallel=1 24 | flags="" 25 | 26 | black=$(tput setaf 0) ; red=$(tput setaf 1) ; green=$(tput setaf 2) ; yellow=$(tput setaf 3); bold=$(tput bold) 27 | blue=$(tput setaf 4) ; magenta=$(tput setaf 5) ; cyan=$(tput setaf 6) ; white=$(tput setaf 7) ; normal=$(tput sgr0) 28 | on_black=$(tput setab 0); on_red=$(tput setab 1) ; on_green=$(tput setab 2); on_yellow=$(tput setab 3) 29 | on_blue=$(tput setab 4) ; on_magenta=$(tput setab 5) ; on_cyan=$(tput setab 6) ; on_white=$(tput setab 7) 30 | shanshuo=$(tput blink) ; wuguangbiao=$(tput civis) ; guangbiao=$(tput cnorm) ; jiacu=${normal}${bold} 31 | underline=$(tput smul) ; reset_underline=$(tput rmul) ; dim=$(tput dim) 32 | standout=$(tput smso) ; reset_standout=$(tput rmso) ; title=${standout} 33 | baihuangse=${white}${on_yellow}; bailanse=${white}${on_blue} ; bailvse=${white}${on_green} 34 | baiqingse=${white}${on_cyan} ; baihongse=${white}${on_red} ; baizise=${white}${on_magenta} 35 | heibaise=${black}${on_white} ; heihuangse=${on_yellow}${black} 36 | 37 | function _print() { printf "${bold}${normal}%s${normal}\n" "$@" ; } 38 | function _info() { printf "${bold}${cyan}➜ %s${normal}\n" "$@" ; } 39 | function _success() { printf "${bold}${green}✓ %s${normal}\n" "$@" ; } 40 | function _warning() { printf "${bold}${yellow}⚠ %s${normal}\n" "$@" ; } 41 | function _error() { printf "${bold}${red}✗ %s${normal}\n" "$@" ; } 42 | 43 | get_opsy() { [ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return 44 | [ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return 45 | [ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return ; } 46 | get_opsy | grep -qiE "debian|ubuntu" && pm=apt 47 | get_opsy | grep -qiE "centos" && pm=yum 48 | 49 | 50 | ######################################################################################################## 51 | 52 | 53 | root_install_iperf() { 54 | if [[ $pm == apt ]]; then 55 | DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" update 56 | DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install iperf iperf3 57 | elif [[ $pm == yum ]]; then 58 | yum update 59 | yum -y install iperf 60 | yum -y install iperf3 61 | fi 62 | iperf_cmd=$(which iperf) 63 | iperf3_cmd=$(which iperf3) 64 | } 65 | 66 | build_iperf() { 67 | mkdir -p $HOME/.local 68 | cd $HOME 69 | wget https://github.com/esnet/iperf/archive/3.7.tar.gz -O iperf.3.7.tar.gz 70 | tar zxf iperf.3.7.tar.gz 71 | cd iperf-3.7 72 | ./configure --prefix=$HOME/.local 73 | make -j$(nproc) 74 | make install 75 | cd .. 76 | 77 | wget https://iperf.fr/download/source/iperf-2.0.9-source.tar.gz 78 | tar zxf iperf-2.0.9-source.tar.gz 79 | cd iperf-2.0.9 80 | ./configure --prefix=$HOME/.local 81 | make -j$(nproc) 82 | make install 83 | cd $HOME 84 | rm -rf $HOME/iperf* 85 | 86 | iperf_cmd="$HOME/.local/bin/iperf" 87 | iperf3_cmd="$HOME/.local/bin/iperf3" 88 | } 89 | 90 | install_iperf() { 91 | if [[ $EUID == 0 ]]; then 92 | root_install_iperf 93 | else 94 | build_iperf 95 | fi 96 | } 97 | 98 | check_iperf() { 99 | no_iperf=0 100 | [[ -x $iperf_cmd ]] || { _warning "No iperf found!" && no_iperf=1 ; } 101 | [[ -x $iperf3_cmd ]] || { _warning "No iperf3 found!" && no_iperf=1 ; } 102 | } 103 | 104 | iperf_test_while_true() { 105 | local seconds=20 106 | while true ; do 107 | seconds=$(( $seconds - 1 )) 108 | echo -ne "[$seconds] " 109 | $do_iperf_cmd -c $server -i 1 -t $times -P $parallel $flags && break 110 | if [ $seconds = 0 ]; then 111 | _error "该节点正忙或无法使用" ; echo 112 | return 1 113 | fi 114 | sleep 1 115 | done 116 | } 117 | 118 | function iperf_menu() { 119 | if [[ $mode == iperf ]]; then 120 | do_iperf_cmd=$iperf_cmd 121 | elif [[ $mode == iperf3 ]]; then 122 | do_iperf_cmd=$iperf3_cmd 123 | fi 124 | clear 125 | cat << EOF 126 | ${bold}${on_magenta}iperf 节点${jiacu} 127 | ${green}<11>${cyan} 法国 Online ${blue}ping.online.net${jiacu} 128 | ${green}<12>${cyan} 法国 OVH ${blue}iperf.ovh.net${jiacu} 129 | ${green}<13>${cyan} 加拿大 OVH ${blue}bhs.proof.ovh.net${jiacu} 130 | ${green}<14>${cyan} 荷兰 NFOrce ${blue}mirror.nforce.com${jiacu} 131 | ${green}<15>${cyan} 荷兰 Serverius ${blue}speedtest.serverius.net${jiacu} 132 | ${green}<16>${cyan} 美国 ACD ${blue}iperf.acd.net${jiacu} 133 | 134 | ${on_magenta}iperf3 节点${jiacu} 135 | ${green}<21>${cyan} 法国 Bouygues ${blue}bouygues.testdebit.info${jiacu} 136 | ${green}<22>${cyan} 法国 Online ${blue}ping.online.net${jiacu} 137 | ${green}<23>${cyan} 荷兰 Online ${blue}ping-ams1.online.net${jiacu} 138 | ${green}<24>${cyan} 荷兰 WorldStream ${blue}iperf.worldstream.nl${jiacu} 139 | ${green}<25>${cyan} 荷兰 YISP ${blue}speedtest.yisp.nl${jiacu} 140 | ${green}<26>${cyan} 德国 wilhelm.tel ${blue}speedtest.wtnet.de${jiacu} 141 | ${green}<27>${cyan} 美国 HE ${blue}iperf.he.net${jiacu} 142 | 143 | ${magenta}<0>${jiacu} iperf 程序路径:${yellow}$do_iperf_cmd${jiacu} 144 | ${magenta}<1>${jiacu} 当前选择的服务器:${yellow}$server${jiacu} 145 | ${magenta}<2>${jiacu} 测试时长:${yellow}$times ${jiacu}秒(每秒一次) 146 | ${magenta}<3>${jiacu} 线程数:${yellow}$parallel${jiacu} 147 | ${magenta}<4>${jiacu} 其他参数:${yellow}$flags ${jiacu}(不懂的话就不用改) 148 | 149 | ${red}<9>${jiacu} 退出脚本 150 | 151 | 测试命令:${heihuangse} $do_iperf_cmd -c $server -i 1 -t $times -P $parallel $flags ${normal} 152 | 153 | EOF 154 | read -ep "${bold}输入对应的数值进行修改,敲回车开始测试${blue} " response ; echo "${normal}" 155 | case $response in 156 | 11) mode=iperf ; server=ping.online.net ; iperf_menu ;; 157 | 12) mode=iperf ; server=iperf.ovh.net ; iperf_menu ;; 158 | 13) mode=iperf ; server=bhs.proof.ovh.net ; iperf_menu ;; 159 | 14) mode=iperf ; server=mirror.nforce.com ; iperf_menu ;; 160 | 15) mode=iperf ; server=speedtest.serverius.net ; iperf_menu ;; 161 | 16) mode=iperf ; server=iperf.acd.net ; iperf_menu ;; 162 | 21) mode=iperf3 ; server=bouygues.testdebit.info ; iperf_menu ;; 163 | 22) mode=iperf3 ; server=ping.online.net ; iperf_menu ;; 164 | 23) mode=iperf3 ; server=ping-ams1.online.net ; iperf_menu ;; 165 | 24) mode=iperf3 ; server=iperf.worldstream.nl ; iperf_menu ;; 166 | 25) mode=iperf3 ; server=speedtest.yisp.nl ; iperf_menu ;; 167 | 26) mode=iperf3 ; server=speedtest.wtnet.de ; iperf_menu ;; 168 | 27) mode=iperf3 ; server=iperf.he.net ; iperf_menu ;; 169 | 0) read -ep "${bold}用哪个程序?${blue}" do_iperf_cmd ; echo -n "${normal}" ; iperf_menu ;; 170 | 1) read -ep "${bold}自定义节点:${blue}" server ; echo -n "${normal}" ; iperf_menu ;; 171 | 2) read -ep "${bold}测试多少秒?${blue}" times ; echo -n "${normal}" ; iperf_menu ;; 172 | 3) read -ep "${bold}用几个线程?${blue}" parallel ; echo -n "${normal}" ; iperf_menu ;; 173 | 4) read -ep "${bold}输入要用的参数?${blue}" flags ; echo -n "${normal}" ; iperf_menu ;; 174 | 9) exit ;; 175 | *) [[ -z $server || -z $do_iperf_cmd ]] && { _error "未指定服务器或 iperf 程序路径,请重新运行脚本并指定!" ; echo ; exit 1; } ;; 176 | esac 177 | } 178 | 179 | ######################################################################## 180 | 181 | check_iperf 182 | if [[ $no_iperf == 1 ]]; then 183 | _info "Now trying to install iperf and iperf3 ..." 184 | install_iperf 185 | fi 186 | check_iperf 187 | if [[ $no_iperf == 1 ]]; then 188 | _error "No executable iperf found, exiting ..." 189 | exit 1 190 | fi 191 | 192 | iperf_menu 193 | iperf_test_while_true 194 | -------------------------------------------------------------------------------- /scripts/ipv6: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # https://github.com/Aniverse/aBox 4 | # Author: Aniverse 5 | # 6 | script_update=2020.05.23 7 | script_version=r31218 8 | ################################################################################################ 9 | 10 | usage_guide() { 11 | s=/usr/local/bin/ipv6;rm -f $s;nano $s;chmod 755 $s 12 | bash <(wget -qO- https://github.com/Aniverse/aBox/raw/master/scripts/ipv6) -m ol2 -6 XXX -d XXX -s 56 13 | } 14 | 15 | ################################################################################################ Get options 16 | 17 | reboot=no 18 | ip_check=y 19 | 20 | OPTS=$(getopt -o m:d:s:6:i:g:rhtc --long "mode:,ipv6:,duid:,subnet:,interface:,gateway:,help,reboot,test,clean" -- "$@") 21 | [ ! $? = 0 ] && { echo -e "Invalid option" ; exit 1 ; } 22 | eval set -- "$OPTS" 23 | 24 | while true; do 25 | case "$1" in 26 | -m | --mode ) mode="$2" ; shift 2 ;; 27 | -6 | --ipv6 ) IPv6="$2" ; shift 2 ;; 28 | -d | --duid ) DUID="$2" ; shift 2 ;; 29 | -s | --subnet ) subnet="$2" ; shift 2 ;; 30 | -g | --gateway ) v6gw="$2" ; shift 2 ;; 31 | -i | --interface ) interface="$2" ; shift 2 ;; 32 | -r | --reboot ) reboot=yes ; shift ;; 33 | -h | --help ) mode=h ; shift ;; 34 | -t | --test ) mode=t ; shift ;; 35 | -c | --clean ) mode=c ; shift ;; 36 | * ) break ;; 37 | esac 38 | done 39 | 40 | [[ -z $mode ]] && mode=m 41 | 42 | ################################################################################################ Colors 43 | 44 | black=$(tput setaf 0) ; red=$(tput setaf 1) ; green=$(tput setaf 2) ; yellow=$(tput setaf 3); bold=$(tput bold) 45 | blue=$(tput setaf 4) ; magenta=$(tput setaf 5) ; cyan=$(tput setaf 6) ; white=$(tput setaf 7) ; normal=$(tput sgr0) 46 | on_black=$(tput setab 0); on_red=$(tput setab 1) ; on_green=$(tput setab 2); on_yellow=$(tput setab 3) 47 | on_blue=$(tput setab 4) ; on_magenta=$(tput setab 5) ; on_cyan=$(tput setab 6) ; on_white=$(tput setab 7) 48 | shanshuo=$(tput blink) ; wuguangbiao=$(tput civis) ; guangbiao=$(tput cnorm) ; jiacu=${normal}${bold} 49 | underline=$(tput smul) ; reset_underline=$(tput rmul) ; dim=$(tput dim) 50 | standout=$(tput smso) ; reset_standout=$(tput rmso) ; title=${standout} 51 | baihuangse=${white}${on_yellow}; bailanse=${white}${on_blue} ; bailvse=${white}${on_green} 52 | baiqingse=${white}${on_cyan} ; baihongse=${white}${on_red} ; baizise=${white}${on_magenta} 53 | heibaise=${black}${on_white} ; heihuangse=${on_yellow}${black} 54 | CW="${bold}${baihongse} ERROR ${jiacu}";ZY="${baihongse}${bold} ATTENTION ${jiacu}";JG="${baihongse}${bold} WARNING ${jiacu}" 55 | 56 | ################################################################################################ 57 | 58 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$PATH 59 | 60 | SysSupport="可能不支持" 61 | DISTRO=$(awk -F'[= "]' '/PRETTY_NAME/{print $3}' /etc/os-release) 62 | CODENAME=$(cat /etc/os-release | grep VERSION= | tr '[A-Z]' '[a-z]' | sed 's/\"\|(\|)\|[0-9.,]\|version\|lts//g' | awk '{print $2}') 63 | [[ $DISTRO == Ubuntu ]] && osversion=$(grep Ubuntu /etc/issue | head -1 | grep -oE "[0-9.]+") 64 | [[ $DISTRO == Debian ]] && osversion=$(cat /etc/debian_version) 65 | [[ $CODENAME =~ (xenial|bionic|jessie|stretch|) ]] && SysSupport="支持" 66 | #[[ $SysSupport == 0 ]] && echo -e "${red}Your system is not supported!${normal}" && exit 1 67 | type=ifdown 68 | [[ -f /etc/netplan/01-netcfg.yaml ]] && [[ $CODENAME == bionic ]] && type=netplan 69 | [[ $type == ifdown ]] && [[ -z $(which ifdown) ]] && { echo -e "${green}Installing ifdown ...${normal}" ; apt-get install ifupdown -y ; } 70 | 71 | [[ -z $(which ifconfig) ]] && { echo -e "${green}Installing ifconfig ...${normal}" ; apt-get install net-tools -y ; } 72 | [[ -z $(which ifconfig) ]] && { echo -e "${red}Error: No ifconfig!${normal}" ; exit 1 ; } 73 | 74 | function lines() { printf "%-70s\n" "-" | sed 's/\s/-/g' ; } 75 | 76 | ################################################################################################ 检测 IP 地址 77 | 78 | function isValidIpAddress() { echo $1 | grep -qE '^[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?$' ; } 79 | function isInternalIpAddress() { echo $1 | grep -qE '(192\.168\.((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.((\d{1,2})$|(1\d{2})$|(2[0-4]\d)$|(25[0-5])$))|(172\.((1[6-9])|(2\d)|(3[0-1]))\.((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.((\d{1,2})$|(1\d{2})$|(2[0-4]\d)$|(25[0-5])$))|(10\.((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.((\d{1,2})$|(1\d{2})$|(2[0-4]\d)$|(25[0-5])$))' ; } 80 | serveripv4=$( ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p' ) 81 | 82 | function _ip() { 83 | echo -e "${bold}正在检查服务器的 IPv4 信息 ...${normal}" 84 | 85 | isInternalIpAddress "$serveripv4" || serveripv4=$( wget --no-check-certificate -t1 -T6 -qO- v4.ipv6-test.com/api/myip.php ) 86 | isValidIpAddress "$serveripv4" || serveripv4=$( wget --no-check-certificate -t1 -T6 -qO- checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//' ) 87 | isValidIpAddress "$serveripv4" || serveripv4=$( wget --no-check-certificate -t1 -T7 -qO- ipecho.net/plain ) 88 | isValidIpAddress "$serveripv4" || { echo "${red}${shanshuo}WARNING ${jiacu}${underline}Failed to detect your public IPv4 address, use internal address instead${jiacu}" ; serveripv4=$( ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p' ) ; } 89 | 90 | echo -e "${bold}正在检查服务器的 IPv6 信息 ...${normal}" 91 | serveripv6=$( wget -t1 -T5 -qO- v6.ipv6-test.com/api/myip.php | grep -Eo "[0-9a-z:]+" | head -1 ) 92 | 93 | if [[ -n $serveripv6 ]];then 94 | serveripv6_show=$serveripv6 95 | else 96 | serveripv6_show="未检测到公网 IPv6 地址" 97 | fi 98 | } 99 | 100 | ################################################################################################## 判断网卡 101 | 102 | # 锐速脚本的写法,我稍微改了下。这个不依赖 ip 和 ifconfig,依赖要求最低,但是有的时候可能出错 103 | [ -n "$(grep 'eth0:' /proc/net/dev)" ] && wangka1=eth0 || wangka1=`cat /proc/net/dev |awk -F: 'function trim(str){sub(/^[ \t]*/,"",str); sub(/[ \t]*$/,"",str); return str } NR>2 {print trim($1)}' |grep -Ev '^lo|^sit|^stf|^gif|^dummy|^vmnet|^vir|^gre|^ipip|^ppp|^bond|^tun|^tap|^ip6gre|^ip6tnl|^teql|^venet|^he-ipv6|^docker' |awk 'NR==1 {print $0}'` 104 | # swizzin 脚本的写法 105 | wangka2=$(ip link show | grep -i broadcast | grep -m1 UP | cut -d: -f 2 | cut -d@ -f 1 | sed 's/ //g') 106 | # 忘了哪里看来的了 107 | #wangka3=$(ip route get 8.8.8.8 | awk '{print $5}') 108 | # 不配佬写的,稍微改了下 109 | #wangka4=$(ifconfig | grep 'e.*UP' | awk 'NR==1{print$1}' | sed 's|:||') 110 | 111 | # 对比 wangka1 和 wangka2,看看是否一致 112 | if [[ -n $wangka2 ]]; then 113 | if [[ $wangka1 == $wangka2 ]];then 114 | interface=$wangka1 115 | else 116 | interface=$wangka2 117 | # 我感觉还是第二种方法准一些 118 | fi 119 | else 120 | interface=$wangka1 121 | fi 122 | 123 | sysctl -w net.ipv6.conf.$interface.autoconf=0 > /dev/null 124 | ik_ipv6="2a00:c70:1:${serveripv4//./:}:1" 125 | ik_way6="${ik_ipv6/${serveripv4##*.}::1}" 126 | AAA=$( echo $serveripv4 | awk -F '.' '{print $1}' ) 127 | BBB=$( echo $serveripv4 | awk -F '.' '{print $2}' ) 128 | CCC=$( echo $serveripv4 | awk -F '.' '{print $3}' ) 129 | DDD=$( echo $serveripv4 | awk -F '.' '{print $4}' ) 130 | 131 | function ip_ipapi() { 132 | echo -e "${bold}正在检查服务器的其他 IP 信息 ... (比较慢)${normal}" 133 | 134 | mkdir -p $HOME/.abench 135 | wget --no-check-certificate -t1 -T6 -qO- https://ipapi.co/json > $HOME/.abench/ipapi 2>&1 136 | ccoodde=$( cat $HOME/.abench/ipapi | grep \"country\" | awk -F '"' '{print $4}' ) 2>/dev/null 137 | country=$( cat $HOME/.abench/ipapi | grep \"country_name\" | awk -F '"' '{print $4}' ) 2>/dev/null 138 | regionn=$( cat $HOME/.abench/ipapi | grep \"region\" | awk -F '"' '{print $4}' ) 2>/dev/null 139 | cityyyy=$( cat $HOME/.abench/ipapi | grep \"city\" | awk -F '"' '{print $4}' ) 2>/dev/null 140 | isppppp=$( cat $HOME/.abench/ipapi | grep \"org\" | awk -F '"' '{print $4}' ) 2>/dev/null 141 | asnnnnn=$( cat $HOME/.abench/ipapi | grep \"asn\" | awk -F '"' '{print $4}' ) 2>/dev/null 142 | [[ $cityyyy == Singapore ]] && unset cityyyy 143 | [[ -z $isppppp ]] && isp="No ISP detected" 144 | [[ -z $asnnnnn ]] && isp="No ASN detected" 145 | rm -f $HOME/.abench/ipapi 2>&1 146 | 147 | # rm -f $ipip_result 148 | ASN=$(echo $asnnnnn | grep -oE "AS[0-9]+") 149 | 150 | if [[ $ASN == AS24940 ]];then 151 | server=Hetzner 152 | script_support="不需要支持" 153 | script_support_add=",因为 Hz 装完自带 IPv6" 154 | elif [[ $ASN == AS16276 ]];then 155 | server=OVH 156 | script_support="不需要支持" 157 | script_support_add=",因为 OVH 装完自带 IPv6" 158 | elif [[ $ASN == AS60781 ]];then 159 | server=LeaseWeb 160 | script_support="支持" 161 | script_support_add=",请填写 1/4 参数" 162 | elif [[ $ASN == AS12876 ]];then 163 | server=Online 164 | script_support="支持" 165 | script_support_add=",请填写 1/2/3 参数" 166 | elif [[ $ASN == AS21409 ]];then 167 | server=Ikoula 168 | script_support="支持" 169 | script_support_add=",不用写参数" 170 | else 171 | server=Unknown 172 | script_support="不支持" 173 | script_support_add="" 174 | fi 175 | } 176 | 177 | 178 | 179 | ################################################################################################ 运行相关的 function 180 | 181 | 182 | 183 | function check_var_123() { 184 | [[ -z $IPv6 ]] && echo "${red}ERROR: No IPv6 input!${normal}" && ask_ipv6 185 | [[ -z $DUID ]] && echo "${red}ERROR: No DUID input!${normal}" && ask_DUID 186 | [[ -z $subnet ]] && echo "${red}ERROR: No subnet input!${normal}" && ask_subnet 187 | } 188 | 189 | function check_var_14() { 190 | [[ -z $IPv6 ]] && echo "${red}ERROR: No IPv6 input!${normal}" && ask_ipv6 191 | [[ -z $v6gw ]] && echo "${red}ERROR: No IPv6 Gateway input!${normal}" && ask_v6gw 192 | } 193 | 194 | # Ikoula 独服(/etc/network/interfaces) 195 | # 这个是只添加 196 | function ikoula_ifupdown() { 197 | if [[ ! $(grep -q "iface $interface inet6 static" /etc/network/interfaces) ]] || [[ $force == 1 ]] ; then 198 | file_backup 199 | [[ $force == 1 ]] && interfaces_file_clean 200 | cat << EOF >> /etc/network/interfaces 201 | ### Added by IPv6_Script ### 202 | iface $interface inet6 static 203 | address 2a00:c70:1:$AAA:$BBB:$CCC:$DDD:1 204 | netmask 96 205 | gateway 2a00:c70:1:$AAA:$BBB:$CCC::1 206 | ### IPv6_Script END ### 207 | EOF 208 | systemctl_restart 209 | fi 210 | } 211 | 212 | # 这个是覆盖重写 213 | function ikoula_interfaces2() { 214 | file_backup 215 | cat << EOF > /etc/network/interfaces 216 | # Network configuration file 217 | # Auto generated by Ikoula 218 | 219 | iface lo inet loopback 220 | auto lo 221 | 222 | auto $interface 223 | iface eth0 inet static 224 | address $AAA.$BBB.$CCC.$DDD 225 | netmask 255.255.255.00 226 | broadcast $AAA.$BBB.$CCC.255 227 | network $AAA.$BBB.$CCC.0 228 | gateway $AAA.$BBB.$CCC.1 229 | dns-nameservers 213.246.36.14 213.246.33.144 80.93.83.11 230 | 231 | ### Added by IPv6_Script ### 232 | iface $interface inet6 static 233 | address 2a00:c70:1:$AAA:$BBB:$CCC:$DDD:1 234 | netmask 96 235 | gateway 2a00:c70:1:$AAA:$BBB:$CCC::1 236 | ### IPv6_Script END ### 237 | EOF 238 | systemctl_restart 239 | } 240 | 241 | 242 | 243 | 244 | # Ikoula 独服,Ubuntu 18.04 系统(netplan) 245 | function ikoula_netplan() { 246 | 247 | # fxxk ikoula 248 | sed -i '/^.*net.ipv6.conf.all.disable_ipv6.*/'d /etc/sysctl.d/40-ikoula.conf 249 | sed -i '/^.*net.ipv6.conf.default.disable_ipv6.*/'d /etc/sysctl.d/40-ikoula.conf 250 | sed -i '/^.*net.ipv6.conf.lo.disable_ipv6.*/'d /etc/sysctl.d/40-ikoula.conf 251 | sed -i '/^.*net.ipv6.conf.eth0.disable_ipv6.*/'d /etc/sysctl.d/40-ikoula.conf 252 | 253 | file_backup 254 | cat << EOF > /etc/netplan/01-netcfg.yaml 255 | network: 256 | version: 2 257 | renderer: networkd 258 | ethernets: 259 | $interface: 260 | dhcp4: no 261 | dhcp6: no 262 | addresses: [$AAA.$BBB.$CCC.$DDD/24, '2a00:c70:1:$AAA:$BBB:$CCC:$DDD:1/96'] 263 | gateway4: $AAA.$BBB.$CCC.1 264 | gateway6: 2a00:c70:1:$AAA:$BBB:$CCC::1 265 | nameservers: 266 | addresses: [213.246.36.14,213.246.33.144,80.93.83.11] 267 | EOF 268 | netplan apply 269 | sleep 5 270 | } 271 | 272 | 273 | ################################################################################################ 274 | 275 | 276 | function write_dhclient6_conf() { 277 | cat << EOF > /etc/dhcp/dhclient6.conf 278 | interface "$interface" { 279 | send dhcp6.client-id $DUID; 280 | request; 281 | } 282 | EOF 283 | } 284 | 285 | 286 | function write_dhclient6_systemd() { 287 | cat << EOF > /etc/systemd/system/dhclient.service 288 | [Unit] 289 | Description=dhclient for sending DUID IPv6 290 | Wants=network.target 291 | Before=network.target 292 | 293 | [Service] 294 | #Restart=always 295 | #RestartSec=10 296 | Type=forking 297 | ExecStart=$(which dhclient) -cf /etc/dhcp/dhclient6.conf -6 -P -v $interface 298 | ExecStop=$(which dhclient) -x -pf /var/run/dhclient6.pid 299 | 300 | [Install] 301 | WantedBy=multi-user.target 302 | EOF 303 | systemctl daemon-reload 304 | systemctl enable dhclient.service 305 | } 306 | 307 | 308 | function write_dhclient_netplan_systemd() { 309 | cat << EOF > /etc/systemd/system/dhclient-netplan.service 310 | [Unit] 311 | Description=redo netplan apply after dhclient 312 | Wants=dhclient.service 313 | After=dhclient.service 314 | Before=network.target 315 | 316 | [Service] 317 | Type=oneshot 318 | ExecStart=/usr/sbin/netplan apply 319 | 320 | [Install] 321 | WantedBy=dhclient.service 322 | EOF 323 | systemctl daemon-reload 324 | systemctl enable dhclient-netplan.service 325 | } 326 | 327 | 328 | 329 | function online_interfaces_file_mod() { 330 | cat << EOF >> /etc/network/interfaces 331 | ### Added by IPv6_Script ### 332 | iface $interface inet6 static 333 | address $IPv6 334 | netmask $subnet 335 | EOF 336 | 337 | } 338 | 339 | 340 | 341 | function online_interfaces_file_mod_dhclient() { 342 | cat << EOF >> /etc/network/interfaces 343 | accept_ra 1 344 | pre-up modprobe ipv6 345 | pre-up dhclient -cf /etc/dhcp/dhclient6.conf -pf /run/dhclient6.$interface.pid -6 -P $interface 346 | pre-down dhclient -x -pf /run/dhclient6.$interface.pid 347 | ### IPv6_Script END ### 348 | EOF 349 | # pre-up /sbin/dhclient -1 -v -pf /run/dhclient6.$interface.pid -lf /var/lib/dhcp/dhclient6.$interface.leases -cf /etc/dhcp/dhclient6.conf -6 -P $interface 350 | } 351 | 352 | 353 | # Online/OneProvider Paris 独服,Ubuntu 16.04,Debian 8/9/10 354 | function online_dhclient() { 355 | check_var_123 356 | file_backup 357 | if [[ ! $(grep -q "iface $interface inet6 static" /etc/network/interfaces) ]]; then 358 | interfaces_file_clean 359 | online_interfaces_file_mod 360 | if [[ $CODENAME == bionic ]];then 361 | apt-get install -y ifupdown 362 | echo "auto $interface" >> /etc/network/interfaces 363 | fi 364 | online_interfaces_file_mod_dhclient 365 | fi 366 | write_dhclient6_conf 367 | write_dhclient6_systemd 368 | systemctl start dhclient.service 369 | systemctl_restart 370 | } 371 | 372 | 373 | # Online/OneProvider Paris 独服,Ubuntu 18.04 系统(netplan) 374 | function online_netplan() { 375 | check_var_123 376 | file_backup 377 | 378 | write_dhclient6_conf 379 | write_dhclient6_systemd 380 | write_dhclient_netplan_systemd 381 | netplan_netcfg_file_clean 382 | cat << EOF >> /etc/netplan/01-netcfg.yaml 383 | ### Added by IPv6_Script ### 384 | dhcp6: no 385 | accept-ra: yes 386 | addresses: 387 | - $IPv6/$subnet 388 | ### IPv6_Script END ### 389 | EOF 390 | systemctl start dhclient.service 391 | systemctl start dhclient-netplan.service 392 | netplan apply 393 | sleep 5 394 | } 395 | 396 | 397 | ########################################################################### dibbler 398 | 399 | 400 | function dibbler_install() { 401 | dpkg-query -W -f='${Status}' build-essential 2>/dev/null | grep -q "ok installed" || apt-get install -y build-essential 402 | if [[ ! -f /usr/local/sbin/dibbler-client ]]; then 403 | wget -4 https://netix.dl.sourceforge.net/project/dibbler/dibbler/1.0.1/dibbler-1.0.1.tar.gz -O dibbler-1.0.1.tar.gz 404 | tar zxf dibbler-1.0.1.tar.gz 405 | cd dibbler-1.0.1 406 | ./configure 407 | make -j$(nproc) 408 | make install 409 | cd .. 410 | rm -rf dibble* 411 | fi 412 | [[ ! -f /usr/local/sbin/dibbler-client ]] && echo -e "\nError: No dibbler-client found!\n" && exit 1 413 | } 414 | 415 | 416 | function online_dibbler_action() { 417 | mkdir -p /var/lib/dibbler /etc/dibbler/ 418 | echo "$DUID" > /var/lib/dibbler/client-duid 419 | cat << EOF > /etc/dibbler/client.conf 420 | log-level 7 421 | duid-type duid-ll 422 | inactive-mode 423 | 424 | iface $interface { 425 | pd 426 | } 427 | EOF 428 | file_backup 429 | interfaces_file_clean 430 | online_interfaces_file_mod 431 | if [[ $CODENAME == bionic ]];then 432 | apt-get install -y ifupdown 433 | echo "auto $interface" >> /etc/network/interfaces 434 | fi 435 | echo "### IPv6_Script END ###" >> /etc/network/interfaces 436 | 437 | cat << EOF > /etc/systemd/system/dibbler-client.service 438 | [Unit] 439 | Description=Dibbler Client 440 | After=networking.service 441 | 442 | [Service] 443 | Type=simple 444 | ExecStart=/usr/local/sbin/dibbler-client start 445 | 446 | [Install] 447 | WantedBy=multi-user.target 448 | EOF 449 | systemctl enable dibbler-client 450 | systemctl start dibbler-client 451 | sleep 5 452 | systemctl status dibbler-client 453 | } 454 | 455 | 456 | function online_dibbler() { 457 | check_var_123 458 | dibbler_install 459 | online_dibbler_action 460 | } 461 | 462 | 463 | 464 | 465 | ########################################################################### odhcp6c 466 | 467 | 468 | 469 | 470 | function odhcp6c_install() { 471 | for app in cmake git build-essential ; do 472 | dpkg-query -W -f='${Status}' $app 2>/dev/null | grep -q "ok installed" || apt-get install -y $app 473 | done 474 | 475 | if [[ -z $(which odhcp6c) ]]; then 476 | git clone --depth=1 https://github.com/openwrt/odhcp6c 477 | cd odhcp6c 478 | cmake . 479 | make 480 | make install 481 | cd .. 482 | rm -rf odhcp6c 483 | fi 484 | } 485 | 486 | 487 | function write_odhcp6c_systemd() { 488 | cat << EOF > /etc/systemd/system/odhcp6c.service 489 | [Unit] 490 | Description=odhcp6c 491 | Wants=network.target 492 | Before=network.target 493 | [Service] 494 | Type=forking 495 | ExecStart=$(which odhcp6c) -c $DUID -P $subnet -d $interface 496 | ExecStartPost=$(which ip) -6 a a $IPv6/$subnet dev $interface 497 | ExecStartPost=$(which ip) -6 r a $IPv6/$subnet dev $interface 498 | [Install] 499 | WantedBy=multi-user.target 500 | EOF 501 | systemctl daemon-reload 502 | systemctl enable odhcp6c.service 503 | } 504 | 505 | 506 | function online_odhcp6c() { 507 | check_var_123 508 | odhcp6c_install 509 | write_odhcp6c_systemd 510 | systemctl start odhcp6c 511 | sleep 5 512 | systemctl status odhcp6c 513 | } 514 | 515 | 516 | ########################################################################### LeaseWeb 517 | 518 | 519 | function leaseweb_prepare() { 520 | subnet=64 521 | check_var_14 522 | file_backup 523 | grep -q "2001:1af8:3100:1::10" /etc/resolv.conf || echo "nameserver 2001:1af8:3100:1::10" >> /etc/resolv.conf 524 | } 525 | 526 | function leaseweb_ifupdown() { 527 | leaseweb_prepare 528 | interfaces_file_clean 529 | cat << EOF >> /etc/network/interfaces 530 | ### Added by IPv6_Script ### 531 | iface $interface inet6 static 532 | address $IPv6 533 | netmask $subnet 534 | pre-up modprobe ipv6 535 | gateway $v6gw 536 | ### IPv6_Script END ### 537 | EOF 538 | echo -e "DONE" 539 | } 540 | 541 | function leaseweb_netplan() { 542 | leaseweb_prepare 543 | netplan_netcfg_file_clean 544 | cat << EOF >> /etc/netplan/01-netcfg.yaml 545 | ### Added by IPv6_Script ### 546 | dhcp6: no 547 | gateway6: $v6gw 548 | addresses: 549 | - $IPv6/$subnet 550 | ### IPv6_Script END ### 551 | EOF 552 | netplan apply 553 | sleep 5 554 | echo -e "DONE" 555 | } 556 | 557 | 558 | 559 | 560 | ########################################################################### 561 | 562 | 563 | 564 | function file_backup() { 565 | mkdir -p /log/script 566 | if [[ $type == netplan ]]; then 567 | cp -f /etc/netplan/01-netcfg.yaml /log/script/netcfg.yaml.$(date "+%Y.%m.%d.%H.%M.%S").bak 568 | elif [[ $type == ifdown ]]; then 569 | cp -f /etc/network/interfaces /log/script/interfaces.$(date "+%Y.%m.%d.%H.%M.%S").bak 570 | fi 571 | } 572 | 573 | function interfaces_file_clean() { 574 | while grep -q "IPv6_Script" /etc/network/interfaces ; do 575 | sed -i '$d' /etc/network/interfaces 576 | done 577 | } 578 | 579 | function netplan_netcfg_file_clean() { 580 | while grep -q "IPv6_Script" /etc/netplan/01-netcfg.yaml ; do 581 | sed -i '$d' /etc/netplan/01-netcfg.yaml 582 | done 583 | } 584 | 585 | function systemctl_restart() { 586 | systemctl restart networking.service || echo -e "\n${red}systemctl restart networking.service FAILED${normal}" 587 | } 588 | 589 | function ipv6_test() { 590 | echo -ne "${bold}检测 IPv6 连接性 ... ${normal}" 591 | IPv6_test=$(ping6 -c 5 ipv6.google.com | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }') 592 | if [[ $IPv6_test -gt 0 ]]; then 593 | echo "${bold}${green}成功!${normal}" 594 | exit 0 595 | else 596 | echo "${bold}${red}失败...${normal}" 597 | exit 1 598 | fi 599 | } 600 | 601 | function sysctl_enable_ipv6() { 602 | sysctl -w net.ipv6.conf.$interface.autoconf=0 > /dev/null 603 | sed -i '/^net.ipv6.conf.*/'d /etc/sysctl.conf 604 | echo "net.ipv6.conf.$interface.autoconf=0" >> /etc/sysctl.conf 605 | } 606 | 607 | function ask_reboot() { 608 | if [[ $reboot == no ]]; then 609 | echo -e "\n${bold}Press ${on_red}Ctrl+C${normal} ${bold}to exit${jiacu}, or press ${bailvse}ENTER${normal} ${bold}to reboot${normal} " 610 | read input 611 | fi 612 | # echo -e "\n${bold}Rebooting ... ${normal}" 613 | reboot -f 614 | init 6 615 | } 616 | 617 | function cleanup() { 618 | echo -n "Cleanup ... " 619 | 620 | interfaces_file_clean 621 | netplan_netcfg_file_clean 622 | rm -f /etc/dhcp/dhclient6.conf /etc/dibbler/client.conf /var/lib/dibbler/client-duid 623 | 624 | systemctl stop dhclient-netplan.service 2>/dev/null 625 | systemctl stop dhclient.service 2>/dev/null 626 | systemctl stop dibbler-client.service 2>/dev/null 627 | systemctl stop odhcp6c.service 2>/dev/null 628 | systemctl disable dhclient-netplan.service 2>/dev/null 629 | systemctl disable dhclient.service 2>/dev/null 630 | systemctl disable dibbler-client.service 2>/dev/null 631 | systemctl disable odhcp6c.service 2>/dev/null 632 | 633 | rm -f /etc/systemd/system/dhclient.service 634 | rm -f /etc/systemd/system/dhclient-netplan.service 635 | rm -f /etc/systemd/system/dibbler-client.service 636 | rm -f /etc/systemd/system/odhcp6c.service 637 | systemctl daemon-reload 638 | 639 | echo "DONE" 640 | } 641 | 642 | function info() { 643 | echo 644 | lines 645 | echo -e " 646 | script_update=$script_update 647 | script_version=$script_version 648 | 649 | OS=$DISTRO $CODENAME 650 | IPv4=$serveripv4 651 | interface=$interface 652 | type=$type 653 | " 654 | lines 655 | if [[ -s etc/network/interfaces ]]; then 656 | echo -e "\n${yellow}cat /etc/network/interfaces${normal}\n" 657 | cat /etc/network/interfaces 2>/dev/null 658 | lines 659 | fi 660 | if [[ -s /etc/netplan/01-netcfg.yaml ]]; then 661 | echo -e "\n${yellow}cat /etc/netplan/01-netcfg.yaml${normal}\n" 662 | cat /etc/netplan/01-netcfg.yaml 2>/dev/null 663 | lines 664 | fi 665 | if [[ -s /etc/dibbler/client.conf ]]; then 666 | echo -e "\n${yellow}cat /etc/dibbler/client.conf${normal}\n" 667 | cat /etc/dibbler/client.conf 2>/dev/null 668 | lines 669 | fi 670 | if [[ -s /var/lib/dibbler/client-duid ]]; then 671 | echo -e "\n${yellow}cat /var/lib/dibbler/client-duid${normal}\n" 672 | cat /var/lib/dibbler/client-duid 2>/dev/null 673 | lines 674 | fi 675 | if [[ -s /etc/systemd/system/odhcp6c.service ]]; then 676 | echo -e "\n${yellow}cat /etc/systemd/system/odhcp6c.service${normal}\n" 677 | cat /etc/systemd/system/odhcp6c.service 2>/dev/null 678 | lines 679 | fi 680 | echo -e " 681 | cat 682 | cd /log/script && ls 683 | netplan apply 684 | systemctl restart networking.service 685 | ping6 -c 5 ipv6.google.com 686 | " 687 | lines;echo 688 | } 689 | 690 | function ask_pause() { 691 | read -p "${bold}敲回车开始执行操作 ${normal} " pause 692 | echo 693 | } 694 | 695 | function ask_ipv4() { 696 | unset serveripv4 697 | echo -e "${bold}请输入你的公网 IPv4 地址:${normal}" 698 | while [[ -z $serveripv4 ]]; do 699 | read -e serveripv4 700 | isInternalIpAddress "$serveripv4" && { echo -e "${CW} This is INTERNAL IPv4 address, not PUBLIC IPv4 address, please write your public IPv4: ${normal}" ; unset serveripv4 ; } 701 | isValidIpAddress "$serveripv4" || { echo -e "${CW} This is not a valid public IPv4 address, please write your public IPv4: ${normal}" ; unset serveripv4 ; } 702 | done 703 | } 704 | 705 | function ask_ipv6() { 706 | read -ep "${bold}输入待配置的 IPv6 地址:${blue}" IPv6 ; echo -n "${normal}" 707 | } 708 | 709 | function ask_DUID() { 710 | read -ep "${bold}输入待配置的 DUID:${blue}" DUID ; echo -n "${normal}" 711 | } 712 | 713 | function ask_subnet() { 714 | read -ep "${bold}输入待配置的 Subnet:${blue}" subnet ; echo -n "${normal}" 715 | } 716 | 717 | function ask_v6gw() { 718 | read -ep "${bold}输入待配置的 Gateway:${blue}" v6gw ; echo -n "${normal}" 719 | } 720 | 721 | 722 | function ask_interface() { 723 | read -ep "${bold}输入网卡名称:${blue}" interface ; echo -n "${normal}" 724 | } 725 | 726 | function show_help() { 727 | echo -e " 728 | ${bold}${baiqingse}IPv6 Script $script_version${normal} 729 | 730 | ${bold}${green}Usage: ${normal} 731 | -m Specify IPv6 configuring mode 732 | ik Ikoula ifupdown, only for Ikoula servers using ifupdown 733 | Typically, This is for Ubuntu 14.04/16.04, Debian 7/8/9/10 734 | ik2 Ikoula netplan, only for Ikoula servers using netplan 735 | Typically, This is ONLY for Ubuntu 18.04 736 | ol Online dhclient, only for Online/OneProvider servers using ifupdown 737 | Typically, This is for Ubuntu 16.04, Debian 8/9/10 738 | ol2 Online netplan, only for Online/OneProvider servers using netplan 739 | Typically, This is ONLY for Ubuntu 18.04 740 | ol3 Online dibbler, only for Online/OneProvider servers 741 | Typically, This is for Ubuntu 16.04/18.04, Debian 8/9/10 742 | ol4 Online odhcp6c, only for Online/OneProvider servers 743 | Typically, This is for Ubuntu 16.04/18.04, Debian 8/9/10 744 | lw LeaseWeb ifupdown, only for LeaseWeb servers using ifupdown 745 | Typically, This is for Ubuntu 14.04/16.04, Debian 7/8/9/10 746 | lw2 LeaseWeb netplan, only for LeaseWeb servers using netplan 747 | Typically, This is ONLY for Ubuntu 18.04 748 | -6 Inupt IPv6 749 | -d Input DUID 750 | -s Input subnet 751 | -i Input interface 752 | -r Do a reboot without confirmation after executing script 753 | -t Test IPv6 connectivity 754 | -h Show this info 755 | 756 | ${bold}${green}Examples: ${normal} 757 | 758 | Ikoula Dedicated Server using Ubuntu 16.04 759 | ${underline}ipv6 -m ik${reset_underline} 760 | 761 | Ikoula Dedicated Server using Ubuntu 18.04 762 | ${underline}ipv6 -m ik2${reset_underline} 763 | 764 | OneProvider Dedicated Server using Debian 9 765 | ${underline}ipv6 -m ol -6 2001:3bc8:2490:: -d 00:03:00:02:19:c4:c9:e3:75:26 -s 56${reset_underline} 766 | 767 | Online Dedicated Server using Ubuntu 18.04 768 | ${underline}ipv6 -m ol3 -6 2001:cb6:2521:240:: -d 00:03:00:01:d3:3a:15:b4:43:ad -s 56${reset_underline} 769 | " 770 | } 771 | 772 | 773 | function ipv6_menu() { 774 | if [[ $ip_check == y ]]; then 775 | _ip 776 | ip_ipapi 777 | ip_check=n 778 | fi 779 | clear 780 | echo -e " 781 | ${bold}${on_magenta} IPv6 配置脚本 ${jiacu} 782 | 783 | IPv4 地址 ${cyan}$serveripv4${jiacu} 784 | IPv6 地址 ${cyan}$serveripv6_show${jiacu} 785 | ASN 信息 ${green}$asnnnnn, $isppppp${jiacu} 786 | 地理位置 ${green}$country, $regionn, $cityyyy${jiacu} 787 | 788 | 操作系统 ${cyan}$DISTRO $osversion $CODENAME${jiacu} 789 | 系统支持性 ${cyan}$SysSupport${jiacu} 790 | 脚本可用性 ${cyan}${script_support}${script_support_add}${jiacu} 791 | 792 | 脚本版本 ${cyan}$script_version ($script_update)${jiacu} 793 | 794 | ${on_blue}-------------------- 下列为可修改的参数 --------------------${jiacu} 795 | 796 | ${green}<1>${cyan} 待配置的 IPv6 地址 ${blue}$IPv6${jiacu} 797 | ${green}<2>${cyan} 待配置的 DUID ${blue}$DUID${jiacu} 798 | ${green}<3>${cyan} 待配置的 Subnet ${blue}$subnet${jiacu} 799 | ${green}<4>${cyan} 待配置的 IPv6 Gateway ${blue}$v6gw${jiacu} 800 | 801 | 以上 4 个参数是否需要修改,在脚本可用性一栏有提示 802 | 803 | ${green}<5>${cyan} 所使用的网卡名称 ${blue}$interface${jiacu} 804 | 805 | 脚本会自动检测网卡,一般来说默认的就是正确的不用改 806 | 807 | ${on_blue}------------------- 下列为可用的配置模式 -------------------${jiacu} 808 | 809 | ${green}<11>${cyan} Online dhclient6 (Debian 8/9/10, Ubuntu 16.04)(调试中,先别用这个) 810 | ${green}<12>${cyan} Online netplan (Ubuntu 18.04) 811 | ${green}<13>${cyan} Online dibbler (Debian 8/9/10, Ubuntu 16.04/18.04) 812 | ${green}<14>${cyan} Online odhcp6c (Debian 8/9/10, Ubuntu 16.04/18.04)(推荐) 813 | ${green}<21>${cyan} Ikoula ifupdown (Debian 8/9/10, Ubuntu 16.04) 814 | ${green}<22>${cyan} Ikoula netplan (Ubuntu 18.04) 815 | ${green}<31>${cyan} LeaseWeb ifupdown (Debian 8/9/10, Ubuntu 16.04) 816 | ${green}<32>${cyan} LeaseWeb netplan (Ubuntu 18.04) 817 | 818 | ${red}<90>${jiacu} 重启 819 | ${red}<95>${jiacu} 移除本脚本的 IPv6 配置 820 | ${red}<96>${jiacu} 修改脚本使用的 IPv4 地址 821 | ${red}<97>${jiacu} 再次检查服务器 IP 信息 822 | ${red}<98>${jiacu} 测试 IPv6 连接性 823 | ${red}<99>${jiacu} 退出脚本(直接回车也是退出) 824 | " 825 | read -ep "${bold}${yellow}输入对应的数值进行修改或者操作${blue} " response ; echo "${normal}" 826 | case $response in 827 | 1) ask_ipv6 ; ipv6_menu ;; 828 | 2) ask_DUID ; ipv6_menu ;; 829 | 3) ask_subnet ; ipv6_menu ;; 830 | 4) ask_v6gw ; ipv6_menu ;; 831 | 5) ask_interface ; ipv6_menu ;; 832 | 11) mode=ol ; ask_pause ; mode_action ;; 833 | 12) mode=ol2 ; ask_pause ; mode_action ;; 834 | 13) mode=ol3 ; ask_pause ; mode_action ;; 835 | 14) mode=ol4 ; ask_pause ; mode_action ;; 836 | 21) mode=ik ; ask_pause ; mode_action ;; 837 | 22) mode=ik2 ; ask_pause ; mode_action ;; 838 | 31) mode=lw ; ask_pause ; mode_action ;; 839 | 32) mode=lw2 ; ask_pause ; mode_action ;; 840 | 90) ask_reboot ;; 841 | 95) mode=c ; ask_pause ; mode_action ; ipv6_menu ;; 842 | 96) ask_ipv4 ; ipv6_menu ;; 843 | 97) _ip;_ipip; ipv6_menu ;; 844 | 98) ipv6_test; ipv6_menu ;; 845 | 99) exit ;; 846 | *) exit ;; 847 | esac 848 | } 849 | 850 | 851 | ########################################################################### 852 | 853 | function mode_action() { 854 | case $mode in 855 | ik ) ikoula_ifupdown ; ask_reboot ;; 856 | ik2 ) ikoula_netplan ; ipv6_test ;; 857 | ol ) online_dhclient ; ipv6_test ; ask_reboot ;; 858 | ol2 ) online_netplan ; ipv6_test ;; 859 | ol3 ) online_dibbler ; ask_reboot ;; 860 | ol4 ) online_odhcp6c ; ipv6_test ;; 861 | lw ) leaseweb_ifupdown ; ask_reboot ;; 862 | lw2 ) leaseweb_netplan ; ipv6_test ;; 863 | t ) info ; ipv6_test ;; 864 | h ) show_help ;; 865 | c ) cleanup ;; 866 | m ) ipv6_menu ;; 867 | esac 868 | } 869 | 870 | mode_action 871 | 872 | ########################################################################### 873 | 874 | 875 | 876 | function references() { 877 | 其实有些我也没参考,先留着当个备份,或许以后有用呢 878 | # https://npchk.info/online-net-dedibox-dibbler-ipv6/ 879 | # https://blog.gloriousdays.pw/2019/03/14/configure-online-net-ipv6-on-ubuntu-18-04/ 880 | # https://blog.gloriousdays.pw/2019/08/27/configure-ikoula-ipv6-under-netplan-io/ 881 | # https://blog.gloriousdays.pw/2018/11/24/something-about-ikoula-seedbox/ 882 | # https://blog.gloriousdays.pw/2017/10/11/online-dedibox-ipv6-configuration/ 883 | # https://ymgblog.com/2018/03/14/383/ 884 | # https://ymgblog.com/2018/03/12/345/ 885 | # https://www.timelate.com/archives/add-ipv6-address-for-ikoula-ubuntu-18-04-dedicated-server.html 886 | # https://documentation.online.net/en/dedicated-server/network/ipv6/prefix 887 | # https://fr-wiki.ikoula.com/fr/Comment_calculer_mon_IPV6 888 | # https://kb.leaseweb.com/support/support-procedures/adding-an-ipv6-address-to-your-server#AddinganIPv6addresstoyourserver-ConfigureIPv6onDebian/Ubuntu 889 | sleep 0 890 | } 891 | -------------------------------------------------------------------------------- /scripts/mountall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # A mountall script from Scaleway Dedibox 3 | 4 | if [ $( whoami ) != "root" ]; then 5 | echo "You need to have root privilege" 6 | exit 1 7 | fi 8 | 9 | is_inlist () { 10 | OIFS=$IFS 11 | IFS=: 12 | for i in $2; do 13 | if [ "$i" -a "$1" = "$i" ]; then 14 | IFS=$OIFS 15 | echo 1 16 | return 17 | fi 18 | done 19 | IFS=$OIFS 20 | echo 0 21 | } 22 | 23 | is_swap () { 24 | magic=$(/bin/dd if="$1" bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null) 25 | if [ "$magic" = "SWAPSPACE2" -o "$magic" = "SWAP-SPACE" ]; then 26 | echo 1 27 | return 28 | fi 29 | echo 0 30 | } 31 | 32 | mdlist="" 33 | rdlist="" 34 | sdlist="" 35 | 36 | for mddev in $( ls /dev/md[0-9]* ); do 37 | mdlist="${mdlist} ${mddev}" 38 | for line in $( mdadm --detail $mddev ); do 39 | rddev=$( echo $line | awk '/\/dev\/sd/ {print $1}' ) 40 | if [ -n "$rddev" ]; then 41 | rdlist="${rddev}:${rdlist}" 42 | fi 43 | done 44 | done 45 | 46 | for sddev in $( ls /dev/sd[a-z][0-9]* ); do 47 | if [ $( is_inlist $sddev $rdlist ) -eq 0 ]; then 48 | if [ $( is_swap $sddev ) -eq 0 ]; then 49 | sdlist="${sdlist} ${sddev}" 50 | else 51 | echo "$sddev looks like a SWAP space and therefore will not be mounted." 52 | fi 53 | else 54 | echo "$sddev is part of a RAID array and therefore will not be mounted." 55 | fi 56 | done 57 | 58 | for part in ${mdlist} ${sdlist}; do 59 | mkdir -p /mnt/${part#/dev/} 2>/dev/null 60 | mount -t auto ${part} /mnt/${part#/dev/} 2>/dev/null 61 | if [ $? -eq 0 ]; then 62 | echo "${part} has just been mounted in /mnt/${part#/dev/}" 63 | else 64 | echo "${part} cannot be mounted." 65 | fi 66 | done 67 | 68 | exit 0 69 | -------------------------------------------------------------------------------- /scripts/my-alias: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #!/bin/bash 3 | # Author: Aniverse 4 | # https://github.com/Aniverse/aBox 5 | ######################################################################################################### 6 | script_update=2020.09.07 7 | script_version=r11005 8 | 9 | usage_guide() { 10 | rm -f 1 ; nano 1 ; source 1 11 | source <(wget -qO- https://github.com/Aniverse/aBox/raw/master/scripts/my-alias) 12 | source <(wget -qO- https://github.com/Aniverse/aBox/raw/master/scripts/my-alias) username 13 | } 14 | 15 | ######################################################################################################### 16 | 17 | iUser=$1 18 | 19 | export LC_ALL=en_US.UTF-8 20 | export LANG=en_US.UTF-8 21 | export LANGUAGE=en_US.UTF-8 22 | export TZ="/usr/share/zoneinfo/Asia/Shanghai" 23 | export PATH=$HOME/bin:$HOME/.bin:$HOME/.pip/bin:$HOME/.local/bin:$PATH 24 | 25 | if (! export | grep -q sbin); then 26 | export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin 27 | fi 28 | 29 | ######################################################################################################### 30 | 31 | function setcolor() { 32 | black=$(tput setaf 0) ; red=$(tput setaf 1) ; green=$(tput setaf 2) ; yellow=$(tput setaf 3); bold=$(tput bold) 33 | blue=$(tput setaf 4) ; magenta=$(tput setaf 5) ; cyan=$(tput setaf 6) ; white=$(tput setaf 7) ; normal=$(tput sgr0) 34 | on_black=$(tput setab 0); on_red=$(tput setab 1) ; on_green=$(tput setab 2); on_yellow=$(tput setab 3) 35 | on_blue=$(tput setab 4) ; on_magenta=$(tput setab 5) ; on_cyan=$(tput setab 6) ; on_white=$(tput setab 7) 36 | shanshuo=$(tput blink) ; wuguangbiao=$(tput civis) ; guangbiao=$(tput cnorm) ; jiacu=${normal}${bold} 37 | underline=$(tput smul) ; reset_underline=$(tput rmul) ; dim=$(tput dim) 38 | standout=$(tput smso) ; reset_standout=$(tput rmso) ; title=${standout} 39 | baihuangse=${white}${on_yellow}; bailanse=${white}${on_blue} ; bailvse=${white}${on_green} 40 | baiqingse=${white}${on_cyan} ; baihongse=${white}${on_red} ; baizise=${white}${on_magenta} 41 | heibaise=${black}${on_white} ; heihuangse=${on_yellow}${black} 42 | CW="${bold}${baihongse} ERROR ${jiacu}";ZY="${baihongse}${bold} ATTENTION ${jiacu}";JG="${baihongse}${bold} WARNING ${jiacu}" ; } 43 | setcolor 44 | 45 | function gggclone(){ git clone --depth=1 $1 && cd $(echo ${1##*/}) ;} 46 | function io_test() { (LANG=C dd if=/dev/zero of=test_$$ bs=64k count=16k conv=fdatasync && rm -f test_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' ; } 47 | function iotest() { io1=$( io_test ) ; echo -e "\n${bold}硬盘 I/O (第一次测试) : ${yellow}$io1${normal}" 48 | io2=$( io_test ) ; echo -e "${bold}硬盘 I/O (第二次测试) : ${yellow}$io2${normal}" ; io3=$( io_test ) ; echo -e "${bold}硬盘 I/O (第三次测试) : ${yellow}$io3${normal}\n" ; } 49 | 50 | # Find a file with a pattern in name: 51 | function ff() { find . -type f -iname '*'"$*"'*' -ls ; } 52 | 53 | # Find a file with pattern $1 in name and Execute $2 on it: 54 | function fe() { find . -type f -iname '*'"${1:-}"'*' -exec ${2:-file} {} \; ; } 55 | 56 | # Find a pattern in a set of files and highlight them: 57 | #+ (needs a recent version of egrep). 58 | function fstr() 59 | { 60 | OPTIND=1 61 | local mycase="" 62 | local usage="fstr: find string in files. 63 | Usage: fstr [-i] \"pattern\" [\"filename pattern\"] " 64 | while getopts :it opt 65 | do 66 | case "$opt" in 67 | i) mycase="-i " ;; 68 | *) echo "$usage"; return ;; 69 | esac 70 | done 71 | shift $(( $OPTIND - 1 )) 72 | if [ "$#" -lt 1 ]; then 73 | echo "$usage" 74 | return; 75 | fi 76 | find . -type f -name "${2:-*}" -print0 | \ 77 | xargs -0 egrep --color=always -sn ${case} "$1" 2>&- | more 78 | 79 | } 80 | 81 | function jieya() { 82 | file=$1 83 | delete=$2 84 | if [ -f $file ] ; then 85 | case $1 in 86 | *.tar.bz2) tar xvjf $1 ;; 87 | *.tar.gz) tar xvzf $1 ;; 88 | *.tar.xz) xz -d $1 ; 89 | tar xvf ${file%.*} ;; 90 | *.bz2) bunzip2 $1 ;; 91 | *.rar) unrar x $1 ;; 92 | *.gz) gunzip $1 ;; 93 | *.tar) tar xvf $1 ;; 94 | *.tbz2) tar xvjf $1 ;; 95 | *.tgz) tar xvzf $1 ;; 96 | *.zip) unzip $1 ;; 97 | *.Z) uncompress $1 ;; 98 | *.7z) 7z x $1 ;; 99 | *) echo "'$1' cannot be extracted via jieya" ;; 100 | esac 101 | [[ $delete == d ]] && rm -f $file ${file%.*} 102 | else 103 | echo "'$1' is not a valid file!" 104 | fi 105 | } 106 | 107 | function chaip() { 108 | local ipv4=$1 109 | echo $ipv4 | grep -qE '^[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?$' || { echo "Error: Not valid IPv4" ; exit 1 ; } 110 | mkdir -p $HOME/.abench 111 | wget --no-check-certificate -t1 -T6 -qO- https://ipapi.co/$ipv4/json > $HOME/.abench/ipapi 2>&1 112 | ccoodde=$( cat $HOME/.abench/ipapi | grep \"country\" | awk -F '"' '{print $4}' ) 2>/dev/null 113 | country=$( cat $HOME/.abench/ipapi | grep \"country_name\" | awk -F '"' '{print $4}' ) 2>/dev/null 114 | regionn=$( cat $HOME/.abench/ipapi | grep \"region\" | awk -F '"' '{print $4}' ) 2>/dev/null 115 | cityyyy=$( cat $HOME/.abench/ipapi | grep \"city\" | awk -F '"' '{print $4}' ) 2>/dev/null 116 | isppppp=$( cat $HOME/.abench/ipapi | grep \"org\" | awk -F '"' '{print $4}' ) 2>/dev/null 117 | asnnnnn=$( cat $HOME/.abench/ipapi | grep \"asn\" | awk -F '"' '{print $4}' ) 2>/dev/null 118 | [[ $cityyyy == Singapore ]] && unset cityyyy 119 | [[ -z $isppppp ]] && isp="No ISP detected" 120 | [[ -z $asnnnnn ]] && isp="No ASN detected" 121 | rm -f $HOME/.abench/ipapi 2>&1 122 | echo -e "$ipv4" 123 | echo -e "$asnnnnn, $isppppp" 124 | echo -e "$country, $regionn, $cityyyy" 125 | } 126 | 127 | 128 | # Creates an archive (*.tar.gz) from given directory. 129 | function make-tar() { tar cvzf "${1%%/}.tar.gz" "${1%%/}/"; } 130 | 131 | # Create a ZIP archive of a file or folder. 132 | function make-zip() { zip -r "${1%%/}.zip" "$1" ; } 133 | 134 | function dabao() { 135 | local target=$1 136 | if [[ -d "$target" ]];then 137 | folder_size=$(du -sB MiB $target | awk '{print $1}' | grep -oE "[0-9]+") 138 | echo -e "\033[0;33m目标文件夹大小 $folder_size MiB\033[0m" 139 | [[ $folder_size -ge 200 ]] && read -p "确定打包么?" 140 | mkdir -p $HOME/tars 141 | target_full_path=$(cd $target;pwd) 142 | dirpath=$(dirname $target_full_path) 143 | target=$(basename $target_full_path) 144 | output=$target 145 | echo $target | grep -qE "^." && output=$(echo $target | sed "s/\.//") 146 | tarfile=$HOME/tars/$output.tar.gz 147 | [[ -e $tarfile ]] && echo -ne "\033[0;31m同名压缩包已存在" && rm -f $tarfile && echo -e ",删除之\033[0m" 148 | tar zcf $tarfile -C $dirpath $target && echo -ne "\033[0;32m打包后体积 " && du -sB KiB $tarfile | awk '{print $1}' 149 | echo -e "\033[0;34msz $tarfile\033[0m\n" 150 | else 151 | echo "\033[0;31m不是文件夹\033[0m" 152 | fi 153 | } 154 | 155 | # Make your directories and files access rights sane. 156 | function sanitize() { chmod -R u=rwX,g=rX,o= "$@" ;} 157 | 158 | ######################################################################################################### 159 | 160 | alias sssa="/appex/bin/serverSpeeder.sh start" 161 | alias sssb="/appex/bin/serverSpeeder.sh stop" 162 | alias sssc="/appex/bin/serverSpeeder.sh status" 163 | alias sssr="/appex/bin/serverSpeeder.sh restart" 164 | alias ssss="nano +60 /etc/serverSpeeder.conf" 165 | alias lssa="/appex/bin/lotServer.sh start" 166 | alias lssb="/appex/bin/lotServer.sh stop" 167 | alias lssc="/appex/bin/lotServer.sh status" 168 | alias lssr="/appex/bin/lotServer.sh restart" 169 | alias lsss="nano +60 /appex/etc/config" 170 | alias nginxr="/etc/init.d/nginx restart" 171 | alias nginxs="nano +50 /etc/nginx/sites-available/default" 172 | 173 | alias yongle="du -sB GiB" 174 | alias yongle2="du -sB MiB" 175 | alias rclonec='echo;echo q | rclone config | grep -Ev ".*\)|e/.*"' 176 | alias scrgd="screen -U -R GoogleDrive" 177 | alias scrgda="screen -U -r -d GoogleDrive" 178 | alias scrgdb="screen -S GoogleDrive -X quit" 179 | function scrb(){ screen -S $1 -X quit ;} 180 | 181 | alias dddd='rm -rf' 182 | alias ..='cd ..' 183 | alias path='echo -e \${PATH//:/\\\\n}' 184 | alias libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}' 185 | alias dh='df -kTh' 186 | alias aatop="TERM=st atop 1" 187 | alias px="ps aux | grep -v grep | grep" 188 | alias tree="tree --dirsfirst" 189 | alias l="ls -hAv --color --group-directories-first" 190 | alias ll="ls -hAlvZ --color --group-directories-first" 191 | alias ios="iostat -dxm 1" 192 | alias vms="vmstat 1 10" 193 | alias vns="vnstat -l" 194 | alias vnss="vnstat -m ; vnstat -d" 195 | alias vnsa="systemctl start vnstat" 196 | alias vnsb="systemctl stop vnstat" 197 | alias vnsc="systemctl status vnstat" 198 | alias vnsr="systemctl restart vnstat" 199 | 200 | alias abench="bash <(wget -qO- https://github.com/Aniverse/A/raw/i/a)" 201 | alias bench.sh="wget -qO- bench.sh | bash" 202 | alias fiobench="bash <(wget -qO- https://github.com/amefs/fio-bench/raw/master/fio-bench_zh-cn.sh -o /dev/null)" 203 | 204 | alias sousuo="find / -name" 205 | alias sousuo2="find /home/$iUser -name" 206 | alias swapon="dd if=/dev/zero of=/etc/.swapfile bs=1M count=2048;mkswap /etc/.swapfile;swapon /etc/.swapfile;swapon -s" 207 | alias swapoff="swapoff /etc/.swapfile;rm -f /etc/.swapfile" 208 | 209 | alias yuan="nano +20 /etc/apt/sources.list" 210 | alias sshr="sed -i '/.*AllowGroups.*/d' /etc/ssh/sshd_config ; sed -i '/.*PasswordAuthentication.*/d' /etc/ssh/sshd_config ; sed -i '/.*PermitRootLogin.*/d' /etc/ssh/sshd_config ; echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config ; /etc/init.d/ssh restart >/dev/null 2>&1 && echo -e '\n已开启 root 登陆\n'" 211 | 212 | alias jxe="journalctl -xe" 213 | 214 | ######################################################################################################### Shared Seedbox 215 | 216 | if [[ -d $HOME/.iferal ]]; then 217 | alias sysr="systemctl --user daemon-reload" 218 | alias qba="systemctl --user start qbittorrent" 219 | alias qbb="systemctl --user stop qbittorrent" 220 | alias qbc="systemctl --user status qbittorrent" 221 | alias qbr="systemctl --user restart qbittorrent" 222 | fi 223 | 224 | alias space='du -sB GiB $HOME/' 225 | alias zjpid='ps aux | egrep "$(whoami)|COMMAND" | egrep -v "grep|aux|root"' 226 | 227 | ######################################################################################################### QuickBox 228 | 229 | if [[ -d /etc/QuickBox ]] && [[ -n $iUser ]]; then 230 | alias qba="systemctl start qbittorrent@$iUser" 231 | alias qbb="systemctl stop qbittorrent@$iUser" 232 | alias qbc="systemctl status qbittorrent@$iUser" 233 | alias qbr="systemctl restart qbittorrent@$iUser" 234 | alias dea="systemctl start deluged@$iUser" 235 | alias deb="systemctl stop deluged@$iUser" 236 | alias dec="systemctl status deluged@$iUser" 237 | alias der="systemctl restart deluged@$iUser" 238 | alias dewa="systemctl start deluge-web@$iUser" 239 | alias dewb="systemctl stop deluge-web@$iUser" 240 | alias dewc="systemctl status deluge-web@$iUser" 241 | alias dewr="systemctl restart deluge-web@$iUser" 242 | alias tra="systemctl start transmission@$iUser" 243 | alias trb="systemctl stop transmission@$iUser" 244 | alias trc="systemctl status transmission@$iUser" 245 | alias trr="systemctl restart transmission@$iUser" 246 | alias rta="systemctl start rtorrent@$iUser" 247 | alias rtb="systemctl stop rtorrent@$iUser" 248 | alias rtc="systemctl status rtorrent@$iUser" 249 | alias rtr="systemctl restart rtorrent@$iUser" 250 | alias rtscreen="chmod -R 777 /dev/pts && su $iUser -c 'screen -r rtorrent'" 251 | alias irssia="systemctl start irssi@$iUser" 252 | alias irssib="systemctl stop irssi@$iUser" 253 | alias irssic="systemctl status irssi@$iUser" 254 | alias irssir="systemctl restart irssi@$iUser" 255 | alias irssiscreen="chmod -R 777 /dev/pts && su $iUser -c 'screen -r irssi'" 256 | alias fga="systemctl start flexget@$iUser" 257 | alias fgb="systemctl stop flexget@$iUser" 258 | alias fgc="systemctl status flexget@$iUser" 259 | alias fgr="systemctl restart flexget@$iUser" 260 | alias rtyongle="du -sB GiB /home/$iUser/torrents/rtorrent" 261 | alias qbyongle="du -sB GiB /home/$iUser/torrents/qbittorrent" 262 | alias deyongle="du -sB GiB /home/$iUser/torrents/deluge" 263 | alias tryongle="du -sB GiB /home/$iUser/torrents/transmission" 264 | alias cdde="cd /home/$iUser/torrents/deluge" 265 | alias cdqb="cd /home/$iUser/torrents/qbittorrent" 266 | alias cdrt="cd /home/$iUser/torrents/rtorrent" 267 | alias cdtr="cd /home/$iUser/torrents/transmission" 268 | fi 269 | 270 | ######################################################################################################### 271 | 272 | # Disable mail check/warning 273 | shopt -u mailwarn 274 | unset MAILCHECK 275 | 276 | # Custom History Format 277 | HISTFILESIZE=4000 278 | HISTSIZE=4000 279 | export HISTTIMEFORMAT="${yellow}[%F]${cyan}[%T]${normal} " 280 | 281 | # Disable mail check/warning 282 | shopt -u mailwarn 283 | unset MAILCHECK 284 | 285 | ######################################################################################################### 286 | 287 | PS1='\[\e[1;35m\][\t] \[\e[1;34m\]\! \[\e[1;31m\]\u\[\e[1;33m\]@\[\e[1;36m\]\h \[\e[1;33m\]\w \[\e[1;32m\]$ \[\e[0m\]' 288 | -------------------------------------------------------------------------------- /scripts/r8168: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: Aniverse 3 | # https://github.com/Aniverse/aBox 4 | 5 | #################################################################################################### 6 | 7 | script_update=2020.07.12 8 | script_version=r22033 9 | 10 | #################################################################################################### 11 | usage_guide() { 12 | bash <(wget -qO- https://github.com/Aniverse/aBox/raw/master/scripts/r8168) 13 | s=/usr/local/bin/r8168 ; rm -f $s ; nano $s ; chmod 755 $s 14 | } 15 | 16 | #################################################################################################### 17 | 18 | black=$(tput setaf 0) ; red=$(tput setaf 1) ; green=$(tput setaf 2) ; yellow=$(tput setaf 3); bold=$(tput bold) 19 | blue=$(tput setaf 4) ; magenta=$(tput setaf 5) ; cyan=$(tput setaf 6) ; white=$(tput setaf 7) ; normal=$(tput sgr0) 20 | on_black=$(tput setab 0); on_red=$(tput setab 1) ; on_green=$(tput setab 2); on_yellow=$(tput setab 3) 21 | on_blue=$(tput setab 4) ; on_magenta=$(tput setab 5) ; on_cyan=$(tput setab 6) ; on_white=$(tput setab 7) 22 | shanshuo=$(tput blink) ; wuguangbiao=$(tput civis) ; guangbiao=$(tput cnorm) ; jiacu=${normal}${bold} 23 | underline=$(tput smul) ; reset_underline=$(tput rmul) ; dim=$(tput dim) 24 | standout=$(tput smso) ; reset_standout=$(tput rmso) ; title=${standout} 25 | baihuangse=${white}${on_yellow}; bailanse=${white}${on_blue} ; bailvse=${white}${on_green} 26 | baiqingse=${white}${on_cyan} ; baihongse=${white}${on_red} ; baizise=${white}${on_magenta} 27 | heibaise=${black}${on_white} ; heihuangse=${on_yellow}${black} 28 | 29 | #################################################################################################### 30 | 31 | [[ $EUID != 0 ]] && echo -e "没 root 跑个蛋" && exit 1 32 | 33 | CODENAME=$(cat /etc/os-release | grep VERSION= | tr '[A-Z]' '[a-z]' | sed 's/\"\|(\|)\|[0-9.,]\|version\|lts//g' | awk '{print $2}') 34 | kernel=$(uname -r) 35 | kernelvvv=$(uname -r | grep -oE [0-9.-]+ | head -1) 36 | KNA=$(awk -F'[= "]' '/PRETTY_NAME/{print $3}' /etc/os-release) 37 | KernelBit=$(getconf LONG_BIT) 38 | 39 | [ -n "$(grep 'eth0:' /proc/net/dev)" ] && wangka1=eth0 || wangka1=`cat /proc/net/dev |awk -F: 'function trim(str){sub(/^[ \t]*/,"",str); sub(/[ \t]*$/,"",str); return str } NR>2 {print trim($1)}' |grep -Ev '^lo|^sit|^stf|^gif|^dummy|^vmnet|^vir|^gre|^ipip|^ppp|^bond|^tun|^tap|^ip6gre|^ip6tnl|^teql|^venet|^he-ipv6|^docker' |awk 'NR==1 {print $0}'` 40 | wangka2=$(ip link show | grep -i broadcast | grep -m1 UP | cut -d: -f 2 | cut -d@ -f 1 | sed 's/ //g') 41 | 42 | if [[ -n $wangka2 ]]; then 43 | if [[ $wangka1 == $wangka2 ]];then 44 | interface=$wangka1 45 | else 46 | interface=$wangka2 47 | interface_diff=yes 48 | fi 49 | else 50 | interface=$wangka1 51 | fi 52 | 53 | mkdir -p /log/script 54 | OutputLOG=/log/script/r8168.log 55 | 56 | #################################################################################################### 57 | 58 | function version_ge(){ test "$(echo "$@" | tr " " "\n" | sort -rV | head -1)" == "$1" ; } 59 | function version_gt(){ test "$(printf '%s\n' "$@" | sort -V | head -1)" != "$1"; } 60 | 61 | function apt_install_check() { 62 | unset apt_install_list 63 | packages=("$@") 64 | [[ -z "$packages" ]] && echo "ERROR: No packages" | tee -a $OutputLOG && exit 1 65 | for package in "${packages[@]}" ; do 66 | dpkg-query -W -f='${Status}' $package 2>/dev/null | grep -q "ok installed" || apt_install_list="$apt_install_list $package" 67 | done 68 | } 69 | 70 | function apt_install_together() { 71 | if [[ -n "$apt_install_list" ]]; then 72 | apt-get update 2>&1 | tee -a "$OutputLOG" 73 | eval DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install "$apt_install_list" >> "$OutputLOG" 2>&1 74 | if [ ! $? = 0 ]; then 75 | echo -e "ERROR: Failed to install packages" 2>&1 | tee -a "$OutputLOG" 76 | exit 1 77 | fi 78 | fi 79 | } 80 | 81 | function check_apps() { 82 | echo -e "${bold}Checking necessary dependency ...${normal}" 83 | apt_install_check net-tools ethtool iperf iperf3 84 | apt_install_together 85 | } 86 | 87 | function show_headers() { 88 | echo -e "${bold}Kernel and headers installed in your system${blue}" 89 | echo $kernel 90 | echo -n "${yellow}" 91 | dpkg -l | grep linux-image | awk '{print $2}' 92 | dpkg -l | grep linux-headers | awk '{print $2}' 93 | echo -n "${normal}" 94 | dpkg -l | grep linux-headers | grep $kernelvvv -q || echo -e "${bold}${baihongse}Warning${jiacu} No match headers found${normal}" 95 | version_ge $kernelvvv 4.17 && echo -e "${bold}${baihongse}ATTENTION${jiacu} You do not need r8168 if your kernel is higher than 4.16${normal}" 96 | echo 97 | } 98 | 99 | function show_iface() { 100 | echo -e "${bold}The followings are details about your current interface${yellow}" 101 | if [[ -n $interface_diff ]]; then 102 | echo -e "Interface: $wangka1\nInterface: $wangka2" 103 | else 104 | echo -e "Interface: $wangka1" 105 | fi 106 | echo -e "${normal}${bold}ethtool -i $interface${yellow}" 107 | ethtool -i $interface 108 | echo -e "${normal}" 109 | } 110 | 111 | function kill_appex() { 112 | [[ -f /appex/bin/serverSpeeder.sh ]] && { /appex/bin/serverSpeeder.sh stop ; /appex/bin/serverSpeeder.sh status ; ruisu=y ; } 113 | [[ -f /appex/bin/lotServer.sh ]] && { /appex/bin/lotServer.sh stop ; /appex/bin/lotServer.sh status ; ruisu=y ; } 114 | [[ -z $ruisu ]] && echo -e "\n${red}No ServerSpeeder or LotServer Found${normal}\n" || echo -e "\n${red}ServerSpeeder or LotServer has been shut down ...${normal}\n" 115 | } 116 | 117 | function ask_iperf() { 118 | echo 119 | read -ep "${bold}${red}Would you like to do iperf test? [Y/n]${normal} " responce 120 | case $responce in 121 | [yY] | [yY][Ee][Ss] | "") do_iperf ;; 122 | [nN] | [nN][Oo] ) sleep 0 ;; 123 | * ) do_iperf ;; 124 | esac 125 | } 126 | 127 | function do_iperf() { 128 | echo -e "\n${bold}${cyan}iperf -c iperf.ovh.net -i 1 -t 4${normal}" 129 | iperf -c iperf.ovh.net -i 1 -t 4 130 | echo -e "\n${bold}${cyan}iperf3 -c ping-ams1.online.net -p 5203 -t 4${normal}" 131 | iperf3 -c ping-ams1.online.net -p 5203 -t 4 132 | echo -e "\n${bold}${cyan}iperf3 -c bouygues.testdebit.info -p 5203 -4 -t 4${normal}" 133 | iperf3 -c bouygues.testdebit.info -p 5203 -4 -t 4 134 | echo -e "\n${bold}${cyan}DONE${normal}\n" 135 | } 136 | 137 | #################################################################################################### 138 | 139 | function r8168_driver() { 140 | # read -ep "${bold}确定 headers 已经安装、内核已安装并重启过了?${normal}" 141 | for app in dkms ; do # firmware-realtek 142 | dpkg -l | grep $app -q && apt-get purge -y $app 143 | done 144 | 145 | apt_install_check build-essential libelf-dev 146 | apt_install_together 147 | if [[ $CODENAME == buster ]] && ! version_ge $kernelvvv 4.15; then 148 | install_old_binutils 149 | fi 150 | 151 | rm -rf r8168-8.046.00.tar.bz2 r8168-8.046.00 152 | wget -O r8168-8.046.00.tar.bz2 https://github.com/Aniverse/inexistence-files/raw/master/firmware/r8168-8.046.00.tar.bz2 153 | tar xfvj r8168-8.046.00.tar.bz2; rm -rf r8168-8.046.00.tar.bz2 ; cd r8168-8.046.00 154 | # https://community.hetzner.com/tutorials/installing-the-r8168-driver?title=Installation_des_r8168-Treibers/en 155 | # make modules 156 | # echo ; read -ep "${bold}Press ${baihongse}ENTER${jiacu} to continue ${normal}" 157 | if [[ $self == 1 ]]; then 158 | r8168_autorun 159 | else 160 | { ./autorun.sh || modprobe r8169 ; } 2>&1 | tee -a $OutputLOG 161 | fi 162 | cd .. ; rm -rf r8168-8.046.00 163 | 164 | [[ $reboot == y ]] && { reboot -f ; init 6 ; } 165 | show_iface 166 | ask_iperf 167 | } 168 | 169 | #################################################################################################### 170 | 171 | function r8168_dkms() { 172 | for app in dkms ; do 173 | dpkg -l | grep $app -q && apt-get purge -y $app 174 | done 175 | 176 | apt-get update && apt-get install -y dkms | tee -a $OutputLOG 177 | 178 | if [[ $CODENAME == bionic ]]; then 179 | headers_list="$(apt-cache search linux-image-4.15.0.*generic | sort | tail -1 | awk '{print $1}') $(apt-cache search linux-headers-4.15.0.*generic | sort | tail -1 | awk '{print $1}')" 180 | elif [[ $CODENAME == xenial ]]; then 181 | headers_list="$(apt-cache search linux-image-4.4.0.*generic | sort | tail -1 | awk '{print $1}') $(apt-cache search linux-headers-4.4.0.*generic | sort | tail -1 | awk '{print $1}')" 182 | elif [[ $CODENAME == jessie ]]; then 183 | headers_list="$(apt-cache search linux-image-3.16.0.*amd64 | grep -Ev "rt|cloud|unsigned|dbg" | sort | tail -1 | awk '{print $1}') $(apt-cache search linux-headers-3.16.0.*amd64 | grep -Ev "rt|cloud|unsigned|dbg" | sort | tail -1 | awk '{print $1}')" 184 | elif [[ $CODENAME == stretch ]]; then 185 | headers_list="$(apt-cache search linux-image-4.9.0.*amd64 | grep -Ev "rt|cloud|unsigned|dbg" | sort | tail -1 | awk '{print $1}') $(apt-cache search linux-headers-4.9.0.*amd64 | grep -Ev "rt|cloud|unsigned|dbg" | sort | tail -1 | awk '{print $1}')" 186 | elif [[ $CODENAME == buster ]]; then 187 | headers_list="$(apt-cache search linux-image-4.19.0.*amd64 | grep -Ev "rt|cloud|unsigned|dbg" | sort | tail -1 | awk '{print $1}') $(apt-cache search linux-headers-4.19.0.*amd64 | grep -Ev "rt|cloud|unsigned|dbg" | sort | tail -1 | awk '{print $1}')" 188 | fi 189 | 190 | [[ -n "$headers_list" ]] && apt-get purge -y "$headers_list" 191 | wget https://github.com/Aniverse/inexistence-files/raw/master/firmware/r8168-dkms_8.040.00-1_all.deb -O r8168-dkms_8.040.00-1_all.deb 192 | dpkg -i r8168-dkms_8.040.00-1_all.deb 193 | rm -f r8168-dkms_8.040.00-1_all.deb 194 | 195 | [[ $reboot == y ]] && { reboot -f ; init 6 ; } 196 | show_iface 197 | ask_iperf 198 | } 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | #################################################################################################### 207 | 208 | # https://github.com/JiangXL/ColorMapping/issues/1 209 | # https://www.reddit.com/r/linuxquestions/comments/903xwq/unable_to_compile_working_kernel_modules_anymore/ 210 | function install_old_binutils() { 211 | if version_gt $(dpkg-query -W binutils | awk '{print $NF}') 2.30-22 ; then 212 | echo -e "${bold}Downgrading binutils to 2.30-22 ...${normal}" 213 | echo "deb http://snapshot.debian.org/archive/debian/20180625T120000Z/ sid main" > /etc/apt/sources.list.d/old.binutils.list 214 | apt-get -o Acquire::Check-Valid-Until=false update 215 | apt-get install -y --allow-downgrades binutils:amd64=2.30-22 binutils-common:amd64=2.30-22 binutils-dev:amd64=2.30-22 binutils-x86-64-linux-gnu:amd64=2.30-22 libbinutils:amd64=2.30-22 216 | # 不需要 apt hold,之后版本升级了也没事 217 | rm -f /etc/apt/sources.list.d/old.binutils.list 218 | apt-get update 219 | else 220 | echo -e "${bold}binutils' version is already le 2.30-22 ...${normal}" 221 | fi 222 | } 223 | 224 | function _excute() { 225 | ($1 2>&1 | tee -a $OutputLOG) 226 | } 227 | 228 | function rmmod_old_driver(){ 229 | echo "Check old driver and unload it." 230 | check=`lsmod | grep r8169` 231 | if [ "$check" != "" ]; then 232 | echo "rmmod r8169" 233 | /sbin/rmmod r8169 234 | fi 235 | 236 | check=`lsmod | grep r8168` 237 | if [ "$check" != "" ]; then 238 | echo "rmmod r8168" 239 | /sbin/rmmod r8168 240 | fi 241 | } 242 | 243 | function r8168_autorun() { 244 | TARGET_PATH=$(find /lib/modules/$(uname -r)/kernel/drivers/net/ethernet -name realtek -type d) 245 | if [ "$TARGET_PATH" = "" ]; then 246 | TARGET_PATH=$(find /lib/modules/$(uname -r)/kernel/drivers/net -name realtek -type d) 247 | fi 248 | if [ "$TARGET_PATH" = "" ]; then 249 | TARGET_PATH=/lib/modules/$(uname -r)/kernel/drivers/net 250 | fi 251 | echo 252 | 253 | echo "Build the module and install" | tee -a $OutputLOG 254 | echo "-------------------------------" | tee -a $OutputLOG 255 | echo "$(date "+%Y%m%d.%H%M")" | tee -a $OutputLOG 256 | _excute "make $@ all" 257 | module=`ls src/*.ko` 258 | module=${module#src/} 259 | module=${module%.ko} 260 | 261 | if [ "$module" = "" ]; then 262 | echo "No driver exists!!!" | tee -a $OutputLOG 263 | exit 1 264 | elif [ "$module" != "r8169" ]; then 265 | if test -e $TARGET_PATH/r8169.ko ; then 266 | echo "Backup r8169.ko" | tee -a $OutputLOG 267 | if test -e $TARGET_PATH/r8169.bak ; then 268 | i=0 269 | while test -e $TARGET_PATH/r8169.bak$i 270 | do 271 | i=$(($i+1)) 272 | done 273 | echo "rename r8169.ko to r8169.bak$i" | tee -a $OutputLOG 274 | _excute "mv $TARGET_PATH/r8169.ko $TARGET_PATH/r8169.bak$i" 275 | else 276 | echo "rename r8169.ko to r8169.bak" | tee -a $OutputLOG 277 | _excute "mv $TARGET_PATH/r8169.ko $TARGET_PATH/r8169.bak" 278 | fi 279 | fi 280 | fi 281 | 282 | echo "DEPMOD $(uname -r)" | tee -a $OutputLOG 283 | _excute "depmod $(uname -r)" 284 | echo "load module $module" | tee -a $OutputLOG 285 | modprobe $module 2>&1 | tee -a $OutputLOG || r8168_failed=yes 286 | 287 | echo "blacklist r8169" >> /etc/modprobe.d/blacklist.conf 288 | echo "r8168" >> /etc/initramfs-tools/modules 289 | 290 | is_update_initramfs=n 291 | distrib_list="ubuntu debian" 292 | 293 | if [ -r /etc/debian_version ]; then 294 | is_update_initramfs=y 295 | elif [ -r /etc/lsb-release ]; then 296 | for distrib in $distrib_list 297 | do 298 | /bin/grep -i "$distrib" /etc/lsb-release 2>&1 /dev/null && \ 299 | is_update_initramfs=y && break 300 | done 301 | fi 302 | 303 | if [ "$is_update_initramfs" = "y" ]; then 304 | if which update-initramfs >/dev/null ; then 305 | echo "Updating initramfs. Please wait." | tee -a $OutputLOG 306 | _excute "update-initramfs -u -k $(uname -r)" 307 | else 308 | echo "update-initramfs: command not found" | tee -a $OutputLOG 309 | exit 1 310 | fi 311 | fi 312 | 313 | if [[ $r8168_failed == yes ]]; then 314 | echo -e "${jiacu}${baihongse}ERROR${jiacu} FAILED 失败${normal}" | tee -a $OutputLOG 315 | else 316 | echo "Completed." | tee -a $OutputLOG 317 | fi 318 | } 319 | 320 | 321 | 322 | #################################################################################################### 323 | 324 | 325 | 326 | 327 | check_apps 328 | kill_appex 329 | show_iface 330 | show_headers 331 | 332 | echo -e "$script_update ($script_version)" 333 | echo -e "${green}1)${normal} Compile r8168 driver using modified autorun.sh (recommend)" 334 | echo -e "${green}2)${normal} Compile r8168 driver" 335 | echo -e "${green}3)${normal} Install r8168 via dkms" 336 | # echo -e "${green}6)${normal} rmmod r8169 and then reboot" 337 | echo -e "${green}9)${normal} Do iperf test" 338 | read -ep "${bold}${yellow}What would you like to do? ${normal}" responce 339 | case $responce in 340 | 1 ) self=1 ; r8168_driver ;; 341 | 2 ) r8168_driver ;; 342 | 3 ) r8168_dkms ;; 343 | 6 ) echo "rmmod r8169" ; /sbin/rmmod r8169 ; reboot -f ; init 6 ;; 344 | 9 ) do_iperf ;; 345 | * ) exit 1 ;; 346 | esac 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | #################################################################################################### 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | function Notes() { 381 | # the followings are dkms logs 382 | ############ Debian 9 ############ 383 | dh-python distro-info-data file libmagic-mgc libmagic1 libmpdec2 libpython3-stdlib libpython3.5-minimal 384 | libpython3.5-stdlib linux-compiler-gcc-6-x86 linux-headers-4.9.0-8-amd64 linux-headers-4.9.0-8-common 385 | linux-headers-amd64 linux-kbuild-4.9 lsb-release mime-support python3 python3-minimal python3.5 python3.5-minimal 386 | ############ 387 | (Reading database ... 44527 files and directories currently installed.) 388 | Preparing to unpack r8168-dkms_8.040.00-1_all.deb ... 389 | 390 | ------------------------------ 391 | Deleting module version: 8.040.00 392 | completely from the DKMS tree. 393 | ------------------------------ 394 | Done. 395 | Unpacking r8168-dkms 8.040.00-1 over 8.040.00-1 ... 396 | Setting up r8168-dkms 8.040.00-1 ... 397 | Loading new r8168-8.040.00 DKMS files... 398 | Building for 3.16.0-4-amd64 399 | Building initial module for 3.16.0-4-amd64 400 | Done. 401 | 402 | r8168: 403 | Running module version sanity check. 404 | - Original module 405 | - No original module exists within this kernel 406 | - Installation 407 | - Installing to /lib/modules/3.16.0-4-amd64/updates/dkms/ 408 | 409 | depmod.... 410 | 411 | Backing up initrd.img-3.16.0-4-amd64 to /boot/initrd.img-3.16.0-4-amd64.old-dkms 412 | Making new initrd.img-3.16.0-4-amd64 413 | (If next boot fails, revert to initrd.img-3.16.0-4-amd64.old-dkms image) 414 | update-initramfs.... 415 | 416 | DKMS: install completed. 417 | 418 | ######################## 419 | 420 | Check old driver and unload it. 421 | rmmod r8169 422 | Build the module and install 423 | At main.c:160: 424 | - SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:74 425 | - SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:81 426 | sign-file: certs/signing_key.pem: No such file or directory 427 | Warning: modules_install: missing 'System.map' file. Skipping depmod. 428 | Backup r8169.ko 429 | rename r8169.ko to r8169.bak 430 | DEPMOD 4.19.51-xanmod26 431 | load module r8168 432 | Updating initramfs. Please wait. 433 | update-initramfs: Generating /boot/initrd.img-4.19.51-xanmod26 434 | Completed. 435 | 436 | ######################## Debian 10 3.16.0-4, FAILED 437 | 438 | Backup r8169.ko 439 | rename r8169.ko to r8169.bak 440 | DEPMOD 3.16.0-4-amd64 441 | load module r8168 442 | modprobe: ERROR: could not insert 'r8168': Exec format error 443 | Updating initramfs. Please wait. 444 | update-initramfs: Generating /boot/initrd.img-3.16.0-4-amd64 445 | cryptsetup: ERROR: Couldn't resolve device rootfs 446 | cryptsetup: WARNING: The initramfs image may not contain cryptsetup binaries 447 | nor crypto modules. If that's on purpose, you may want to uninstall the 448 | 'cryptsetup-initramfs' package in order to disable the cryptsetup initramfs 449 | integration and avoid this warning. 450 | Completed. 451 | } 452 | 453 | -------------------------------------------------------------------------------- /scripts/syslog: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: Aniverse 3 | # 4 | script_update=2020.03.10 5 | script_version=r10000 6 | 7 | usage() { 8 | s=/usr/local/bin/syslog;rm -f $s;nano $s;chmod 755 $s 9 | syslog deluged 10 | syslog deluged -C5 11 | } 12 | 13 | ################################################################################ 14 | 15 | keyword=$1 16 | flags=$2 17 | 18 | if [[ -n $flags ]]; then 19 | for log in $(ls /var/log | grep syslog); do 20 | printf "%-50s\n" "-" | sed 's/\s/-/g' ; echo $log ; printf "%-50s\n" "-" | sed 's/\s/-/g' 21 | if echo $log | grep -q gz; then 22 | gunzip -c /var/log/$log | grep -i $keyword 23 | else 24 | grep -i $keyword /var/log/$log 25 | fi 26 | done 27 | else 28 | for log in $(ls /var/log | grep syslog); do 29 | printf "%-50s\n" "-" | sed 's/\s/-/g' ; echo $log ; printf "%-50s\n" "-" | sed 's/\s/-/g' 30 | if echo $log | grep -q gz; then 31 | gunzip -c /var/log/$log | eval grep -i $keyword "$flags" 32 | else 33 | eval grep -i $keyword /var/log/$log "$flags" 34 | fi 35 | done 36 | fi 37 | -------------------------------------------------------------------------------- /scripts/torrent-rename: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: Aniverse 3 | # https://github.com/Aniverse/aBox 4 | ######################################################################################################### 5 | script_update=2020.03.30 6 | script_version=r12007 7 | 8 | usage_guide() { 9 | s=/usr/local/bin/torrent-rename ; rm -f $s ; nano $s ; chmod 755 $s 10 | } 11 | 12 | ######################################################################################################### 13 | 14 | [[ $1 == -d ]] && debug=1 15 | [[ $1 == -v ]] && verbose=1 16 | 17 | 18 | command -v transmission-show > /dev/null || { echo -e "Error: No transmission-show" ; exit 1 ; } # apt-get install transmission-cli -y 19 | command -v lstor > /dev/null || { echo -e "Error: No lstor" ; exit 1 ; } # pip install pyrocore 20 | command -v bc > /dev/null || { echo -e "Error: No bc" ; exit 1 ; } # apt-get install bc -y 21 | 22 | ######################################################################################################### 23 | 24 | function edit_trackers() { 25 | tracker=$(echo $tracker | sed 's/.org//') 26 | tracker=$(echo $tracker | sed 's/.net//') 27 | tracker=$(echo $tracker | sed 's/.cn//') 28 | tracker=$(echo $tracker | sed 's/.com//') 29 | tracker=$(echo $tracker | sed 's/.me//') 30 | tracker=$(echo $tracker | sed 's/.cc//') 31 | tracker=$(echo $tracker | sed 's/.xyz//') 32 | tracker=$(echo $tracker | sed 's/tracker.//') 33 | tracker=$(echo $tracker | sed 's/announce.//') 34 | tracker=$(echo $tracker | sed 's/a.//') 35 | echo $tracker | grep -q "moose.awesome-hd.me" && tracker=AHD 36 | echo $tracker | grep -q world-in-hd && tracker=WiHD 37 | echo $tracker | grep -q "landof.tv" && tracker=BTN 38 | echo $tracker | grep -q "stackoverflow.tech" && tracker=IPT 39 | echo $tracker | grep -q "flacsfor.me" && tracker=Red 40 | echo $tracker | grep -q "hdts-announce" && tracker=HDTs 41 | echo $tracker | grep -q "seedsfor.me" && tracker=T 42 | echo $tracker | grep -q "seedingfor.me" && tracker=S 43 | echo $tracker | grep -qE ":[0-9]+" && tracker=$(echo $tracker | sed "s/:[0-9]\{1,5\}//") # remove ports 44 | } 45 | 46 | ######################################################################################################### 47 | 48 | [ -f tmp.ti.txt ] && rm -f tmp.ti.txt 49 | mkdir -p renamed ; echo 50 | 51 | for file in $PWD/*.torrent; do 52 | [[ $debug == 1 ]] && echo $file > tmp.ti.txt 53 | transmission-show "$file" >> tmp.ti.txt 54 | name=$(cat tmp.ti.txt | grep ' Name' | grep -Po '.*Name: \K.*') 55 | [[ $debug == 1 ]] && echo $name 56 | tracker=$(cat tmp.ti.txt | grep -v Comment | grep http | head -1 | grep -Po '\/\/(.*?)\/' | grep -Po '[^\/]+(?=\/)') 57 | [[ $debug == 1 ]] && echo $tracker 58 | torrent_file_num=$( lstor -V "$file" 2>1 | grep LISTING | grep -oP "\d+") ; [ -z $torrent_file_num ] && torrent_file_num=1 59 | [[ $debug == 1 ]] && echo $torrent_file_num 60 | size=$(lstor -V "$file" 2>1 | head -10 | grep SIZE | awk '{print $2,$3}') 61 | [[ $debug == 1 ]] && echo $size 62 | piece=$(cat tmp.ti.txt | grep "Piece Count" | awk '{print $NF}') 63 | psize=$(cat tmp.ti.txt | grep "Piece Size" | awk '{print $(NF-1),$NF}' | sed 's/ //') 64 | edit_trackers 65 | filename="[${tracker}][$size] $name.torrent" 66 | [[ $verbose == 1 ]] && filename="[${tracker}] $name [$torrent_file_num files][$psize x $piece = $size].torrent" 67 | [[ $debug == 1 ]] && echo "$PWD/renamed/$filename" 68 | cp "$file" "${PWD}/renamed/${filename}" 69 | echo -e "$(tput bold)$(tput setaf 3)Origin: $(tput sgr0)$(tput smul)$(basename "$file")$(tput rmul)\n$(tput bold)$(tput setaf 3)Rename: $(tput sgr0)$filename\n" 70 | [[ -z $debug ]] && rm -f tmp.ti.txt 71 | done 72 | --------------------------------------------------------------------------------