LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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,036
Blog Entries: 3

Rep: Reputation: 174Reputation: 174
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
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,688

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
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,036
Blog Entries: 3

Original Poster
Rep: Reputation: 174Reputation: 174
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
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,688

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
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,036
Blog Entries: 3

Original Poster
Rep: Reputation: 174Reputation: 174
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: Gentoo mostly, currently. Bedrock Linux (+gentoo,+others) again, soon.
Posts: 197

Rep: Reputation: 62
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,036
Blog Entries: 3

Original Poster
Rep: Reputation: 174Reputation: 174
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,036
Blog Entries: 3

Original Poster
Rep: Reputation: 174Reputation: 174
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:55 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration