Change lsb-release contents using a script [Solved]

Forum rules
Before you post please read this

Change lsb-release contents using a script [Solved]

Postby jand on Tue Jun 17, 2014 10:10 am

I am trying to write a script to automate the software installation process on new Mint (Cinnamon) installations. So after I added some PPAs and repos and stuff, I am stuck at the point where I need to temporarily alter the contents of /etc/lsb-release file in order to launch the Intel Graphics Driver update utility and install the drivers.

echo and cat commands can't be used with sudo to clear the contents of the lsb-release file, althought can be used when I switch to root. All I want to do is to clear all text and add Ubuntu's data:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"

So can someone pretty please help me with this problem? I am sure that's an easy thing to do with sed but I'm probably too stupid to find out how...

Also, is there a way to pause the script until after the Intel drivers are installed, the utility's window is closed and the original lsb-release file restored?

This is what I have so far and what I'm trying to achieve:
Code: Select all
#Intel Graphics Driver update utility
echo "deb https://download.01.org/gfx/ubuntu/14.04/main trusty main" | sudo tee /etc/apt/sources.list.d/intellinuxgraphics.list
wget --no-check-certificate https://download.01.org/gfx/RPM-GPG-KEY-ilg -O - | sudo apt-key add -
sudo apt-get update && sudo apt-get install intel-linux-graphics-installer -y
sudo cp /etc/lsb-release /etc/lsb-release.bak
????? <--- alter contents of /etc/lsb-release
sudo intel-linux-graphics-installer  <--- Pause script, open window & install drivers
sudo cp /etc/lsb-release.bak /etc/lsb-release

...Script continues with other stuff...
Last edited by jand on Tue Jun 17, 2014 2:33 pm, edited 1 time in total.
jand
Level 1
Level 1
 
Posts: 6
Joined: Fri May 09, 2014 12:55 pm

Linux Mint is funded by ads and donations.
 

Re: Change lsb-release contents using a script

Postby kurotsugi on Tue Jun 17, 2014 11:11 am

Code: Select all
#first of all, replace cp with mv.
mv /etc/apt/sources.list /etc/apt/sources.list.bak
echo "DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"" > /etc/apt/sources.list
the > command works similar with tee which you used above. as for the other question, the easiest way to pause the script is using 'sleep <time in second>' command but I'm not sure if it will work with your script design.
kurotsugi
Level 5
Level 5
 
Posts: 936
Joined: Fri Jan 25, 2013 3:54 am

Re: Change lsb-release contents using a script

Postby jand on Tue Jun 17, 2014 2:28 pm

Thanks for your input, kurotsugi. (no pun intended :P)
Unfortunately your command won't work because 'sudo echo' is a no go in Ubuntu. Also the distro identifiers have to go in /etc/lsb-release.
Anyway, I solve it using sudo sh -c 'echo... which also allowed me to replace tee with >.

So (if anyone interested) the section of the script for installing the Intel's drivers is:
Code: Select all
sudo sh -c 'echo "deb https://download.01.org/gfx/ubuntu/14.04/main trusty main" > /etc/apt/sources.list.d/intellinuxgraphics.list'
wget --no-check-certificate https://download.01.org/gfx/RPM-GPG-KEY-ilg -O - | sudo apt-key add -
sudo apt-get update && sudo apt-get install intel-linux-graphics-installer -y
sudo cp /etc/lsb-release /etc/lsb-release.bak
sudo sh -c 'echo "DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"" > /etc/lsb-release'
sudo intel-linux-graphics-installer
sudo cp /etc/lsb-release.bak /etc/lsb-release

The good thing is that the rest of the script is not executing when the Intel app's window is open, so you have all the time in the world to install the drivers before the /etc/lsb-release changes back to Mint's default.
(You also have to add this section at the very beginning or near the end of the script so you won't have to wait for this part to execute or stall the whole script if you are afk.)

Thanks again.
jand
Level 1
Level 1
 
Posts: 6
Joined: Fri May 09, 2014 12:55 pm


Return to Scripts & Bash

Who is online

Users browsing this forum: DJNightchild and 1 guest