Script to force MIRROR and improve download speed! :)
Tofloor
poster avatar
m***o@gmail.com
deepin
2017-05-10 03:48
Author
Hi,
I'm not a Dev and I'm not a programmer, but I see that changing mirror in the Control Center is not good as change mirror in Source.List.

So, I decided to write an easy script to allow users to select the nearest mirror for their location.
This script is great for worldwide users, not chinese ones (because chinese mirror works great for chinese mainland).



Here the compressed file, just unzip and run in terminal:
Deepin_force_local_mirror.sh.zip

Have a nice day!
Reply Favorite View the author
All Replies
1 / 2
To page
Blogghete
deepin
2017-05-10 06:37
#1
Edited by Blogghete at 2017-5-9 17:32

Grazie, finalmente ora dovrei riuscire ad aumentare la velocità di download degli aggiornamenti.
Lo provo.

UPDATEerfetto, funziona alla grande.
Prima scaricava a 36Kb/s con proxy attivo.
Ora viaggia sui 15.000Kb/s con proxy attivo.
Sei davvero un grande!
Grazie!
Reply View the author
m***o@gmail.com
deepin
2017-05-10 08:42
#2
Blogghete replied at 2017-5-9 15:37
Grazie, finalmente ora dovrei riuscire ad aumentare la velocità di download degli aggiornamenti.
Lo ...

Grande!
Ottima notizia.
It is really important to fix mirror because Deepin does not change it via Control Center.
Reply View the author
Blogghete
deepin
2017-05-10 08:45
#3
https://bbs.deepin.org/post/139198
Grande!
Ottima notizia.
It is really important to fix mirror because Deepin does not change it via ...

Già.
Sei stato più efficace dei programmatori di deepin. Complimenti!
Reply View the author
m***o@gmail.com
deepin
2017-05-10 12:03
#4
Guys any other feedback? Does it work for you? Do you have something to suggest?
Reply View the author
liujianfeng
deepin
2017-05-10 17:25
#5
What deepin does in the controll center is changing the file /etc/apt/apt.conf.d/99mirrors.conf, first apt download InRelease from packages.deepin.com, then check if data from the mirror is the same, if so, apt will download the rest data from mirror, if not, download data from packages.deepin.com.
If mirror have the right datda, you only need to download InRelease from packages.deepin.com.
Reply View the author
laoguang
deepin
2017-05-10 18:46
#6
really, I just sudo gedit or vim the .list.
Reply View the author
m***o@gmail.com
deepin
2017-05-11 01:51
#7
laoguang replied at 2017-5-10 03:46
really, I just sudo gedit or vim the .list.

Many users are not able to do it, so I made this simple Script!
Reply View the author
m***o@gmail.com
deepin
2017-05-11 01:53
#8
Edited by Maxximo88 at 2017-5-10 11:36
liujianfeng replied at 2017-5-10 02:25
What deepin does in the controll center is changing the file /etc/apt/apt.conf.d/99mirrors.conf, fir ...


But Deepin continue to download upgrates and software (Deepin store) from Chinese servers (I saw..), and download speed is really low..
Reply View the author
rajubdctg
deepin
2017-05-15 05:43
#9
Is there is any option for Bangladesh (GMT + 06:00)
Reply View the author
invaderjiks
deepin
2017-05-15 06:56
#10
I need re install the deepin-desktop more the mirror not help.
Reply View the author
laoguang
deepin
2017-05-16 19:56
#11
https://bbs.deepin.org/post/139198
Many users are not able to do it, so I made this simple Script!

that is very nice of you!
Reply View the author
snyh1010
deepin
2017-05-16 22:11
#12
Edited by snyh1010 at 2017-5-16 14:18
https://bbs.deepin.org/post/139198
But Deepin continue to download upgrates and software (Deepin store) from Chinese servers (I saw.. ...

It will download from packages.deepin.com if and only if the right deb file can't find from the mirror server.    You can see more debug information by enable
  1. Acquire::SmartMirrors::Debug
Copy the Code
in /etc/apt/apt.conf.d/99lastore.conf

There has a bug in lastore-daemon < 0.9.42 cause slow download speed (Fixed in 15.4).   

Wish you can test it again using apt-get install  -o Acquire::SmartMirrors:ebug=true  foobar   and without change the source.list

We implement this mirror logcial by using new apt feature like by-hash .
It will only download the InRelease file which is smaller than 20Kb from packages.deepin.com all other files should go through the mirror server which is same like change the source.list file directly.     If it's not then there must a bug in there.
Reply View the author
m***o@gmail.com
deepin
2017-05-17 22:48
#13
snyh1010 replied at 2017-5-16 07:11
It will download from packages.deepin.com if and only if the right deb file can't find from the mir ...

I think You cannot detect any issue because you use it in China Mainland bro..
Really, try to live outside China Great Firewall, Deepin has huge issue in downloading system upgrades and apps..
Reply View the author
m***o@gmail.com
deepin
2017-05-17 22:49
#14
rajubdctg replied at 2017-5-14 14:43
Is there is any option for Bangladesh (GMT + 06:00)

Choose a mirror near you, every mirror is better than original Chiense one for us..
Reply View the author
dimador
deepin
2017-05-18 00:25
#15
Thank you SOOOO much! It's so easy to use and works just great for me!
Reply View the author
m***o@gmail.com
deepin
2017-05-18 22:27
#16
dimador replied at 2017-5-17 09:25
Thank you SOOOO much! It's so easy to use and works just great for me!

Thx Man!
That's why I decided to create this script, in order to allow users to really have fun with Deepin!
Reply View the author
Comments
Blogghete
2017-05-19 00:31
I think that this thread should be locked in the top of the Newbie section of this Forum to help worldwide users to improve the download speed.
th3blad3runn3r
deepin
2017-05-19 11:41
#17
Edited by th3blad3runn3r at 2017-5-18 20:47

As already mentioned, try this, whatever your location is :

edit /etc/apt/sources.list
and change
  1. http://packages.deepin.com/deepin
Copy the Code
by
  1. http://www.mirrorservice.org/sites/packages.linuxdeepin.com/deepin
Copy the Code
so your sources.list file looks like
  1. ## Generated by deepin-installer
  2. #deb [by-hash=force] http://packages.deepin.com/deepin panda main contrib non-free
  3. #deb-src http://packages.deepin.com/deepin panda main contrib non-free
  4. deb http://www.mirrorservice.org/sites/packages.linuxdeepin.com/deepin panda main contrib non-free
Copy the Code
run
  1. apt-get update && apt-get upgrade
Copy the Code

You'll notice  HUGE improvments...

Reply View the author
m***o@gmail.com
deepin
2017-05-19 22:37
#18
th3blad3runn3r replied at 2017-5-18 20:41
As already mentioned, try this, whatever your location is :

edit /etc/apt/sources.list

Did you tried my script before posting in this topic?Mmm
Reply View the author
th3blad3runn3r
deepin
2017-05-21 02:00
#19
Edited by th3blad3runn3r at 2017-5-21 11:35

@maxximo: I did not try your script, but opened it to see by my self.
My post is an 'always working' alternative for this issue, as long as mirrorservice.org is functionning.

Your script is surely useful, but same could be done in less code.
PLEASE take no offense, this isn't a troll post. I'd be glad to help you improve it
Reply View the author
th3blad3runn3r
deepin
2017-05-21 02:00
#20
Edited by th3blad3runn3r at 2017-5-21 19:36

Here's my proposal for an (easier to maintain) alternative script.

Please note that only a few mirrors have been integrated due to an extreme lazyness
Feel free to enhance it, by adding relevant lines in the aMirrorsList array (starting line 60)
  1. #!/bin/bash
  2. #
  3. # Purpose  : Adapt your sources.list file to the most accurate mirror server
  4. # Versions : 0.3: Fixed typos and set exit on error conditions or undeclared vcaiables
  5. #            0.2: refactoring -> Th3Blad3Runn3r
  6. #            0.1: Original concept & Idea; Maxximo88

  7. # Pre-requisites
  8. set -o errexit
  9. set -o nounset

  10. # Uncomment the following line to see the magic happens :p
  11. #set -o xtrace

  12. # Display choices
  13. displayMenu () {
  14.    echo "Ciao!"
  15.    echo ""
  16.    echo "This script allow international Deepin users to modify the 'sources.list' file and get full download speed by using a nearest mirror"
  17.    echo "Please select a Country/Region :"
  18.    echo ""

  19.    # Display available choices
  20.    iIndex=0;
  21.    for sMirrorTuple in "${aMirrorsList[@]}"; do
  22.         # Compute an index and display it as a string (0 leading, 2 char padding)
  23.         iIndex=$((${iIndex} + 1))
  24.         sIndex=$(printf "%02d" ${iIndex})
  25.         echo [${sIndex}]" - "${sMirrorTuple}
  26.    done
  27. }

  28. # Upgrade the /etc/apt/sources.list file
  29. updateSourceList () {
  30.     # Get distro codename
  31.     sCodeName=$(lsb_release -sc)

  32.     # Preparing rolling backup
  33.     sSourceFileName=/etc/apt/sources.list
  34.     sTimeStamp=$(date +%Y%m%d%H%M%S)

  35.     # Backup current sources.list
  36.     cp ${sSourceFileName} ${sSourceFileName}-${sTimeStamp}

  37.     # Replace sources.list
  38.     echo "Upgrading /etc/apt/sources.list with mirror" $2
  39.     echo ""

  40.     echo "## Generated by Deepin-installer / updated by "$0" for region "$1 > "${sSourceFileName}"
  41.     echo "deb [by-hash=force] http://"$2" "${sCodeName}" main contrib non-free" >> "${sSourceFileName}"
  42. }

  43. # Main
  44. if [ "$EUID" -ne 0 ]; then
  45.     # Privilege warning
  46.     echo "Please run this script as root (use sudo)"
  47. else
  48.     # Declare main array (Please, pay attention when editing this array, to not introduce typos)
  49.     aMirrorsList=(
  50.         'Original Mirror (Deepin)=packages.deepin.com/deepin'
  51.         'Universal mirror (Mirror Service)=www.mirrorservice.org/sites/packages.linuxdeepin.com/deepin'
  52.         'Italy=ba.mirror.garr.it/mirrors/deepin'
  53.         'Poland=piotrkosoft.net/pub/mirrors/deepin'
  54.         'Turkey=mirror.veriteknik.net.tr/deepin'
  55.         'Brazil=sft.if.usp.br/deepin'
  56.         'Canada=deepin.mirror.globo.tech'
  57.         'Germany=ftp.fau.de/deepin'
  58.         'Greece=ftp.cc.uoc.gr/mirrors/linux/deepin/packages'
  59.         'Russia=mirror.yandex.ru/mirrors/deepin/packages'
  60.         'Singapore=mirror.0x.sg/deepin'
  61.         'Sweden=ftp.acc.umu.se/mirror/linuxdeepin/package'
  62.         'United States of America=mirror.jmu.edu/pub/deepin'
  63.     )

  64.     # Get max index of the MirrorsList array
  65.     iMaxIndexValue=${#aMirrorsList[@]}

  66.     # Display Menu
  67.     clear
  68.     displayMenu

  69.     # Wait for choice
  70.     iChoice=0
  71.     while [ ${iChoice} -lt 1 ] || [ ${iChoice} -gt ${iMaxIndexValue} ]; do
  72.         echo ""
  73.         echo -e "Enter the numerical value corresponding to your choice (or ctrl+c to quit): \c"
  74.         read; iChoice=$REPLY
  75.     done

  76.     # Knowing that arrays are zero based, we substract 1 from the previous answer to access the right tuple
  77.     iChoice=$((${iChoice} - 1))

  78.     # Get tuple (Region/Mirror) based upon previous selection
  79.     sMirrorTuple=${aMirrorsList[${iChoice}]}

  80.     # Extract atomic values from the tuple (left and right part of the '=' sign)
  81.     sRegionName=$(echo ${sMirrorTuple}|cut -d'=' -f1)
  82.     sMirrorName=$(echo ${sMirrorTuple}|cut -d'=' -f2)

  83.     # Upgrade sources.list
  84.     updateSourceList "${sRegionName}" "${sMirrorName}"
  85.     apt-get update

  86.     # Done
  87.     echo "Done !"
  88. fi
Copy the Code




Reply View the author
1 / 2
To page