sunzhigang Posted January 11, 2022 Share Posted January 11, 2022 首先大概描述下问题所在: github等网站经常被墙导致无法访问 就算能连上也经常无法下载或者速度特别慢 然后说下大概解决思路: 使用国内github镜像网站替换掉原始地址 发现很多网站https不能下载,http反而速度还可以,那就用把下载地址的https替换为http。 unraid下载大多数时候使用的是wget命令,所以在wget里面完成以上操作即可 最后说下我的具体步骤,仅供参考: 因为/usr/local/bin优先级高于/usr/bin,所以我在/usr/local/bin中写了个同名wget脚本,内容如下,主要作用就是将调用wget的参数做替换,然后再传给真正的wget: #!/bin/bash opts=[email protected] opts=`echo $opts | sed -e 's;raw.githubusercontent.com;raw.staticdn.net;g' -e 's;https://raw.github.com/;https://raw.staticdn.net/;g' -e 's;https://github.com/;https://github.com.cnpmjs.org/;g' -e 's;https://;http://;g' ` /usr/bin/wget ${opts} 这个wget脚本我实际存储在/mnt/user/system/bin/wget,在/boot/config/go中链接到/usr/local/bin中,命令如下: find /mnt/user/system/bin -type f ! -name ".*~" -exec ln -sf {} /usr/local/bin/ \; 然后你就发现系统中的所有下载好用了,尤其更新系统安装插件。 同样思路可以做很多事。 5 Quote Link to comment
Xie1000 Posted February 8, 2022 Share Posted February 8, 2022 (edited) 可以给萌新出个详细的操作方法吗,不能顺利的从github上下载软件太让新人痛苦了 Edited February 8, 2022 by Xie1000 Quote Link to comment
lyqalex Posted February 9, 2022 Share Posted February 9, 2022 现在能做最好的方法是梯子,墙把外面隔绝了,以上的方法并不能根本解决问题,只能是偶尔透过缝看月光而已。 Quote Link to comment
foxjojo Posted February 9, 2022 Share Posted February 9, 2022 还有一种方法在自定义脚本中每次开机执行 wget -qO - https://raw.hellogithub.com/hosts | cat - >> /etc/hosts 会将hosts替换为以下 # Generated 127.0.0.1 54.149.176.35 keys.lime-technology.com # GitHub520 Host Start 140.82.113.25 alive.github.com 140.82.114.26 live.github.com 185.199.108.154 github.githubassets.com 140.82.112.22 central.github.com 185.199.108.133 desktop.githubusercontent.com 185.199.108.153 assets-cdn.github.com 185.199.108.133 camo.githubusercontent.com 185.199.108.133 github.map.fastly.net 199.232.69.194 github.global.ssl.fastly.net 140.82.113.4 gist.github.com 185.199.108.153 github.io 140.82.113.4 github.com 192.0.66.2 github.blog 140.82.112.5 api.github.com 185.199.108.133 raw.githubusercontent.com 185.199.108.133 user-images.githubusercontent.com 185.199.108.133 favicons.githubusercontent.com 185.199.108.133 avatars5.githubusercontent.com 185.199.108.133 avatars4.githubusercontent.com 185.199.108.133 avatars3.githubusercontent.com 185.199.108.133 avatars2.githubusercontent.com 185.199.108.133 avatars1.githubusercontent.com 185.199.108.133 avatars0.githubusercontent.com 185.199.108.133 avatars.githubusercontent.com 140.82.114.9 codeload.github.com 52.217.70.196 github-cloud.s3.amazonaws.com 52.216.139.27 github-com.s3.amazonaws.com 54.231.201.121 github-production-release-asset-2e65be.s3.amazonaws.com 52.217.160.249 github-production-user-asset-6210df.s3.amazonaws.com 52.217.160.249 github-production-repository-file-5c1aeb.s3.amazonaws.com 185.199.108.153 githubstatus.com 64.71.144.202 github.community 23.100.27.125 github.dev 185.199.108.133 media.githubusercontent.com 185.199.108.133 cloud.githubusercontent.com 185.199.108.133 objects.githubusercontent.com # Update time: 2022-02-09T20:06:23+08:00 # Update url: https://raw.hellogithub.com/hosts # Star me: https://github.com/521xueweihan/GitHub520 # GitHub520 Host End 这样也能正常访问github相关网站 4 1 Quote Link to comment
wongdi Posted July 21, 2022 Share Posted July 21, 2022 你这思路还可以向/dev/net中添加其他设备驱动 666,能给解释下那条go中的命令吗,我看看有没有其他发挥余地😂 Quote Link to comment
sunzhigang Posted August 4, 2022 Author Share Posted August 4, 2022 其实主要思路是/usr/local/bin优先级大于/usr/bin/,自己可以自定义一些同名命令放在/usr/loca/bin/下面,这样系统调研就都会调用你的命令。 /usr/local/bin/下面命令可以是对参数解析更改后传给/usr/bin下的原始命令 Quote Link to comment
sunzhigang Posted August 4, 2022 Author Share Posted August 4, 2022 On 7/21/2022 at 11:23 PM, wongdi said: 你这思路还可以向/dev/net中添加其他设备驱动 666,能给解释下那条go中的命令吗,我看看有没有其他发挥余地😂 go那条命令就是把自定义的命令链接到/usr/local/bin下面 Quote Link to comment
tingyu Posted August 8, 2022 Share Posted August 8, 2022 (edited) 大佬,我用了这个方法,然后重启了unraid,发现用which wget时,显示的仍然是/usr/bin/下的wget,这可能是什么原因?难道是因为我使用了oh-my-zsh的原因吗?我的go完整内容为: [email protected]:~# cat /boot/config/go #!/bin/bash # Start the Management Utility /usr/local/sbin/emhttp & /bin/sh /boot/config/custom-init.sh #docker # prepare folder mkdir -p /etc/docker # update mirror tee /etc/docker/daemon.json << EOF { "registry-mirrors": [ "https://*********.mirror.aliyuncs.com" ] } EOF # https://obsolete.blog/2021/07/10/persistent-zsh-oh-my-zsh-on-unraid/ # give me oh-my-zsh tar xjf /boot/root/zsh.tar.bz2 -C /root/ ln -s /root/.bash_profile /root/.bashrc # and update it! cp /boot/root/omz-update.sh /root/ && chmod +x /root/omz-update.sh && /root/omz-update.sh # begin https://forums.unraid.net/topic/124014-i-need-config-a-proxy/?do=findComment&comment=1130948 http_proxy=http://192.168.50.107:7893 https_proxy=http://192.168.50.107:7893 echo "export http_proxy=\"http://192.168.50.107:7893\"" >> /root/.zshrc echo "export https_proxy=\"http://192.168.50.107:7893\"" >> /root/.zshrc # end # github access issue solove under gfw https://forums.unraid.net/topic/118444-%E4%BB%8E%E6%A0%B9%E6%9C%AC%E4%B8%8A%E8%A7%A3%E5%86%B3unraid%E4%BB%8Egithub%E4%B9%8B%E7%B1%BB%E7%BD%91%E7%AB%99%E4%B8%8B%E8%BD%BD%E5%8C%85%E7%BB%8F%E5%B8%B8%E5%A4%B1%E8%B4%A5%E9%97%AE%E9%A2%98/ find /mnt/user/system/bin -type f ! -name ".*~" -exec ln -sf {} /usr/local/bin/ \; 而且我发现/usr/local/bin下也没有建立软连接啊: $ ll /usr/local/bin total 16M -rwxr-xr-x 1 root root 2.9M Aug 3 07:14 docker-compose -rwxr-xr-x 1 root root 1.8M Mar 1 2015 plink -rwxr-xr-x 1 root root 1.8M Mar 1 2015 pscp -rwxr-xr-x 1 root root 1.8M Mar 1 2015 psftp -rwxr-xr-x 1 root root 1.7M Mar 1 2015 pterm -rwxr-xr-x 1 root root 2.9M Mar 1 2015 putty -rwxr-xr-x 1 root root 738K Mar 1 2015 puttygen -rwxr-xr-x 1 root root 1.9M Mar 1 2015 puttytel -rwxr-xr-x 1 root root 452 Aug 8 23:05 smartlocate drwxr-xr-x 3 root root 180 Aug 8 23:06 unraid-api # root @ Tower in ~ [23:06:53] $ ll /mnt/user/system/bin total 4.0K -rw-rw-rw- 1 root root 264 Jul 23 14:20 wget Edited August 8, 2022 by tingyu Quote Link to comment
xffish Posted September 20, 2022 Share Posted September 20, 2022 On 2/9/2022 at 10:31 PM, foxjojo said: 还有一种方法在自定义脚本中每次开机执行 wget -qO - https://raw.hellogithub.com/hosts | cat - >> /etc/hosts 会将hosts替换为以下 # Generated 127.0.0.1 54.149.176.35 keys.lime-technology.com # GitHub520 Host Start 140.82.113.25 alive.github.com 140.82.114.26 live.github.com 185.199.108.154 github.githubassets.com 140.82.112.22 central.github.com 185.199.108.133 desktop.githubusercontent.com 185.199.108.153 assets-cdn.github.com 185.199.108.133 camo.githubusercontent.com 185.199.108.133 github.map.fastly.net 199.232.69.194 github.global.ssl.fastly.net 140.82.113.4 gist.github.com 185.199.108.153 github.io 140.82.113.4 github.com 192.0.66.2 github.blog 140.82.112.5 api.github.com 185.199.108.133 raw.githubusercontent.com 185.199.108.133 user-images.githubusercontent.com 185.199.108.133 favicons.githubusercontent.com 185.199.108.133 avatars5.githubusercontent.com 185.199.108.133 avatars4.githubusercontent.com 185.199.108.133 avatars3.githubusercontent.com 185.199.108.133 avatars2.githubusercontent.com 185.199.108.133 avatars1.githubusercontent.com 185.199.108.133 avatars0.githubusercontent.com 185.199.108.133 avatars.githubusercontent.com 140.82.114.9 codeload.github.com 52.217.70.196 github-cloud.s3.amazonaws.com 52.216.139.27 github-com.s3.amazonaws.com 54.231.201.121 github-production-release-asset-2e65be.s3.amazonaws.com 52.217.160.249 github-production-user-asset-6210df.s3.amazonaws.com 52.217.160.249 github-production-repository-file-5c1aeb.s3.amazonaws.com 185.199.108.153 githubstatus.com 64.71.144.202 github.community 23.100.27.125 github.dev 185.199.108.133 media.githubusercontent.com 185.199.108.133 cloud.githubusercontent.com 185.199.108.133 objects.githubusercontent.com # Update time: 2022-02-09T20:06:23+08:00 # Update url: https://raw.hellogithub.com/hosts # Star me: https://github.com/521xueweihan/GitHub520 # GitHub520 Host End 这样也能正常访问github相关网站 厉害呀,只需要做这个dns设置就可以了,比别的方案包括楼主1楼的更改更方便,对系统的修改更小。特地申请帐号回复 Quote Link to comment
sunzhigang Posted September 20, 2022 Author Share Posted September 20, 2022 你单运行下这条命令看看 Quote Link to comment
fejich Posted October 28, 2022 Share Posted October 28, 2022 思路不错,感谢楼主的分享 直接把脚本写到 local/bin 目录相对更简单些 tee /usr/local/bin/wget <<-'EOF' #!/bin/bash [email protected] opts=`echo $opts | sed -e 's;raw.githubusercontent.com;raw.staticdn.net;g' -e 's;https://raw.github.com/;https://raw.staticdn.net/;g' -e 's;https://github.com/;https://github.com.cnpmjs.org/;g' -e 's;https://;http://;g' ` /usr/bin/wget ${opts} EOF chmod +x /usr/local/bin/wget Quote Link to comment
xyzeratul Posted October 28, 2022 Share Posted October 28, 2022 mark, 最近也是被这个弄得很烦 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.