LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Gentoo (https://www.linuxquestions.org/questions/gentoo-87/)
-   -   Interactive script to update Gentoo install (https://www.linuxquestions.org/questions/gentoo-87/interactive-script-to-update-gentoo-install-4175608785/)

lazydog 06-28-2017 09:50 AM

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


BW-userx 06-28-2017 10:20 AM

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


lazydog 06-28-2017 10:36 AM

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?

BW-userx 06-28-2017 10:46 AM

Quote:

Originally Posted by lazydog (Post 5728328)
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?

lazydog 06-28-2017 12:06 PM

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.

Siljrath 08-15-2017 06:32 AM

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.

lazydog 08-15-2017 10:15 AM

Quote:

Originally Posted by Siljrath (Post 5748444)
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.

lazydog 08-15-2017 05:11 PM

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


_roman_ 12-02-2017 12:42 PM

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

lazydog 12-02-2017 05:16 PM

Quote:

Originally Posted by _roman_ (Post 5787837)
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.

_roman_ 12-03-2017 05:26 AM

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.


All times are GMT -5. The time now is 10:09 AM.