Last modified 20180621

I wrote the second paragraph and decided I should introduce what the script does. The name of the script is “doUpdate.sh”. Now for what it should be doing.

  1. First thing is to see which Hardware the system is using.
  2. Update your Linux packages.
  3. Upgrade the aforementioned Linux Packages.
  4. Check to see if any options were entered either “dist” or “full” upgrade.
  5. Distributions upgrade or full upgrade the system as a whole.
  6. Automatically remove unused or orphaned packages.
  7. Check to see if any packages that may be help or frozen to updates and list upgradable packages.
  8. Create a a text file listing all your Linux  packages available; called “apt.list”.
  9. Also let you know the file size of the “apt.list”
  10. Inform you how long your system has been up.
  11. Depend on Hardware from Step 1. If Raspberry PI then list codec’s, various voltages then finally the CPU voltages. If NOT Raspberry Pi, show CPU/Core temperatures and Hard Drive Temperatures if they exist..
  12. Making sure to display C and F Temperature.
  13. Finally do a “lsb_release” (Linux Standard Base) and display.
  14. Work between my various Linux platforms, x64: xenial and bionic Raspberry Pi’s:  stretch,  xenial (tested, others should work OK, but may need extra logic to allow certain functions.

Items you will/may need to install:

sudo apt install bc lm-sensors

You might like some utilities  to install:

sudo apt install filezilla catfish tmux screen vcgencmd

Now perhaps vcgencmd did not install, I hope we have a fix for it. (You may need to delete it from your previous install list for others to install).

This short sections is for installation of “vcgencmd” But try this first:

sudo vcgencmd measure_temp or sudo /opt/vc/bin/vcgencmd measure_temp

if it works, the jump to the EXPORT PATH below and try that to help. You may also need to use the sudo as shown above.

If it does not work continue on,

try to install:

sudo apt install

From https://www.funtoo.org/Raspberry_Pi_Userland_(VCGENCMD)

cd Downloads

git clonehttps://github.com/raspberrypi/userland

cd userland

This is to make sure cmake is installed:

sudo apt install cmake -y

Now:

cd userland

./buildme

OR:

Check to see if /opt/vc/bin contains “vcgencmd” by:

ls -al /opt/vc/bin/

I hope it appears there is it does then this maybe will do it:

export PATH=$PATH:/opt/vc/bin
export LD_LIBRARY_PATH=$LD_LIBRARYPATH:/opt/vc/lib

if not then there are too many possibilities1. so try the following links for help:

1.

2.

3.

After trying all three I finally got it to work, so maybe the userland worked and the EXPORT PATH worked. The script will work without this, but a lot of nice information, Please leave feedback if it was not installed and you got it to work,

If you already have these it is OK as it will only update them if updates are needed.

On with the scripting code:

Quite a bit of information. Of course not all will be use to you. I found that I did many of those tasks from the keyboard as individual items most every time I logged on, except for step 13. As this is just informational.

My code isn’t pretty, but is functional. This script was written to work on my Pi-2, Pi-3 b, Pi-3 B+, and lastly my HP 8570p and HO-8570w laptops, both x64 i7’s running both Win 7 and Ubuntu Studio. I will try to explain most lines, somethings I May take into account as you probably reading this not as an expert in Linux, but maybe not a Newbie?

This program I call doUpdate.sh is used to update, upgrade, dist-upgrade/full-upgrade and validate packages. Code is at end of article and a download link (link updates newer version on 20180621). Discussion here may not reflect exact current code.

The code is here at in the document but in sections, full code is at end of document between:

********* start of code ************

Is the code

*********** end of code **********.

Now Linux does already have in a software package that does most of what I am writing about, but this is provided to help your understanding on script writing.

The following code is an example (could be better written) of how to get some things done from a command line. This would best be done by downloading the latest code from my server.(link updates newer version on 20180621). Discussion here may not reflect exact current code.You may need to do an chmod to the file once you download it or copy and paste. The command should be:

chmod +x doUpdate.sh

 

So here we go:

#!/bin/bash
# by Benny D Miller ARS w4qed script for doing updates, upgrades and apt.list

# if you modify, please leave original credits there, just add your own.
# latest revision 1.11 on 20180607
#
# 20180607 add in do shutdown or reboot (halt or reboot) and –help.
# 20180528 added in stretch OS.
# 20180523 fixed logic error I made.
# 20180523 just cleaning it up to make more readable.
# 20180522 changed from apt-get to apt.
# 20180413 added in and changed temperature measurements and display
# 20160101 started this.

First line is important it tells the O/S (Operating System – Linux) which shell to use, as there are many.

#!/bin/bash

The rest is advertising myself and the program revisions, I just started using revisions on this script to keep track which one I am using. They all worked, but as I made changes I really wasn’t sure which one I was actually running; hence, revision numbers.

Next:

#

RED=`tput setaf 1`;
GREEN=`tput setaf 2`;
YELLOW=`tput setaf 3`;
BLUE=`tput setaf 4`;
RESET=`tput sgr0`;
#

This is defining the colors I use to display what is going on so if there is a problem, you should be able to identify where the problem is (that particular section of code). Now if you would like to do away with the colors, then replace the COLOR:=’xxxxxxxx’ with ‘tput srg0’.

Where:

Black = 0 (used to reset text color back to default color in my example)

Red = 1

Green = 2

Brown/Orange = 3

Blue = 4

Purple = 5

Cyan = 6

White = 7

Now I believe that this can go from 0 to 255 for more shades of the colors, now tput is a terminal control output program.

So we define the number in  it such as:

RED=`tput setaf 1`;

will let us use the new variable named ${RED} to display text in the color of red and likewise we reset to default by:

RESET=`tput sgr0`;

Then we are back to normal text color buy using in out display string ${RESET}. Now we do not need to use uppercase, I was just making it easier to follow.

Next:

echo –help for help, dist or full and remove or autoremove and halt or reboot.; echo;
if ([ ! -z $1 ] && [ $1 == “–help” ]);
then
echo;
echo usage: doUpdate.sh or doUpdate.sh with options
echo usage: options are dist or full to do a distribution upgrade
echo usage: and/or use remove or autoremove to autoremove unused packages.
echo usage: \(Choose only 3\) doUpdate.sh full autoremove anther options
echo usage: is either halt or reboot as last option, they can be any option order,
echo usage: order if they come before dist and or remove then the later options
echo usage: will not be used.; echo;
echo usage: examples:
echo usage: .\\doUpdate.sh
echo usage: .\\doUpdate.sh dist
echo usage: .\\doUpdate.sh dist autoremove
echo usage: .\\doUpdate.sh full autoremove reboot
echo usage: .\\doUpdate.sh dist remove halt
echo usage: .\\doUpdate.sh halt ${RESET}; echo;
#
exit; # just help.
fi

This sections echo’s how to use the program. You can try:

.\doUpdate.sh dist remove and it will do the same thing as doing .\doUpdate.sh –help Notice there are two dashes “–help”. Once help is done the script will exit.

Other options are .\doUpdate.sh full autoremove.  It will do .\doUpdate.sh full dist, but remember it will do the dist-update or full-update twice.

Next:

I think I should have mentioned earlier, but with the “#!” exception the “# ” and space afterwards is just a comment.

echo; is just that echo a line, with the “;” meaning to terminate this expression. (end of command).

Next:

Here we define the hardware and Linux O/S Variables. It is an actual Linux program that returns the hardware description. I recommend that you take a Terminal window and execute any of these programs and see what it does. Try “uname –help” to get a description of options (variables) that are available.

Hardware:

HW=$(uname -m);

This defines variable $HW to be set by the program “uname -m”.

Linux O/S:

OS=$(lsb_release -s -c);

gives the Linux version we are using in our variable $OS.

Now:

echo; echo ${GREEN}Doing updates.${RESET}; echo;
time sudo apt update; echo;

This action does a newline (CR/LF) with the command “echo;”.

Now ${GREEN} changes the text to green from previous definition of “GREEN=`tput setaf 2`;” and the “${RESET}” changes things back to default colors. Now I could have done several lines by only setting “${GREEN}” once and the “${RESET}” to the last line in the sequence. I wanted to make sure you could understand what was going on easily? Yes I know! Not so easy. everything between ${GREEN} and ${RESET} is just text here.

“time sudo apt update; echo;”; times the execution of the command “sudo apt upgrade -y”. The command sudo apt upgrade tells Linux to enable Superuser to tell the application “apt” ( Advanced Packaging Tool) to preform actions; again do a “apt –help” or “apt-get –help”. The “apt” is a simplified user implementation of”apt-get”. So “sudo apt update -y” says to do any updates that may have been issued and the “-y” says to go on and do these updates. Try: “sudo apt update” without the “-y” and see what happens. The “apt” program will request your permission to do the updated. If you have already done it, there may not be any updates; so try at a later date. In theory it just list the “updates” available to your system and “upgrade” actually does the instillation of the required updates.

Next:

echo; echo ${GREEN}now doing upgrades.${RESET}; echo;
time sudo apt upgrade -y; echo; echo -n ${GREEN} All updates and upgrades are now completed at: ; date; echo ${RESET};

Similarly, “upgrade” looks for any upgrades to the O/S that may need to be upgraded. Again the “-y” gives permission to the “apt” program to do the upgrades.

Next:

if [ ! -z $1 ] # check to see if empty
then
if [ $1 == “dist” ] || [ $1 == “full” ] # not empty, only do dist-upgrate
then
echo; echo ${BLUE}now doing dist-upgrade${RESET}; echo;
time sudo apt dist-upgrade -y; echo; echo -n ${BLUE}The dist-upgrade is completed at: ; date; echo ${RESET};
fi

if [ ! -z $1 ] # check to see if empty The line.

then

the “if” is sort of self explanatory but sets up a condition that if what is between the “[” and “]” is true then  do the following “then” section. So if “!” means NOT in logic and the “-z $1” is to check if the “$1” argument (passed from the command line IE: dist or full or …) if the argument passed is empty do nothing is  entered then skip the part of the If then clause.

Now there are several conditional “if …then” clauses, so try to read them through. I’ll be brief with those.

Continuing:

if [ $1 == “dist” ] || [ $1 == “full” ] # not empty, only do dist-upgrade
then
echo; echo ${BLUE}now doing dist-upgrade${RESET}; echo;
time sudo apt dist-upgrade -y; echo; echo -n ${BLUE}The dist-upgrade is completed at: ; date; echo ${RESET};
fi

This checks to see the 1st argument contains the word “dist” and the “||” is a logical OR so that if it contains either “dist” or “full then execute what follows after the “then”. IE: do the “sudo apt dist-upgrade” similarly could have used “sudo apt full-upgrade”.  BTW: the following “fi” is the end of the “if…then…clause” ending the “if” statement. Note that the respective “[” and “]” brackets help contain what you are testing.

Continuing:

if [ $1 == “remove” ] || [ $1 == “autoremove” ] # do autoremove
then
echo; echo ${GREEN}now doing autoremove${RESET}; echo;
time sudo apt autoremove -y; echo; echo ${GREEN}autoremove has completed at: ; date; echo ${RESET};
fi

Not so much different as before and we are now testing to see if the words or options entered were either “remove” or “autoremove” then do the respective action if one of those options were entered.

Next:

if [ ! -z $2] ] # again check to see if empty
then
if [ $2 == “dist” ] || [ $2 == “full” ] # not empty, only do dist-upgrate
then
echo; echo ${BLUE}now doing dist-upgrade${RESET}; echo;
time sudo apt dist-upgrade -y; echo; echo -n ${BLUE}The dist-upgrade has completed at: ; date; echo ${RESET};
fi
if [ $2 == “remove” ] || [ $2 == “autoremove” ] # do autoremove
then
echo; echo ${GREEN}now doing autoremove${RESET}; echo;
time sudo apt autoremove -y; echo; echo autoremove has completed at: ; date; echo;
fi
fi

This is checking the 2nd argument if any were passed, note again we check if the argument is empty and do nothing if so, Now you may wonder why I did this double checking. Mainly in case you entered “remove dist” as options then they will get executed accordingly and order does not matter in this script.

Now:

#
echo; echo ${YELLOW}now checking for upgradable packages.${RESET}; echo;
time sudo apt list –upgradable; echo; echo -n ${YELLOW}All lists for upgradable packages have completed at: ; date; echo ${R$
#

This section  is checking for upgradable packages and list them out using the “sudo apt list –upgradable” command. kind of a second chance to see if something needs to be upgraded. In one of my systems I have a version of Firefox that is version 5.02 and I don’t want it to be upgraded, so this throws out a list that a held package is not upgraded, but could be.

Following:

#

echo; echo ${BLUE}now making an apt.list${BLUE};
time apt list > ~/apt.list; echo; echo -n ${BLUE}completed making apt.list at: ; date; echo ${RESET};
#

Here you will see an “apt -list > ~/apt.list”. I like to have a list of “apt” packages available to install. Here a little explanation “time” time how long it takes to do the following command of “apt –list > ~/apt.list” and what we are doing is using “apt” to get a list then the “>” is a redirection of output of whatever command precedes it, try “ls -al > 1.txt” will create a file called “1.txt”. So try “ls -al” you will see the long alphabetical list of your current directory. Now back to the program, the “~/apt.list” takes the list that “apt” gave us and stores it into the user’s home directory IE: “cd ~/” tells the program to change directory to the current users home directory. EX: /home/Pi..

The following has been tested with Pi 3B Plus (stretch).

Sort of self explanatory, but here goes. If the hardware is “armv7l”  then check to see of “jessie” etc. is the Linux System (O/S)  if so lets continue, else continue on.

if [ $HW == “armv7l” ]
then
if [ $OS == “jessie” ] || [ $OS == “xenial” ] || [ $OS == “stretch” ]
then

This section checks to see if Hardware is “armv7l” then if it is, continue to check if the O/S is “jessie”  or O/S is “xenial”  or “stretch” then continue, if not go to skip to #1. Now I need to explain that I have only checked the three Pi O/S’s, so there will be others that either need to be added or they will skip some of the code.

for codec in H264 MPG2 WVC1 MPG4 MJPG WMV9 ; do \
eho -e “$codec:\t$(sudo vcgencmd codec_enabled $codec)” ; \
done

The above checks for codec’s that may be enabled. It does a for loop checking with vcgencmd to see if enabled. Within a for a condition then it is done. The for statements sets up what to look for using the vcgencmd H264 and so on checking each type entered. The loop will continue till there are no more items in the list to check,
for id in core sdram_c sdram_i sdram_p ; do \
echo -e “$id:\t$(sudo vcgencmd measure_volts $id)” ; \
done

Again using the vcgencmd to measure voltages  and identify what is being measured.
# sudo vcgencmd measure_volts core
# sudo vcgencmd measure_temp

Comments above.

sudo vcgencmd measure_volts core
tm=`sudo vcgencmd measure_temp`
# tm=`/opt/vc/bin/vcgencmd measure_temp`
tc=`echo $tm| cut -d ‘=’ -f2 | sed ‘s/..$//’`
tf=$(echo “scale=2;((9/5) + $tc) + 32” | bc)
echo temp = $tc\°C \($tf\°F\)

Now the above gets a little tricky and I really had a hard time getting things to work correctly. 1st measure core voltage and display. Then measure CPU temp.  Now we set up a three variables tm tc and tf these are measured Temp, temp Centigrade and temp Farenheit respectively. The line with tm is straight forward get the measured temperature, we’ll look at the tc line now. so it starts off by echo the tm, but the “|” is a pipe (in other-words send the echoed string tm to the next operation to its right which is cut everything before the delimiting character which is the “=”) by using options “-d ‘='”  I know you are flying blind here so do a “sudo vcgencmd measure_temp” and it will return something similar to “temp=53.2’C” maybe not your exact results, but that is OK, in this example it is temp is 53.2 Centigrade. now we are cutting out everything before the delimited character including the “=” and put it out to standard output (your Terminal). For a brief explanation the “-f2” is a field selector, by using cut and the “-d ‘='” we have effectively cut the string into two fields, field 1 is temp and filed 2 is 53.2’C.  Just try this out on your command line try: “sudo vcgencmd measure_temp | cut -d ‘=’  -f2” or substitute “-f1”.  when using the “-f1” it will return temp and when using “-f2” for field 2 you will get 53.2’C in our example; all without the “=” symbol. Now again we use the pipe command “|” to pass the previous results from the cut command upon string “53.2’C” to sed.  Now “sed” is a stream editor (hence the name sed) with the right options it will parse further action on the previous resulting string “53.2’C”

Now with sed we use an option for search for a patters by using “s/” and the following pattern we are looking for in this case “..$” so the pattern is defined by “s/..$/” and after the second “/” and put in the word you want after you find the pattern like ‘s/word/WORD/’ will replace word with the Capitalized expression of WORD. So our substitution of ‘s/..$//’ says to search for. the pattern in our case is ..$, OK I’m sure you understand that one. I actually had to go to my Unix/Linux Guru (someone that actually knows what they are doing). Now lets break this down a bit. The “..$” tells “sed” to search the “.” wildcard character for our WORD. Then the “$” tells “sed” to go to the end of the string hence “..$” means go to the last two characters of the screen and the final “//” is what we are replacing (replace with nothing) and this deletes the last two characters of our original string which was “temp=53.2’C” and we get  for our final string that “sed” gives up the final string of “temp=53.2” as the last two characters were removed using “sed ‘s/..$//’`” and this is stored in a variable we are calling tc.

We are almost through this last part as all we need to do is convert the temperature stored in tc (stored in Celsius) to Fahrenheit. In this code “scale=2;((9/5) + $tc) + 32″ | bc)” should be almost a given, since we have all went through grade school. Just a couple things might throw you off. First is “scale=2” this means to set the number of digits after the decimal point. In this example we get 2 digits after the number.

Now our arithmetic is to divide 9 by 5  and is looks like this (9/5) and then add in 32 for an offset.  Now we have (9/5) + 32.  Remember Celsius’s 0 degree starts at Fahrenheit’s 32 degree point.  All to do how is add in out temperature that is in Delicious ; so in our case we are testing 53.2. Then put it all together we do the scale and set the number after the decimal point to 2 digits then process (( (9/5 + 32) + 53.2). Using () to keep the math order correct.

We have actually been preparing (parsing) the number to pass to the binary calculator “bc”.  Do you remember the pipe command? “|” is passing and giving directions to bc for calculations. Wait for it… with 53.2’C our final number is 87.00’F in Fahrenheit.

Now: We are almost done.

The “else” is from the “armv7l” check.

else
The echo is sort of explanatory the -e means to interpretation of the “\” backslash character. The $(sensors -f) I only found to be useful in my i7 bionic x64 version of Linux.

And the “;” in case I have not mentioned before is a end of line/command

echo -e “$(sensors -f)” ;
echo ;

Almost last is “hddtemp” if the drive has it enabled. “/dev/sda”, “/dev/sdb” etc are your Hard Drives and if you have seperate partitions, it is still the same Hard Drive.
echo -e “$(sudo hddtemp /dev/sda -uF)” ;
echo -e “$(sudo hddtemp /dev/sdb -uF)” ;
echo -e “$(sudo hddtemp /dev/sdc -uF)” ;
fi

Last: Echo a new line, then use “lsb_release -a” and this print distribution specific information, the “-f” is to report the raw output results in Fahrenheit degrees.

echo;
lsb_release -a;

This section added late, it allows for the command line to allow reboot or halt (lowercase).

First we check again to see if there a==was an argument, if not then go to end of program (last fi).

if [ ! -z $1 ]; # check to see if any are empty
then

We know we have an argument and check to see if it is a “halt”, if not then check to see if it in in the second argument and likewise the third argument. we check to see if the argument exists with [ ! -z $2 ] this tells us the second argument isn’t blank, else we exit again. Then (&& is a logical AND) if their is a second argument then see if it matches our command “halt”.  Simulary the third argument is checked. First check to see if argument is blank, if not bland then the && (AND) if the argument is our command of “halt” then execute the shudown command.
if [ $1 == “halt” ] || ([ -z $2 ] && [ $2 == “halt” ]) || ([ ! -z $3 ] && [ $3 == “halt” ]); $
then

If we got here then one of the Arguments had to be the “halt” command line argument. Then shutdown the computer.

echo; echo ${YELLOW}System shutting down system now!!!${RESET}; sleep 3; echo;
time sudo shutdown -H -P -t 0 now; echo; # Halt, Power off.
else

Well we got here since the previous command was not “halt” now we check the same way as for the “halt”, but for the “reboot”  command. You should be able to follow the rest. If you have questions, then please ask and I’ll try to answer and make this document a bit clearer.
if [ $1 == “reboot” ] || ([ ! -z $2 ] && [ $2 == “reboot” ]) || ([ ! -z $3 ] && [ $3 == “re$
then
echo; echo ${GREEN}System will now reboot${RESET}; sleep 3; echo;
time sudo reboot; echo;
fi  # end reboot check
fi  # end if then else
fi  # if no first argument
echo ${RED}done${RESET}

Now to cintinue where I may have skipped a bit o code.

Similarly the “hddtemp -uF /dev/sd?”  ? is your specific drive /dev/sda, /dev/sdb etc. the “-uF” is to force unit output to either “C” for Centigrade or “F” for Fahrenheit.

Credits, there are so many I can not even guess where to reference them as when I have a question I usually do a Google Search. So in respect  to all those that not only have contributed to the Linux but to those countless number of people that have contributed in explaining all this stuff to us. One last special credit, Spell Check is my friend, not saying I got them all, but it surely helps.

As usual if you have questions or corrections please let me know.

You can of course download this script and go over it with a fine tooth combe,

Download the script here.

**************************** start of code  *******************************

#!/bin/bash
# by Benny D Miller ARS w4qed script for doing updates, upgrades and apt.list
# latest revision 1.11 on 20180607
#
# if you modify, please leave original credits there, just
# add your own.
# 20180607 add in do shutdown or reboot (halt or reboot) and --help
# option.
# 20180528 added in stretch OS.
# 20180523 fixed logic error I made.
# 20180523 just cleaning it up to make more readable.
# 20180522 changed from apt-get to apt.
# 20180413 added in and changed temperature measurements and display
# 20160101 started this.
#
# my housekeeping
VERSION="1.11";
MyDATE="20180528"
#
# program usage
RED=`tput setaf 1`;
GREEN=`tput setaf 2`;
YELLOW=`tput setaf 3`;
BLUE=`tput setaf 4`;
RESET=`tput sgr0`;
#
echo; echo ${YELLOW}doUpdate.sh version $VERSION";" $MyDATE
echo --help for help, dist or full and remove or autoremove
echo and halt or reboot.; echo;
#
HW=$(uname -m);
OS=$(lsb_release -s -c);

echo Hardware: $HW
echo Version of O/S: $OS

echo; echo ${GREEN}Doing updates.${RESET}; echo;
time sudo apt update; echo;

echo; echo ${GREEN}now doing upgrades.${RESET}; echo;
time sudo apt upgrade -y; echo; echo -n ${GREEN} All updates and upgrades are now completed at: ; date; echo ${RESET};

 This section just checks if there is a command argument and if
it is "--help" in the first argument and if so give examples.
#
if ([ ! -z $1 ] && [ $1 == "--help" ]);
then
 echo;
 echo usage: doUpdate.sh or doUpdate.sh with options
 echo usage: options are dist or full to do a distribution upgrade
 echo usage: and/or use remove or autoremove to autoremove unused packages.
 echo usage: \(Choose only 3\) doUpdate.sh full autoremove anther options
 echo usage: is either halt or reboot as last option, they can be any option order,
 echo usage: order if they come before dist and or remove then the later options
 echo usage: will not be used.; echo;
 echo usage: examples:
 echo usage: .\\doUpdate.sh
 echo usage: .\\doUpdate.sh dist
 echo usage: .\\doUpdate.sh dist autoremove
 echo usage: .\\doUpdate.sh full autoremove reboot
 echo usage: .\\doUpdate.sh dist remove halt
 echo usage: .\\doUpdate.sh halt ${RESET}; echo;
#
 exit; # just help. just exit script
fi
if [ ! -z $1 ] # check to see if empty
then
if [ $1 == "dist" ] || [ $1 == "full" ] # not empty, only do dist-upgrate
then
echo; echo ${BLUE}now doing dist-upgrade${RESET}; echo;
time sudo apt dist-upgrade -y; echo; echo -n ${BLUE}The dist-upgrade is completed at: ; date; echo ${RESET};
fi

if [ $1 == "remove" ] || [ $1 == "autoremove" ] # do autoremove
then
echo; echo ${GREEN}now doing autoremove${RESET}; echo;
time sudo apt autoremove -y; echo; echo ${GREEN}autoremove has completed at: ; date; echo ${RESET};
fi
#fi

if [ ! -z $2 ] # again check to see if empty
then
if [ $2 == "dist" ] || [ $2 == "full" ] # not empty, only do dist-upgrate
then
echo; echo ${BLUE}now doing dist-upgrade${RESET}; echo;
time sudo apt dist-upgrade -y; echo; echo -n ${BLUE}The dist-upgrade has completed at: ; date; echo ${RESET};
fi
if [ $2 == "remove" ] || [ $2 == "autoremove" ] # do autoremove
then
echo; echo ${GREEN}now doing autoremove${RESET}; echo;
time sudo apt autoremove -y; echo; echo autoremove has completed at: ; date; echo;
fi
fi
fi
#
echo; echo ${YELLOW}now checking for upgradable packages.${RESET}; echo;
time sudo apt list --upgradable -a; echo; echo -n ${YELLOW}All lists for upgradable packages have completed at: ; date; echo ${RESET};
#
echo; echo now making an apt.list;
time apt list > ~/apt.list; echo; echo -n completed making apt.list at: ; date; echo;
#
echo;
printf "${BLUE}File size is: "; du --all --human-readable --apparent-size apt.list;
printf "Word count is: "; wc -l < apt.list; echo ${RESET};
printf "${GREEN}System has been up for: "; echo; uptime; echo ${RESET};

if [ $HW == "armv7l" ]
then
if [ $OS == "jessie" ] || [ $OS == "xenial" ] || [ $OS == "stretch" ]
then
for codec in H264 MPG2 WVC1 MPG4 MJPG WMV9 ; do \
echo -e "$codec:\t$(sudo vcgencmd codec_enabled $codec)" ; \
done
for id in core sdram_c sdram_i sdram_p ; do \
echo -e "$id:\t$(sudo vcgencmd measure_volts $id)" ; \
done
# "sudo vcgencmd measure_volts core" try it from command line.
# "sudo vcgencmd measure_temp"
sudo vcgencmd measure_volts core
tm=`sudo vcgencmd measure_temp`
# tm=`/opt/vc/bin/vcgencmd measure_temp` could get information here also.
tc=`echo $tm| cut -d '=' -f2 | sed 's/..$//'`
tf=$(echo "scale=2;((9/5) + $tc) + 32" | bc)
echo temp = $tc\°C \($tf\°F\)
# else
for codec in H264 MPG2 WVC1 MPG4 MJPG WMV9 ; do \
echo -e "$codec:\t$(vcgencmd codec_enabled $codec)" ; \
done
for id in core sdram_c sdram_i sdram_p ; do \
echo -e "$id:\t$(vcgencmd measure_volts $id)" ; \
done
sudo vcgencmd measure_volts core
# sudo vcgencmd measure_temp
tm=`sudo vcgencmd measure_temp`
tc=`echo $tm| cut -d '=' -f2 | sed 's/..$//'`
tf=$(echo "scale=2;((9/5) + $tc) + 32" | bc)
echo temp = $tc\°C \($tf\°F\)
fi
else
echo -e "$(sensors -f)" ;
echo ;
echo -e "$(sudo hddtemp /dev/sda -uF)" ;
echo -e "$(sudo hddtemp /dev/sdb -uF)" ;
echo -e "$(sudo hddtemp /dev/sdc -uF)" ;
fi

echo;
lsb_release -a;
#
if ([ ! -z $1 ] && [ $1 == "halt" ]) || ([ ! -z $2 ] && [ $2 == "halt" ]) || ([ ! -z $3 ] && [$
 # check to see if any are empty
then
 echo; echo ${YELLOW}System shutting down system now!!!${RESET}; sleep 3; echo;
 time sudo shutdown -H -P -t 0 now; echo; # Halt, Power off.
fi # if halt
if ([ ! -z $1 ] && [ $1 == "reboot" ]) || ([ ! -z $2 ] && [ $2 == "reboot" ]) || ([ ! -z $3 ]$
 then
 echo; echo ${GREEN}System will now reboot${RESET}; sleep 3; echo;
 time sudo reboot; echo;
fi # if reboot
#

 Then we are all done, if reboot or halt was done before this will not show.
echo ${RED}done${RESET}

**************************** end of code  *******************************

OK we are all done This particular post took me about a week to compose and make sure things worked and fixed those that did not. I hope you enjoy.

Ben ARS w4qed.

QED.

 

Advertisements