Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: I wrote an upgrade script for the hell of it...

  1. #1
    Join Date
    May 2005
    Location
    US
    Beans
    Hidden!
    Distro
    Ubuntu

    I wrote an upgrade script for the hell of it...

    Disclaimer: I am not a programmer. I know very little about shell scripts except that they're collections of terminal commands. Most of this code is stuff I stole/adapted from a script written by forum member Nanotube.

    If you see anything you want to improve, please post the improvement.

    Since most people who would know enough to do
    Code:
    chmod +x scriptname.sh
    ./scriptname.sh
    would know enough to upgrade themselves, I'm not sure how useful this script might be, but I just put it together to see if it was possible to do easily.

    Let me know what you think:
    Code:
    #/bin/bash
    
    ## Script written on 11 October, 2006 by aysiu
    ## Most of the syntax is adapted or just plain copied from code originally written by Nanotube for a Firefox installation script
    
    ## Make sure that we exit if any commands do not complete successfully.
    set -o errexit
    trap 'echo "Previous command did not complete successfully. Exiting."' ERR
    
    ## Introduction to script
    echo "This script will upgrade you to the next version of Ubuntu.
    
    If you're using Warty, it will upgrade you to Hoary.
    If you're using Hoary, it will upgrade you to Breezy.
    If you're using Breezy, it will upgrade you to Dapper.
    If you're using Dapper, it will upgrade you to Edgy.
    
    You should not upgrade more than one version at a time. If you want to upgrade from Breezy to Edgy, you're better off--in terms of time and stability--just installing Edgy from scratch.
    
    This script also assumes you have a broadband internet connection. If you have no internet connection or are on dial-up, please do not use this script."
    
    ## Confirmation of desire to proceed
    echo -e -n "
    
    Do you still wish to proceed [y/n]? "
    while true
    do
      read ans
      case $ans in
           Y|y) break ;;
      [Yy][Ee][Ss]) break ;;
           N|n) exit ;;
      [Nn][Oo]) exit ;;
             *) echo -n "Invalid command. Please answer yes or no [y/n] " ;;
      esac
    done
    
    ## Stop from running the script people who are already at the latest version.
    if grep -q "development" /etc/issue ; then
      echo "You're already using the development version. You cannot upgrade to a newer version."
      exit 1
    elif grep -q "6.10" /etc/issue ; then
      echo "At the time of this script's creation, Edgy was already the latest release of Ubuntu."
      exit 1
    fi
    
    ## Prompt for metapackage installation
    echo -e -n "
    
    In order to have a more likely success in upgrading, we're going to have to install the appropriate metapackages for your desktop environments. This may involve the installation of additional software." 
    echo -e -n "
    
    Do you still wish to proceed? [y/n]? "
    while true
    do
      read ans
      case $ans in
           Y|y) break ;;
      [Yy][Ee][Ss]) break ;;
           N|n) exit ;;
      [Nn][Oo]) exit ;;
             *) echo -n "Invalid command. Please answer yes or no [y/n] " ;;
      esac
    done
    
    ## Install metapackages
    if [ -f /usr/share/xsessions/gnome.desktop ]; then
      echo -e "
    
    Since you have Gnome installed, we're going to make sure ubuntu-desktop is also installed"
      sudo aptitude update && sudo aptitude install ubuntu-desktop
    fi
    if [ -f /usr/share/xsessions/kde.desktop ]; then
      echo -e "
    
    Since you have KDE installed, we're going to make sure kubuntu-desktop is also installed"
      sudo aptitude update && sudo aptitude install kubuntu-desktop
    fi
    if [ -f /usr/share/xsessions/xfce.desktop ]; then
      echo -e "
    
    Since you have XFCE installed, we're going to make sure xubuntu-desktop is also installed"
      sudo aptitude update && sudo aptitude install xubuntu-desktop
    fi
    
    ## Back up sources.list
    echo '
    
    Backing up old sources.list file'
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.old
    
    ## Revise sources.list
    echo '
    
    Replacing with new sources.list for upgrade'
    if grep -q "4.10" /etc/issue ; then
      sed 's/warty/hoary/g' /etc/apt/sources.list > ~/temp.list && sudo mv ~/temp.list /etc/apt/sources.list
    elif grep -q "5.04" /etc/issue ; then
      sed 's/hoary/breezy/g' /etc/apt/sources.list > ~/temp.list && sudo mv ~/temp.list /etc/apt/sources.list
    elif grep -q "5.10" /etc/issue ; then
      sed 's/breezy/dapper/g' /etc/apt/sources.list > ~/temp.list && sudo mv ~/temp.list /etc/apt/sources.list
    elif grep -q "6.06" /etc/issue ; then
      sed 's/dapper/edgy/g' /etc/apt/sources.list > ~/temp.list && sudo mv ~/temp.list /etc/apt/sources.list
    else
      echo "
    
    Error: unable to determine what version of Ubuntu you currently have installed."
      exit 1
    fi
    
    ## Do the upgrade
    echo "
    
    We're going to start doing the actual upgrade. This could take hours, even on a broadband internet connection. Please be patient."
    sudo aptitude update && sudo aptitude dist-upgrade
    Even if you have nothing to contribute, please let me know if you think this sort of script is worth doing... or if people already know how to upgrade properly...
    Last edited by aysiu; October 12th, 2006 at 07:22 AM.

  2. #2
    Join Date
    Jun 2006
    Location
    CT - MA - NY, U.S.
    Beans
    1,619

    Re: I wrote an upgrade script for the hell of it...

    I think it is definitely worth doing, especially if you get it to evolve into a little tiny program, that could eventually be used by anyone. this goes even beyond holding new user's hands. this is like putting them in a crib surrounded by food and love.

    on the other hand, it wouldn't kill people to know how to just type "sudo aptitude update && sudo aptitude dist-upgrade", it's really not that hard. So i guess i have mixed feelings about it

    edit: actually, i guess they would have to replace their sources.list file too. So it's probably good to automate that for them...

  3. #3
    Join Date
    Aug 2005
    Beans
    6,025

    Re: I wrote an upgrade script for the hell of it...

    Quote Originally Posted by aysiu View Post
    Even if you have nothing to contribute, please let me know if you think this sort of script is worth doing... or if people already know how to upgrade properly...
    Maybe just warn people with bandwidth caps that it might be a better option to download the latest ISO than upgrading all the way from warty to edgy as it will eat considerable bandwidth and take time.

  4. #4
    Join Date
    Apr 2006
    Beans
    149

    Re: I wrote an upgrade script for the hell of it...

    Given the various problems reported from past upgrades of all sorts, you'll want to put some major caveats on this if you're going to recommend it (or something like it) to newbies.

    I find myself in something of a dilemma over this type of script. I started using Ubuntu (and linux) about 6 months ago and mostly tried to avoid using scripts. Instead, I read the wiki and forum information and learned much more. However, I realise that not everyone wants to do it this way.

    It is good to lend a hand to new users but hiding everything in scripts and GUIs removes the opportunity to learn. I've found that the most valuable part of writing this sort of script was what I learned during the writing.


    Keith

  5. #5
    Join Date
    May 2005
    Location
    US
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: I wrote an upgrade script for the hell of it...

    Quote Originally Posted by maniacmusician View Post
    on the other hand, it wouldn't kill people to know how to just type "sudo aptitude update && sudo aptitude dist-upgrade", it's really not that hard. So i guess i have mixed feelings about it

    edit: actually, i guess they would have to replace their sources.list file too. So it's probably good to automate that for them...
    It's a three-parter to do a proper upgrade:

    1. Make sure you have the proper metapackage installed (xubuntu-desktop, for example)

    2. Change your sources.list

    3. Do the upgrade

    So, it is simple... but it's also not.

    Quote Originally Posted by mips View Post
    Maybe just warn people with bandwidth caps that it might be a better option to download the latest ISO than upgrading all the way from warty to edgy as it will eat considerable bandwidth and take time.
    I did actually warn people... not about the bandwidth, but I did tell them not to try skip versions in upgrades (Breezy to Edgy, for example).

    Quote Originally Posted by keithweddell View Post
    Given the various problems reported from past upgrades of all sorts, you'll want to put some major caveats on this if you're going to recommend it (or something like it) to newbies.
    Good point.

    I find myself in something of a dilemma over this type of script. I started using Ubuntu (and linux) about 6 months ago and mostly tried to avoid using scripts. Instead, I read the wiki and forum information and learned much more. However, I realise that not everyone wants to do it this way.

    It is good to lend a hand to new users but hiding everything in scripts and GUIs removes the opportunity to learn. I've found that the most valuable part of writing this sort of script was what I learned during the writing.
    Well, to me, it's all about choice.

    If people want to learn stuff, I'm all for that. But if they want a simpler way... they should get that if it's available.

    By the way, is anyone willing to test this script? It doesn't have to be now... whenever you move to Edgy from Dapper.

    I did a sort of test on my test machine, and it seemed to work (I canceled out before the actual dist-upgrade).

  6. #6
    Join Date
    Aug 2005
    Beans
    Hidden!

    Re: I wrote an upgrade script for the hell of it...

    aysiu I will test it,and post back findings errors should there be any.
    Advantages and Disadvantages of 64bit.(Plus install Guides)

    ‘In search of some small measure of peace, that we all seek, and few of us ever find.’

  7. #7
    Join Date
    Aug 2006
    Beans
    71

    Re: I wrote an upgrade script for the hell of it...

    Well, I wouldn't recommend this kind of script to anyone. I upgraded
    by changing my sources and it certainly required some manual attention.
    I think that people that do not know to do this operation on their
    own,are very likely to not know how to deal with potential problems.

    And I think it should be better completely replacing sources.list with a
    new one since it is likely that many people would have added custom
    repositories, many of which might not yet have an edgy pool.

  8. #8
    Join Date
    May 2005
    Location
    US
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: I wrote an upgrade script for the hell of it...

    That's what I figured.

    An upgrade is a major change.

    Anyone who needs a script will likely run into problems, blame the script, and then not know how to fix it.

    Still, it may be useful to a handful of people (a very, very small handful).

  9. #9
    Join Date
    Oct 2004
    Location
    Cupertino, CA
    Beans
    5,092
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: I wrote an upgrade script for the hell of it...

    Ayisu, I don't really mean to be critical or anything, but have you seen dist-upgrader? (aka the update-manager -c -d thing)

    It's already a very reliable upgrader for Ubuntu, implemented as a GNOME GUI. A console frontend is in the discussion, for server usage, etc.

    I think this kind of upgrader work needs to be consolidated into one, and so far the best solution I've used is dist-upgrader / update-manger.
    Quote Originally Posted by tuxradar
    Linux's audio architecture is more like the layers of the Earth's crust than the network model, with lower levels occasionally erupting on to the surface, causing confusion and distress, and upper layers moving to displace the underlying technology that was originally hidden

  10. #10
    Join Date
    May 2005
    Location
    US
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: I wrote an upgrade script for the hell of it...

    Quote Originally Posted by jdong View Post
    Ayisu, I don't really mean to be critical or anything, but have you seen dist-upgrader? (aka the update-manager -c -d thing)

    It's already a very reliable upgrader for Ubuntu, implemented as a GNOME GUI. A console frontend is in the discussion, for server usage, etc.

    I think this kind of upgrader work needs to be consolidated into one, and so far the best solution I've used is dist-upgrader / update-manger.
    At the time when Dapper came out, I saw numerous complaints about the updater application to go from Breezy to Dapper.

    If that's been refined for the Dapper to Edgy transition, then that would make my script totally useless, of course, except for those wanting to upgrade from Warty to Hoary, Hoary to Breezy, or Breezy to Dapper.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •