LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Gentoo
User Name
Password
Gentoo This forum is for the discussion of Gentoo Linux.

Notices


Reply
  Search this Thread
Old 06-28-2017, 09:50 AM   #1
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Interactive script to update Gentoo install


Hello,

I recently reinstalled Gentoo on a new system and have decided to use an interactive script to do system updated.

Please take a look and let me know if there are any improvements that can be make to it. Thnx.

Code:
#/bin/bash

read -p 'Update the Portage Tree? ' tree

if [ "$tree" == "y" ]
   then
	echo '*******************************'
	echo '*******************************'
	echo '**'
	echo '**  UPDATING PORTAGE TREE'
	echo '**'
	echo '*******************************'
	echo '*******************************'
	echo
	echo
	eix-sync && \
	echo
	echo
fi

read -p 'Check Gentoo Security Advisories? ' glsa

if [ "$glsa" == "y" ]
   then
	echo '*******************************'
	echo '*******************************'
	echo '**'
	echo '**  SECURITY ADVISORIES'
	echo '**'
	echo '*******************************'
	echo '*******************************'
	echo
	echo
	glsa-check -l && \
	echo
	echo
fi

read -p 'Check System Updates? ' check

if [ "$check" == "y" ]
   then
	echo '*******************************'
	echo '*******************************'
	echo '**'
	echo '**  CHECKING SYSTEM UPDATES'
	echo '**'
	echo '*******************************'
	echo '*******************************'
	echo
	echo
	emerge --update --deep --pretend --with-bdeps=y @world && \
	echo
	echo
fi

read -p 'Porceed with System Updates? ' update

if [ "$update" == "y" ]
   then
	echo '*******************************'
	echo '*******************************'
	echo '**'
	echo '**  CHECKING SYSTEM UPDATES'
	echo '**'
	echo '*******************************'
	echo '*******************************'
	echo
	echo
	emerge --update --deep --with-bdeps=y @world && \
	echo
	echo
fi

read -p 'Remove Pckages No Longer Needed? ' cleanup

if [ "$cleanup" == "y" ]
   then
	echo '*******************************'
	echo '*******************************'
	echo '**'
	echo '**  REMOVING OLD PACKAGES'
	echo '**'
	echo '*******************************'
	echo '*******************************'
	echo
	echo
	emerge --ask --depclean && \
	echo
	echo
fi

read -p 'Update ETC Files? ' etc

if [ "$etc" == "y" ]
   then
	echo '*******************************'
	echo '*******************************'
	echo '**'
	echo '**  UPDATING ETC FILES'
	echo '**'
	echo '*******************************'
	echo '*******************************'
	echo
	echo
	etc-update && \
	echo
	echo
fi

echo
echo
echo '*******************************'
echo '*******************************'
echo '**'
echo '**  SYSTEM UPDATE COMPLETE'
echo '**'
echo '*******************************'
echo '*******************************'
echo
echo
 
Old 06-28-2017, 10:20 AM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
You do not have to write 'echo' for every line.
Code:
read -p 'Update the Portage Tree? ' tree

if [ "$tree" == "y" ]
   then
	echo "*******************************
	     ********************************
	     **				   **
             **  UPDATING PORTAGE TREE     **
	     **				   **
	     ********************************
	     ********************************"
	echo;echo
	echo "eix-sync && \""
	echo;echo
fi
 
Old 06-28-2017, 10:36 AM   #3
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249

Original Poster
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Thnx. That would make for less typing.
But because of the indents to the script I need to leave those echo's in there so everything lines up.

Other then that, do I have all the bases covered?

Last edited by lazydog; 06-28-2017 at 10:41 AM.
 
Old 06-28-2017, 10:46 AM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by lazydog View Post
Thnx. That would make for less typing.
But because of the indents to the script I need to leave those echo's in there so everything lines up.

Other then that, do I have all the bases covered?
try one and see what it does. it just a matter of formatting the text to show how you want it on your screen.
and if it is doing everything that you want it to, then I'd say yes.

Q: what ifs.

what if you hit the wrong key then what happens?
 
Old 06-28-2017, 12:06 PM   #5
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249

Original Poster
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Thnx. I already know if any key but y is hit the script moves onto the next step in the process.

Code:
Update the Portage Tree? f
Check Gentoo Security Advisories? e
Check System Updates? s
Porceed with System Updates? t
Remove Pckages No Longer Needed? u
Update ETC Files? s


*******************************
*******************************
**
**  SYSTEM UPDATE COMPLETE
**
*******************************
*******************************
Which is exactly what I want.
 
Old 08-15-2017, 06:32 AM   #6
Siljrath
Bedrock Linux Advocate
 
Registered: Nov 2004
Location: the internet
Distribution: server:Gentoo | workstation:Bedrock (hijacked:void, fetched:Gentoo,Devuan,Artix)
Posts: 226

Rep: Reputation: 66
basics covered, here's some further development ideas to consider.

could include overlay and eix stuff maybe.

glsa stuff maybe too? like to give the option to only ugrade the glsa packages.


also, i wondered about the questions being asked up front, bam bam bam bam bam, before anything happens, so it isnt left waiting for user interaction. so it would be as fast for the user saying "y" to the questions, as "n" (or other).
...and then even have an alternative answer to "y", where "a" for "ask" could still offer the chance to be asked before proceeding at some stage, like where what you might want to do might change depending on the outcome of the previous step.
 
Old 08-15-2017, 10:15 AM   #7
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249

Original Poster
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Quote:
Originally Posted by Siljrath View Post
basics covered, here's some further development ideas to consider.

could include overlay and eix stuff maybe.
What do you mean with the eix reference? I do syncing as the first thing in the script.
Overlays... maybe. Haven't really looked into overlays as I am still new to gentoo and its workings

Quote:
glsa stuff maybe too? like to give the option to only ugrade the glsa packages.
Again I do this in the script so what are you referring to here?

Quote:
also, i wondered about the questions being asked up front, bam bam bam bam bam, before anything happens, so it isnt left waiting for user interaction. so it would be as fast for the user saying "y" to the questions, as "n" (or other).
...and then even have an alternative answer to "y", where "a" for "ask" could still offer the chance to be asked before proceeding at some stage, like where what you might want to do might change depending on the outcome of the previous step.
Sometimes it make sense to ask the question right before the action as something that is shown just before might influence your decision on if you should continue or not. If you answered everything upfront you might not want a portion to be completed at the present time because of something that was in one of the outputs.

I have stream-lined the script a bit and added color. When I get home tonight I'll post the new script.
 
Old 08-15-2017, 05:11 PM   #8
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249

Original Poster
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Here is what I have now:

Code:
#/bin/bash

clear


# *** PORTAGE TREE UPDATE ***
echo
echo
echo $'\e[32;1m*******************************'
echo '*******************************'
echo '**'
echo '**  UPDATING PORTAGE TREE'
echo '**'
echo '*******************************'
echo $'*******************************\e[0m'
echo
echo
eix-sync && \
echo
echo

# *** SECURITY ADVISORIES ***
echo
echo
echo $'\e[32;1m*******************************'
echo '*******************************'
echo '**'
echo '**  SECURITY ADVISORIES'
echo '**'
echo '*******************************'
echo $'*******************************\e[0m'
echo
echo
glsa-check -l && \
echo
echo

# *** SECURTIY CONTINUE ***
read -p $'\e[33;1mContinue with System Updates?\e[0m ' check

if [ "$check" == "n" ]
   then
        exit
fi

# *** SYSTEM UPDATE ***
echo
echo
echo $'\e[32;1m*******************************'
echo '*******************************'
echo '**'
echo '**  CHECKING SYSTEM UPDATES'
echo '**'
echo '*******************************'
echo $'*******************************\e[0m'
echo
echo
emerge --ask --update --deep --with-bdeps=y @world && \
echo
echo

# *** REMOVE OLD PACKAGES
echo
echo
echo $'\e[32;1m*******************************'
echo '*******************************'
echo '**'
echo '**  REMOVING OLD PACKAGES'
echo '**'
echo '*******************************'
echo $'*******************************\e[0m'
echo
echo
emerge --ask --depclean && \
echo
echo

# *** UPDATING ETC FILES
echo
echo
echo $'\e[32;1m*******************************'
echo '*******************************'
echo '**'
echo '**  UPDATING ETC FILES'
echo '**'
echo '*******************************'
echo $'*******************************\e[0m'
echo
echo
etc-update && \
echo
echo

echo
echo 
echo $'\e[32;1m*******************************'
echo '*******************************'
echo '**'
echo '**  SYSTEM UPDATE COMPLETE'
echo '**'
echo '*******************************'
echo $'*******************************\e[0m'
echo 
echo
 
Old 12-02-2017, 12:42 PM   #9
_roman_
Member
 
Registered: Dec 2017
Location: _Austro_Bavaria_
Distribution: gentoo / linux mint
Posts: 433

Rep: Reputation: 29
You miss the keep-going feature. Kinda annoying when portage stops on every package which breaks. like sdl2-mixer which is not fixed for over 2 weeks, open bugs for ages.

And depclean is dangerous. I would not recommend removing packages if you do not have to by a script

depclean removes anything which is not related to the world file, and the world file itself, is a headache to keep it sane.

why not


emerge --sync; emerge --update --keep-going --deep -N world

you can add that bdeps things, but i hardly ever add that

i use


emerge --sync; emerge -av --update --keep-going --deep -N world

to see a list whats updated. that is also a decent point to uninstall software, change useflags, lookup useflags before you proceed.

--

also i would not recommend to use etc-update by a script. that tool is broken in my point of view. the majority are just fresh config files, where most of the time i delete rm /etc/.... _cfg_0000_file_name.
Never let a script touch the bootloader, grub.cfg or the /etc directory

etc-update will overwrite your network password, and other user changed config files, so you loose functionality. never ever use it carelessly! it's more recommended to ignore the message about config files

--

if you want to update your box and do not really care, add a cron job for that. not recommended but if you want to.

also setting kernel symlink, x-server + nvidia-driver can render you in loss of x-server, direct rendering, so an autoupdate script is not recommended.

gentoo has the habbit to provide kernels with not compatible nvidia-drivers. after 2 weeks you can update to a newer kernel branch usually after a new nvidia-driver is in the portage tree

it also does not remove older kernels, older kernel modules, cleans up boot.

--

i would not give the impression, that this update script fix everything for the newbie user. for the others its just enough to

emerge --sync; emerge -av --update --keep-going --deep -N world

Last edited by _roman_; 12-02-2017 at 12:46 PM.
 
Old 12-02-2017, 05:16 PM   #10
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249

Original Poster
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Quote:
Originally Posted by _roman_ View Post
i would not give the impression, that this update script fix everything for the newbie user. for the others its just enough to

emerge --sync; emerge -av --update --keep-going --deep -N world
Thanks for you feed back, I'll take a look at some of those things you listed. Never intended to give the impression that this is the script that fixes anything. If you read what I posted I state that I installed Gentoo and this is the script I use to update my system. This is an interactive script so nothing is done without your approval.
 
Old 12-03-2017, 05:26 AM   #11
_roman_
Member
 
Registered: Dec 2017
Location: _Austro_Bavaria_
Distribution: gentoo / linux mint
Posts: 433

Rep: Reputation: 29
Honestly I just looked into your code, not in the text.

Thank you for your feedback.

I think my one liner is more than enough for that purpose.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
witch - install gentoo with an easy script Siljrath Linux - Distributions 0 07-05-2012 12:39 AM
BASH - How to open an interactive script from a non interactive script..... OldGaf Programming 4 06-29-2008 04:34 PM
shell script in non interactive way googlix Linux - General 6 11-13-2007 09:18 AM
Please help with interactive script moosedaddy Linux - Newbie 3 12-08-2005 09:02 PM
Gentoo - interactive boot[?] Ph0enix2003 Linux - Distributions 3 09-20-2004 04:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Gentoo

All times are GMT -5. The time now is 06:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration