从根本上解决unraid从github之类网站下载包经常失败问题


Recommended Posts

首先大概描述下问题所在:

  1. github等网站经常被墙导致无法访问
  2. 就算能连上也经常无法下载或者速度特别慢

然后说下大概解决思路:

  1. 使用国内github镜像网站替换掉原始地址
  2. 发现很多网站https不能下载,http反而速度还可以,那就用把下载地址的https替换为http。
  3. unraid下载大多数时候使用的是wget命令,所以在wget里面完成以上操作即可

最后说下我的具体步骤,仅供参考:

  1. 因为/usr/local/bin优先级高于/usr/bin,所以我在/usr/local/bin中写了个同名wget脚本,内容如下,主要作用就是将调用wget的参数做替换,然后再传给真正的wget:
#!/bin/bash
opts=$@
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}
  1. 这个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/ \;

 

然后你就发现系统中的所有下载好用了,尤其更新系统安装插件。

同样思路可以做很多事。

  • Like 5
  • Upvote 1
Link to comment
  • 4 weeks later...

还有一种方法在自定义脚本中每次开机执行

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相关网站

  • Like 4
  • Thanks 1
Link to comment
  • 4 months later...
  • 1 month later...
  • 2 weeks later...

大佬,我用了这个方法,然后重启了unraid,发现用which wget时,显示的仍然是/usr/bin/下的wget,这可能是什么原因?难道是因为我使用了oh-my-zsh的原因吗?我的go完整内容为:

root@Tower:~# 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 by tingyu
Link to comment
  • 1 month later...
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楼的更改更方便,对系统的修改更小。特地申请帐号回复

Link to comment
  • 1 month later...

思路不错,感谢楼主的分享

 

直接把脚本写到 local/bin 目录相对更简单些

 

tee /usr/local/bin/wget <<-'EOF'
#!/bin/bash
opts=$@
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

 

Link to comment
  • 2 months later...
  • 2 weeks later...
  • 2 months later...
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相关网站

我直接在mikrotik路由器里更改DNS了,感谢大佬

Link to comment
  • 4 months later...
  • 5 weeks later...
On 1/11/2022 at 6:38 PM, sunzhigang said:

首先大概描述下问题所在:

  1. github等网站经常被墙导致无法访问
  2. 就算能连上也经常无法下载或者速度特别慢

然后说下大概解决思路:

  1. 使用国内github镜像网站替换掉原始地址
  2. 发现很多网站https不能下载,http反而速度还可以,那就用把下载地址的https替换为http。
  3. unraid下载大多数时候使用的是wget命令,所以在wget里面完成以上操作即可

最后说下我的具体步骤,仅供参考:

  1. 因为/usr/local/bin优先级高于/usr/bin,所以我在/usr/local/bin中写了个同名wget脚本,内容如下,主要作用就是将调用wget的参数做替换,然后再传给真正的wget:
#!/bin/bash
opts=$@
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}
  1. 这个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/ \;

 

然后你就发现系统中的所有下载好用了,尤其更新系统安装插件。

同样思路可以做很多事。

牛的,解决了商店打不开的问题。没想到后台其实是用的wget

Link to comment
  • 6 months later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.