I think this may be a fabulous idea but it needs testing. Why isn't this default upstream? I don't know.

Running the line you suggested would have to be run as a script very early in the boot process that would add several seconds to boot time. The way more native to apt and simple way to do it seems to be this. I tested it and it works.

I'll not go into too many details right now but after thinking through this over the past days and running multiple different tests, I don't think there is any good way to do anything like this by default--which, probably, is why no distro has this by default.

The option with the least drawbacks and highest possible return for users is to incorporate an apt mirror speed test in the ubiquity installer; but, the cons even to that seem to outweigh the pros, e.g., if I install in California and move to Florida, I've probably achieved a persistent negative in terms of speed.

In the case of doing a speed test at some other point, what the fastest mirror is still changes due to many factors, even day to day and sometimes hour to hour. In the case of doing a test for only the geographically nearest mirror, there isn't necessarily any value in that, since the nearest mirror can actually be much slower than one further away.

Bottom line: I can't come up with a good way to do this that works well for everyone's scenarios. Accordingly, I think it's a good idea to leave this entirely in user control but create a small program that users can run at will, or by default in the background at startup, to detect the fastest mirror and place that mirror into their apt configs. It would only take several hours to write and I could do that and then make the program available in the repository, and include it by default in future releases.

How about we get the result of the command in the first post as part of UberStudentUpdate whenever, let's say, an update download is required larger than a specific threshold. Until that threshold is exceeded again, the updater can use that mirror.

Since uberstudentsources reconfigures the base source to be us.archive.ubuntu.com from time to time, now that I returned to Turkey from Florida for the summer, us.archive.ubuntu.com is killing me and this makes me wanna remove uberstudentsources completely. But instead of removing it, I thought, why not try to make it better

_________________Berker PeközPhD Student in Electrical EngineeringUniversity of South Florida at Tampa

Well, running the curl string you posted in the uberstudentsource postinst file would seem a good solution. In this way, one can simply reinstall that package to get the fastest mirror if/when they move.

# Inform the userechoecho "Determining the fastest software repository mirror for your location."echoecho "Please be patient. This may take a few minutes. Doing this now will"echo "save you time in the future."echo

# The printf bracket here is just for ascetic reasons.printf "["

# While the above curl process is running we here give a progress bar in# the terminal to inform the user about what is going on.while kill -0 $PID 2> /dev/null; do printf "▓" sleep 1done

# Most users don't have source files added to their apt configs, so we only# run this if they do. They are not enabled by default in UberStudent.if [ -f /etc/apt/sources.list.d/official-source-repositories.list ]; then FILE3=$(</etc/apt/sources.list.d/official-source-repositories.list) echo "${FILE3//marker/$FILE1}" > /tmp/aptmirror.test/source sleep 1 mv /tmp/aptmirror.test/source /etc/apt/sources.list.d/official-source-repositories.list sleep 1fi

# Required for every user case. We here place the list file we made# containing the fastest mirror and clean up the temp file(s) we made.mv /tmp/aptmirror.test/package /etc/apt/sources.list.d/official-package-repositories.listsleep 1rm -rf /tmp/aptmirror.testsleep 1

# Inform the userechoecho "Found the fastest mirror! It's been placed into your apt configurations."echoecho "If in the future you geographically move a long distance away from your"echo "current location, re-install this package and it will again find and set"echo "the fastest mirror for you!"echoecho "Using the program Software Sources, you can restore the default U.S.-based"echo "repository."echosleep 1

I've just now released a new version of uberstudentsources that incorporates the feature request asked for here. I tested the proposed package repeatedly on both upgraded installations and fresh ones and am confident.

The new version of uberstudentsources will also install a small new program/script, set-fastest-mirror, as a dependency. People can run it any time to get and set the fastest mirror into their apt configurations if they move.

Berker, you'll need to reinstall uberstudentsources to get some minor code improvements and the new dependency, set-fastest-mirror.

# If the find command *does not equal* (!=) empty, i.e., if it's not over 30 days old.# This should use less resources then the *if test* line, above.if [ "$(find /tmp/aptmirrortest/age -mtime +30)" != "" ]; then # Needed sleep to ensure network is up and all other start programs have started sleep 15 # Test if decently internet-connected, and if so, proceed, or else pass to line 135 "else" wget -q --tries=1 --timeout=15 http://uberstudent.net -O /tmp/test.idx &> /dev/null if [ -s /tmp/test.idx ]; then echo "Mirror is over 30 days old. Taking actions...."

# Run the mirror speed test string and write the result to a temp file we read from below. # This is the magic line that tests the mirror speeds and selects the fastest one, # which is from http://askubuntu.com/a/719551/274446

if [ -f /tmp/aptmirrortest/age ]; then rm /tmp/aptmirrortest/age echo "This file is needed by apt-mirror-test. Please leave it here." > /tmp/aptmirrortest/age fi fi else # If either /tmp/aptmirrortest/age is younger than 30 days old or there is no decent internet connection, # we pass the whole script to do nothing, the ":". Comment in echo and comment out : for CLI testing. : # echo "Mirror is younger than 30 days old, so doing nothing." fi

The script apt-mirror-check is set in /etc/sudoers.d/ to run without root requirements, something neccesary in this case.

What do you think about these additions? It works without flaw on my system, but I worry that this might be too intrusive.

I find it perfectly useful for those who want it, but doing this periodically might be unwanted for some. I vote we add this as another package that is recommended by the set-fastest-mirror, like set-fastest-mirror-periodically, but not a dependency to the original package I'm trying it out on my Socrates upgraded laptop when I go home

_________________Berker PeközPhD Student in Electrical EngineeringUniversity of South Florida at Tampa

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum