Results 1 to 4 of 4

Thread: He me with this bash scripting?

  1. #1
    Join Date
    Aug 2009
    Location
    India
    Beans
    Hidden!
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    He me with this bash scripting?

    We run apt-cacher-ng server in our office for installing packages locally. However we are using different versions of ubuntu, and so the sources.list file varies for different distributions, all the source files were kept in the following location say ie.. http://172.29.39.100/ubuntu/............ and so on. What i need to do is first of all i need to find the ubuntu version using lsb_release -rs and then if the version is i.e 10.10 then the default sources.list should get replaced using wget from the following location,

    If 10.10 then,

    Code:
    wget http://172.29.39.100/ubuntu/1010/sources.list
    If 10.04 then,

    Code:
    wget http://172.29.39.100/ubuntu/1004/sources.list
    How can i automate this task in bash script? Can anyone help me?

  2. #2
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: He me with this bash scripting?

    If there are any mistakes, hopefully someone can catch them. But below is what I would try:

    Code:
    #!/bin/sh
    
    VER=$(/usr/bin/lsb_release -sr)
    
    if   [ '10.10' = ${VER} ]; then
     /usr/bin/wget http://172.29.39.100/ubuntu/1010/sources.list
    
    elif [ '10.04' = ${VER} ]; then
     /usr/bin/wget http://172.29.39.100/ubuntu/1004/sources.list
    
    fi
    You might need to use wget with the -O or --output-document option.

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

    Re: He me with this bash scripting?

    how about
    Code:
    wget http://172.29.39.100/ubuntu/$( lsb_release -sr | tr -d '.' )/sources.list
    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

  4. #4
    Join Date
    Aug 2009
    Location
    India
    Beans
    Hidden!
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: He me with this bash scripting?

    Thankyou Vaphell & Lars Noodén

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
  •