├── .gitattributes ├── requirements.txt ├── readme.md └── install.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | ehforwarderbot 2 | efb-telegram-master 3 | efb-wechat-slave 4 | efb-telegram-master[tgs] -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # efb 一键本地部署脚本 2 | --- 3 | efb 本地部署脚本 不支持 docker 4 | 5 | 需要 root 权限运行 6 | 7 | ``` 8 | wget https://raw.githubusercontent.com/shzxm/efb-install/main/install.sh -O install.sh && chmod +x install.sh && bash install.sh 9 | ``` 10 | 11 | 目前支持 Centos7 Ubuntu18/20 Debian8/9/10 12 | 13 | 14 | 欢迎来我 [blog](https://blog.shzxm.com) 观看 [手动部署教程](https://blog.shzxm.com/2020/12/31/efb/) 15 | 16 | 相关的配置文件修改 [blog](https://blog.shzxm.com) 也有写 17 | 18 | 有问题欢迎随时提 19 | 20 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ $EUID -ne 0 ]]; then 3 | clear 4 | echo "错误:本脚本需要 root 权限执行。" 1>&2 5 | exit 1 6 | fi 7 | 8 | check_sys() { 9 | if [[ -f /etc/redhat-release ]]; then 10 | release="centos" 11 | elif cat /etc/issue | grep -q -E -i "debian"; then 12 | release="debian" 13 | elif cat /etc/issue | grep -q -E -i "ubuntu"; then 14 | release="ubuntu" 15 | elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then 16 | release="centos" 17 | elif cat /proc/version | grep -q -E -i "debian"; then 18 | release="debian" 19 | elif cat /proc/version | grep -q -E -i "ubuntu"; then 20 | release="ubuntu" 21 | elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then 22 | release="centos" 23 | fi 24 | } 25 | 26 | welcome() { 27 | echo "" 28 | echo "欢迎使用 efb 一键安装程序。" 29 | echo "安装即将开始" 30 | echo "如果您想取消安装," 31 | echo "请在 3 秒钟内按 Ctrl+C 终止此脚本。" 32 | echo "" 33 | sleep 3 34 | } 35 | 36 | yum_update() { 37 | echo "正在优化 yum . . ." 38 | echo "此过程稍慢 因为需要升级系统依赖" 39 | yum install yum-utils epel-release -y >>/dev/null 2>&1 40 | yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm -y >>/dev/null 2>&1 41 | yum update -y >>/dev/null 2>&1 42 | } 43 | 44 | yum_git_check() { 45 | echo "正在检查 Git 安装情况 . . ." 46 | if command -v git >>/dev/null 2>&1; then 47 | echo "Git 似乎存在,安装过程继续 . . ." 48 | else 49 | echo "Git 未安装在此系统上,正在进行安装" 50 | yum install git -y >>/dev/null 2>&1 51 | fi 52 | } 53 | 54 | yum_python_check() { 55 | echo "正在检查 python 安装情况 . . ." 56 | if command -v python3 >>/dev/null 2>&1; then 57 | U_V1=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1}') 58 | U_V2=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $2}') 59 | if [ $U_V1 -gt 3 ]; then 60 | echo 'Python 3.6+ 存在 . . .' 61 | elif [ $U_V2 -ge 6 ]; then 62 | echo 'Python 3.6+ 存在 . . .' 63 | PYV=$U_V1.$U_V2 64 | PYV=$(which python$PYV) 65 | else 66 | if command -v python3.6 >>/dev/null 2>&1; then 67 | echo 'Python 3.6+ 存在 . . .' 68 | PYV=$(which python3.6) 69 | else 70 | echo "Python3.6 未安装在此系统上,正在进行安装" 71 | yum install python3 -y >>/dev/null 2>&1 72 | update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 >>/dev/null 2>&1 73 | PYV=$(which python3.6) 74 | fi 75 | fi 76 | else 77 | echo "Python3.6 未安装在此系统上,正在进行安装" 78 | yum install python3 -y >>/dev/null 2>&1 79 | update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 >>/dev/null 2>&1 80 | fi 81 | if command -v pip3 >>/dev/null 2>&1; then 82 | echo 'pip 存在 . . .' 83 | else 84 | echo "pip3 未安装在此系统上,正在进行安装" 85 | yum install -y python3-pip >>/dev/null 2>&1 86 | fi 87 | } 88 | 89 | yum_screen_check() { 90 | echo "正在检查 Screen 安装情况 . . ." 91 | if command -v screen >>/dev/null 2>&1; then 92 | echo "Screen 似乎存在, 安装过程继续 . . ." 93 | else 94 | echo "Screen 未安装在此系统上,正在进行安装" 95 | yum install screen -y >>/dev/null 2>&1 96 | fi 97 | } 98 | 99 | yum_require_install() { 100 | echo "正在安装系统所需依赖,可能需要几分钟的时间 . . ." 101 | yum update -y >>/dev/null 2>&1 102 | yum install python-devel python3-devel ffmpeg ffmpeg-devel cairo cairo-devel wget -y >>/dev/null 2>&1 103 | yum list updates >>/dev/null 2>&1 104 | } 105 | 106 | apt_update() { 107 | echo "正在优化 apt-get . . ." 108 | apt-get install sudo -y >>/dev/null 2>&1 109 | apt-get update >>/dev/null 2>&1 110 | } 111 | 112 | apt_git_check() { 113 | echo "正在检查 Git 安装情况 . . ." 114 | if command -v git >>/dev/null 2>&1; then 115 | echo "Git 似乎存在, 安装过程继续 . . ." 116 | else 117 | echo "Git 未安装在此系统上,正在进行安装" 118 | apt-get install git -y >>/dev/null 2>&1 119 | fi 120 | } 121 | 122 | apt_python_check() { 123 | echo "正在检查 python 安装情况 . . ." 124 | if command -v python3 >>/dev/null 2>&1; then 125 | U_V1=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1}') 126 | U_V2=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $2}') 127 | if [ $U_V1 -gt 3 ]; then 128 | echo 'Python 3.6+ 存在 . . .' 129 | elif [ $U_V2 -ge 6 ]; then 130 | echo 'Python 3.6+ 存在 . . .' 131 | PYV=$U_V1.$U_V2 132 | PYV=$(which python$PYV) 133 | else 134 | if command -v python3.6 >>/dev/null 2>&1; then 135 | echo 'Python 3.6+ 存在 . . .' 136 | PYV=$(which python3.6) 137 | else 138 | echo "Python3 未安装在此系统上,正在进行安装" 139 | add-apt-repository ppa:deadsnakes/ppa -y 140 | apt-get update >>/dev/null 2>&1 141 | apt-get install python3 -y >>/dev/null 2>&1 142 | update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3 1 >>/dev/null 2>&1 143 | PYV=$(which python3.6) 144 | fi 145 | fi 146 | else 147 | echo "Python3.6 未安装在此系统上,正在进行安装" 148 | add-apt-repository ppa:deadsnakes/ppa -y 149 | apt-get update >>/dev/null 2>&1 150 | apt-get install python3 -y >>/dev/null 2>&1 151 | update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3 1 >>/dev/null 2>&1 152 | fi 153 | if command -v pip3 >>/dev/null 2>&1; then 154 | echo 'pip 存在 . . .' 155 | else 156 | echo "pip3 未安装在此系统上,正在进行安装" 157 | apt-get install -y python3-pip >>/dev/null 2>&1 158 | fi 159 | } 160 | 161 | debian_python_check() { 162 | echo "正在检查 python 安装情况 . . ." 163 | if command -v python3 >>/dev/null 2>&1; then 164 | U_V1=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1}') 165 | U_V2=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $2}') 166 | if [ $U_V1 -gt 3 ]; then 167 | echo 'Python 3.6+ 存在 . . .' 168 | elif [ $U_V2 -ge 6 ]; then 169 | echo 'Python 3.6+ 存在 . . .' 170 | PYV=$U_V1.$U_V2 171 | PYV=$(which python$PYV) 172 | else 173 | if command -v python3.6 >>/dev/null 2>&1; then 174 | echo 'Python 3.6+ 存在 . . .' 175 | PYV=$(which python3.6) 176 | else 177 | echo "Python3.6 未安装在此系统上,正在进行安装" 178 | apt-get update -y >>/dev/null 2>&1 179 | apt-get install -y build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev >>/dev/null 2>&1 180 | wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz >>/dev/null 2>&1 181 | tar -xvf Python-3.8.5.tgz >>/dev/null 2>&1 182 | chmod -R +x Python-3.8.5 >>/dev/null 2>&1 183 | cd Python-3.8.5 >>/dev/null 2>&1 184 | ./configure >>/dev/null 2>&1 185 | make && make install >>/dev/null 2>&1 186 | cd .. >>/dev/null 2>&1 187 | rm -rf Python-3.8.5 Python-3.8.5.tar.gz >>/dev/null 2>&1 188 | PYP=$(which python3.6) 189 | update-alternatives --install $PYP python3 $PYV 1 >>/dev/null 2>&1 190 | fi 191 | fi 192 | else 193 | echo "Python3.6 未安装在此系统上,正在进行安装" 194 | apt-get update -y >>/dev/null 2>&1 195 | apt-get install -y build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev >>/dev/null 2>&1 196 | wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz >>/dev/null 2>&1 197 | tar -xvf Python-3.8.5.tgz >>/dev/null 2>&1 198 | chmod -R +x Python-3.8.5 >>/dev/null 2>&1 199 | cd Python-3.8.5 >>/dev/null 2>&1 200 | ./configure >>/dev/null 2>&1 201 | make && make install >>/dev/null 2>&1 202 | cd .. >>/dev/null 2>&1 203 | rm -rf Python-3.8.5 Python-3.8.5.tar.gz >>/dev/null 2>&1 204 | PYP=$(which python3) 205 | update-alternatives --install $PYP python3 $PYV 1 >>/dev/null 2>&1 206 | fi 207 | echo "正在检查 pip3 安装情况 . . ." 208 | if command -v pip3 >>/dev/null 2>&1; then 209 | echo 'pip 存在 . . .' 210 | else 211 | echo "pip3 未安装在此系统上,正在进行安装" 212 | apt-get install -y python3-pip >>/dev/null 2>&1 213 | fi 214 | } 215 | 216 | apt_screen_check() { 217 | echo "正在检查 Screen 安装情况 . . ." 218 | if command -v screen >>/dev/null 2>&1; then 219 | echo "Screen 似乎存在, 安装过程继续 . . ." 220 | else 221 | echo "Screen 未安装在此系统上,正在进行安装" 222 | apt-get install screen -y >>/dev/null 2>&1 223 | fi 224 | } 225 | 226 | apt_require_install() { 227 | echo "正在安装系统所需依赖,可能需要几分钟的时间 . . ." 228 | apt-get install python3.6-dev python3-dev ffmpeg ffmpeg-devel libcairo2-dev libcairo2 -y >>/dev/null 2>&1 229 | } 230 | 231 | debian_require_install() { 232 | echo "正在安装系统所需依赖,可能需要几分钟的时间 . . ." 233 | apt-get install python3-dev ffmpeg ffmpeg-devel libcairo2-dev libcairo2 -y >>/dev/null 2>&1 234 | } 235 | 236 | download_repo() { 237 | echo "下载 repository 中 . . ." 238 | cd /root >>/dev/null 2>&1 239 | git clone https://github.com/shzxm/efb-install.git ~/.ehforwarderbot/profiles/default/ >>/dev/null 2>&1 240 | cd ~/.ehforwarderbot/profiles/default/ >>/dev/null 2>&1 241 | echo "Hello World!" >~/.ehforwarderbot/profiles/default/.lock 242 | } 243 | 244 | pypi_install() { 245 | echo "下载安装 pypi 依赖中 . . ." 246 | $PYV -m pip install --upgrade pip >>/dev/null 2>&1 247 | $PYV -m pip install -r requirements.txt >>/dev/null 2>&1 248 | $PYV -m pip install --upgrade Pillow >>/dev/null 2>&1 249 | sudo -H $PYV -m pip install --ignore-installed PyYAML >>/dev/null 2>&1 250 | } 251 | 252 | configure() { 253 | cd /root 254 | echo "配置文件由 efb-wizard 自动生成" 255 | LANG=zh_CN.UTF-8 256 | echo "无需定制 使用默认即可" 257 | sleep 3 258 | efb-wizard 259 | } 260 | 261 | login_screen() { 262 | cd /root/.ehforwarderbot/profiles/default 263 | screen -S efb -X quit >>/dev/null 2>&1 264 | screen -L -dmS efb 265 | sleep 4 266 | echo "请打开 微信" 267 | screen -x -S efb -p 0 -X stuff "/usr/local/bin/ehforwarderbot" 268 | screen -x -S efb -p 0 -X stuff $'\n' 269 | sleep 1 270 | while [ ! -f "/root/.ehforwarderbot/profiles/default/blueset.wechat/wxpy.pkl" ]; do 271 | echo "请 扫一扫 二维码登录 微信" 272 | cat /root/.ehforwarderbot/profiles/default/screenlog.0 273 | sleep 5 274 | done 275 | sleep 5 276 | screen -S efb -X quit >>/dev/null 2>&1 277 | rm -rf /root/.ehforwarderbot/profiles/default/screenlog.0 278 | } 279 | 280 | systemctl_reload() { 281 | echo "正在写入系统进程守护 . . ." 282 | echo "[Unit] 283 | Description=ehforwarderbot 284 | After=network.target 285 | [Install] 286 | WantedBy=multi-user.target 287 | [Service] 288 | Type=simple 289 | WorkingDirectory=/root 290 | ExecStart=/usr/local/bin/ehforwarderbot 291 | Restart=always 292 | " >/etc/systemd/system/efb.service 293 | chmod 755 efb.service >>/dev/null 2>&1 294 | systemctl daemon-reload >>/dev/null 2>&1 295 | systemctl start efb >>/dev/null 2>&1 296 | systemctl enable efb >>/dev/null 2>&1 297 | } 298 | 299 | start_installation() { 300 | if [ "$release" = "centos" ]; then 301 | echo "系统检测通过。" 302 | welcome 303 | yum_update 304 | yum_git_check 305 | yum_python_check 306 | yum_screen_check 307 | yum_require_install 308 | download_repo 309 | pypi_install 310 | configure 311 | login_screen 312 | systemctl_reload 313 | echo "efb 已经安装完毕 在telegram 中 和bot对话 开始使用" 314 | elif [ "$release" = "ubuntu" ]; then 315 | echo "系统检测通过。" 316 | welcome 317 | apt_update 318 | apt_git_check 319 | apt_python_check 320 | apt_screen_check 321 | apt_require_install 322 | download_repo 323 | pypi_install 324 | configure 325 | login_screen 326 | systemctl_reload 327 | echo "efb 已经安装完毕 在telegram 中 和bot对话 开始使用" 328 | elif [ "$release" = "debian" ]; then 329 | echo "系统检测通过。" 330 | welcome 331 | apt_update 332 | apt_git_check 333 | debian_python_check 334 | apt_screen_check 335 | debian_require_install 336 | download_repo 337 | pypi_install 338 | configure 339 | login_screen 340 | systemctl_reload 341 | echo "efb 已经安装完毕 在telegram 中 和bot对话 开始使用" 342 | else 343 | echo "目前暂时不支持此系统。" 344 | fi 345 | exit 1 346 | } 347 | 348 | cleanup() { 349 | if [ ! -x "/root/.ehforwarderbot/profiles" ]; then 350 | echo "目录不存在不需要卸载。" 351 | else 352 | echo "正在关闭 efb" 353 | systemctl disable efb >>/dev/null 2>&1 354 | systemctl stop efb >>/dev/null 2>&1 355 | echo "正在卸载efb" 356 | pip3 uninstall -y -r ~/.ehforwarderbot/profiles/defaultrequirements.txt 357 | echo "正在删除 efb 文件 . . ." 358 | rm -rf /etc/systemd/system/efb.service >>/dev/null 2>&1 359 | rm -rf /root/.ehforwarderbot >>/dev/null 2>&1 360 | echo "卸载完成 . . ." 361 | fi 362 | } 363 | 364 | reinstall() { 365 | cleanup 366 | start_installation 367 | } 368 | 369 | cleansession() { 370 | if [ ! -x "/root/.ehforwarderbot/profiles" ]; then 371 | echo "目录不存在请重新安装 efb。" 372 | exit 1 373 | fi 374 | echo "正在关闭 efb . . ." 375 | systemctl stop efb >>/dev/null 2>&1 376 | echo "正在删除账户授权文件 . . ." 377 | echo "请进行重新登陆. . ." 378 | if [ "$release" = "centos" ]; then 379 | yum_python_check 380 | yum_screen_check 381 | elif [ "$release" = "ubuntu" ]; then 382 | apt_python_check 383 | apt_screen_check 384 | elif [ "$release" = "debian" ]; then 385 | debian_python_check 386 | apt_screen_check 387 | else 388 | echo "目前暂时不支持此系统。" 389 | fi 390 | login_screen 391 | systemctl start efb >>/dev/null 2>&1 392 | } 393 | 394 | stop_pager() { 395 | echo "" 396 | echo "正在关闭 efb . . ." 397 | systemctl stop efb >>/dev/null 2>&1 398 | echo "" 399 | sleep 3 400 | shon_online 401 | } 402 | 403 | start_pager() { 404 | echo "" 405 | echo "正在启动 efb . . ." 406 | systemctl start efb >>/dev/null 2>&1 407 | echo "" 408 | sleep 3 409 | shon_online 410 | } 411 | 412 | restart_pager() { 413 | echo "" 414 | echo "正在重新启动 efb . . ." 415 | systemctl restart efb >>/dev/null 2>&1 416 | echo "" 417 | sleep 3 418 | shon_online 419 | } 420 | 421 | install_require() { 422 | if [ "$release" = "centos" ]; then 423 | echo "系统检测通过。" 424 | yum_update 425 | yum_git_check 426 | yum_python_check 427 | yum_screen_check 428 | yum_require_install 429 | pypi_install 430 | systemctl_reload 431 | shon_online 432 | elif [ "$release" = "ubuntu" ]; then 433 | echo "系统检测通过。" 434 | apt_update 435 | apt_git_check 436 | apt_python_check 437 | apt_screen_check 438 | apt_require_install 439 | pypi_install 440 | systemctl_reload 441 | shon_online 442 | elif [ "$release" = "debian" ]; then 443 | echo "系统检测通过。" 444 | welcome 445 | apt_update 446 | apt_git_check 447 | debian_python_check 448 | apt_screen_check 449 | debian_require_install 450 | pypi_install 451 | systemctl_reload 452 | shon_online 453 | else 454 | echo "目前暂时不支持此系统。" 455 | fi 456 | exit 1 457 | } 458 | 459 | shon_online() { 460 | echo "请选择您需要进行的操作:" 461 | echo " 1) 安装 efb" 462 | echo " 2) 卸载 efb" 463 | echo " 3) 重新安装 efb" 464 | echo " 4) 重新登陆 efb" 465 | echo " 5) 关闭 efb" 466 | echo " 6) 启动 efb" 467 | echo " 7) 重新启动 efb" 468 | echo " 8) 重新安装 efb 依赖" 469 | echo " 9) 退出脚本" 470 | echo "" 471 | echo " Version:0.1" 472 | echo "" 473 | echo -n "请输入编号: " 474 | read N 475 | case $N in 476 | 1) start_installation ;; 477 | 2) cleanup ;; 478 | 3) reinstall ;; 479 | 4) cleansession ;; 480 | 5) stop_pager ;; 481 | 6) start_pager ;; 482 | 7) restart_pager ;; 483 | 8) install_require ;; 484 | 9) exit ;; 485 | *) echo "Wrong input!" ;; 486 | esac 487 | } 488 | 489 | check_sys 490 | shon_online 491 | --------------------------------------------------------------------------------