Results 1 to 6 of 6

Thread: Trying to write a little script to install all my software

  1. #1
    Join Date
    Dec 2010
    Beans
    48

    Question Trying to write a little script to install all my software

    Hey, so my computer sucks, and little things go wrong so I end up reformatting it all the time. I'm also of a little fickle so I end up installing different OS's on my laptop (all ubuntu o
    r linux mint), and it gets kind of annoying having to go and find ppa's and install everything one by one, so I'm trying to make a little script or executable text document and was hoping to get some help writing it. Here's what I have so far:

    PHP Code:
    sudo add-apt-repository ppa:kevin-mehall/pithos-daily && sudo add-apt-repository ppa:videolan/stable-daily && sudo add-apt-repository ppa:webupd8team/y-ppa-manager && sudo add-apt-repository ppa:skype-wrapper/ppa && sudo add-apt-repository ppa:transmissionbt/ppa && sudo add-apt-repository ppa:pidgin-developers/ppa && sudo add-apt-repository ppa:libreoffice/ppa && sudo apt-get update && sudo apt-get install pithos vlc y-ppa-manager skype-wrapper transmission pidgin libreoffice gnome-do && sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove && sudo apt-get autoclean 
    I was also wondering how I would fit the insallation of Spotify for Linux in. Here's the instuctions from their website:

    Debian
    # 1. Add this line to your list of repositories by editing your /etc/apt/sources.list deb http://repository.spotify.com stable non-free
    # 2. If you want to verify the downloaded packages, you will need to add our public key sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 94558F59
    # 3. Run apt-get update sudo apt-get update
    # 4. Install spotify! sudo apt-get install spotify-client


    How would I go about setting all this up so I can just click on a file and have it open a terminal and start running and installing everything?

  2. #2
    Join Date
    Nov 2008
    Beans
    Hidden!

    Re: Trying to write a little script to install all my software

    I would think that one of the standard backup methods would work as long as it appears in software sources list.

    http://www.googlubuntu.com/results/?...Search&lang=en

    https://help.ubuntu.com/community/Re...y_Software_Tab

  3. #3
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: Trying to write a little script to install all my software

    I did something similar as I install to two computers and every 6 months with multiple installs of the next version.

    All I did was run the command from command line and then list history. Then copied history to bash file. Of course I had a lot of typos errors in my command line, but it let me test & verify which lines really worked.

    I wanted to find some checking and add some distribution based variables. You then can add whatever works.

    Code:
    #!/usr/bin/env bash -x
    # -x adds debugging mode set +x or set -x
    
    # Repositoires - Normally users have the first 4 enabled - main, universe, multiverse, restricted
    # Check if we are on Ubuntu
    if [ "$(lsb_release -is)" != "Ubuntu" ] ; then
        echo "This script is only intended to run on Ubuntu"
        exit 255
    fi
    
    # Check if we are root
    if [ $UID -ne 0 ] ; then
        echo "Please run this as root!"
        exit 255
    fi
    
    # Get distro
    distro=$(lsb_release -cs)
    
    src=/etc/apt/sources.list
    #save your original sources.list file.
    echo "Backing Up The sources.list"
    cp -i /etc/apt/sources.list /etc/apt/sources.list_backup
    #this updates everything
    apt-get update
    apt-get upgrade
    #would upgrade you to the latest kernel in the repositories
    apt-get dist-upgrade
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

  4. #4
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Trying to write a little script to install all my software

    spotify
    http://www.liberiangeek.net/2012/04/...ecise-pangolin
    simply copy-paste those lines into your script.

    Btw, if you don't want the script to fail in case of a single operation going wrong
    (missing repository or whatever) you should split that chain of commands glued together with &&

    Code:
    #!/bin/bash
    
    # Check if we are root
    if [ $UID -ne 0 ]
    then
        echo "Please run this as root!"
        exit 255
    fi
    
    # PPAs one by one
    add-apt-repository ppa:kevin-mehall/pithos-daily
    add-apt-repository ppa:videolan/stable-daily
    add-apt-repository ppa:webupd8team/y-ppa-manager
    add-apt-repository ppa:skype-wrapper/ppa
    add-apt-repository ppa:transmissionbt/ppa
    add-apt-repository ppa:pidgin-developers/ppa
    add-apt-repository ppa:libreoffice/ppa
    # spotify, avoid duplicates in sources.list
    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4E9CFF4E
    grep -q spotify /etc/apt/sources.list || sh -c 'echo "deb http://repository.spotify.com stable non-free" >> /etc/apt/sources.list'
    
    apt-get update && apt-get install pithos vlc y-ppa-manager skype-wrapper transmission pidgin libreoffice gnome-do spotify-client-qt
    
    apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove && sudo apt-get autoclean
    Last edited by Vaphell; October 30th, 2012 at 06:37 PM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  5. #5
    Join Date
    Dec 2010
    Beans
    48

    Re: Trying to write a little script to install all my software

    Awesome thank you for that, one last questions, how do I save it so I can click and run it?

    I tried saving it as a normal text document, then giving it permission to be an executable, but when i select "run in terminal" or just "run" noting happens.

  6. #6
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: Trying to write a little script to install all my software

    Better to use terminal, cd to folder with script, and run with sudo from that. Then if you get any messages you can see them.
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

Tags for this Thread

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
  •