A complete rewrite of the Linux scripts

Re: A complete rewrite of the Linux scripts

Postby telnetuserid » 13.07.2017, 05:47

This is great.
Watching this thread for another great stuff, such as support for curl as downloader tool in addition to wget and aria2.
telnetuserid
 
Posts: 12
Joined: 04.10.2016, 06:33

Re: A complete rewrite of the Linux scripts

Postby mani » 14.07.2017, 16:44

Dear Hartmut
I had since Monday a none running cron task and found that the debian-10 updates must have changed something with either bash or cron.....or the wsusofline110 update (which I had to do manually on Sunday).....your beta-4 worked for a few days before without problems.

never the less with a small change in download-updates.bash I could solve the ignorance of the "export $TERM=xterm" in my cron script.

Line 208
+ if [[ "${TERM}" = "dumb" ]]; then
+ COLUMNS=80
+ LINES=24
+ else
if type -P tput > /dev/null; then
COLUMNS="$(tput cols)"
LINES="$(tput lines)"
else
COLUMNS=80
LINES=24
fi
+ fi
export COLUMNS
export LINES

I hope you find a better solution, because my bash knowledge is very basic.

BR
Mani
mani
 
Posts: 21
Joined: 04.04.2017, 15:50

Re: A complete rewrite of the Linux scripts

Postby hbuhrmester » 15.07.2017, 00:22

It seems, that I didn't notice this before.

The two conditions can probably be combined: if the terminal is not a dumb terminal, then tput can be used to query the height and width.

If this fails, then the variables can be set with a parameter expansion that provides default values. This works, if the variables are unset or empty and may serve as a "catch all", if tput does not work as expected.

The code then looks like:

Code: Select all
# Try to get the height and width of the terminal window. These
# environment variables are usually available in interactive sessions,
# but they are not inherited by scripts.
#
# If the script is running within a terminal emulator window, then tput
# can be used to query its dimensions. This does not work within a cron
# job, though.
if [[ "${TERM}" != "dumb" ]] && type -P tput  > /dev/null; then
    COLUMNS="$(tput cols)" || true
    LINES="$(tput lines)"  || true
fi

# If the variables could not be set with tput, they will be set to
# default values.
COLUMNS="${COLUMNS:-80}"
LINES="${LINES:-24}"
export COLUMNS
export LINES
hbuhrmester
 
Posts: 525
Joined: 11.10.2013, 20:59

Re: A complete rewrite of the Linux scripts

Postby mani » 16.07.2017, 11:07

Thanks, worked

I found another (unimportant glitch)...or maybe I am the only one who runs it with cron?

first i have overseen that the preferences.bash is only a template in the original and have to be copied without the template addition in the file name to work.

The updates runs now automatically and starts the same download-updates.bash again...
in my case not ideal, because I am running all my updates from another bash script (edited get-all-updates.bash)
At least I will see a problem in the morning, because my logcheck script was not running and I am missing my daily WSUSoffline-Update email

I don't see an easy way to solve this problem and actually it is not necessary (or a waste of time), because the next night it will run fully and I am forced to check the logs ;-)

BR
Mani
mani
 
Posts: 21
Joined: 04.04.2017, 15:50

Re: A complete rewrite of the Linux scripts

Postby hbuhrmester » 17.07.2017, 02:37

The updates runs now automatically and starts the same download-updates.bash again...
in my case not ideal, because I am running all my updates from another bash script (edited get-all-updates.bash)


The other commands in the script get-all-updates.bash should still be run, with the exception that the first script encounters an error. Then the rest of the script get-all-updates.bash will be stopped. This is controlled by the option errexit at the beginning of the file:

Code: Select all
# Stop this script, if one of download runs exits with an error code.
set -o errexit


It was inserted, because I wanted an easy way to stop all commands in this file. Now I can type Ctrl-C to stop one download run, and all remaining download runs are canceled as well. But you won't get any error message, if the option errexit stops a script. If you think, this is wrong, you could comment out this option.
hbuhrmester
 
Posts: 525
Joined: 11.10.2013, 20:59

Re: A complete rewrite of the Linux scripts

Postby mani » 17.07.2017, 12:00

I was mimicking the wsusoffline1101 update once again (changing StaticDownloadLink-this.txt) and this time it run through my whole update script without interruption.

After the next real update I will know for sure, if there is no error raising, which silently interrupts my script.

Thanks for your help
mani
 
Posts: 21
Joined: 04.04.2017, 15:50

Re: A complete rewrite of the Linux scripts

Postby lindesbs » 19.07.2017, 07:29

Thanks for this working script.
But only one question still open for me: How to create the ISO files ?
That is one of the most used options, when using the Windows tool.
lindesbs
 

Re: A complete rewrite of the Linux scripts

Postby Dalai » 19.07.2017, 15:35

lindesbs wrote:That is one of the most used options, when using the Windows tool.

Really? Isn't it easier to just copy the wsusoffline\client directory to a USB flash drive and use that on the Windows target system?

Regards
Dalai
Dalai
 
Posts: 1041
Joined: 12.07.2016, 21:00

Re: A complete rewrite of the Linux scripts

Postby boco » 19.07.2017, 16:09

In my case, I service Virtual Machines, so, the ISO option is far more convenient than USB.

Not everyone uses WOU the same way. That's why I appreciate the choice to use ISO or USB. You need to do neither, simply copying the .\client subdirectory to the target machine (or hosting over SMB) is enough.
Microsoft update catalog: http://catalog.update.microsoft.com/v7/site/
Windows Install media download: https://support.microsoft.com/en-us/help/15088/windows-create-installation-media
boco
 
Posts: 2391
Joined: 24.11.2009, 17:00
Location: Germany

Re: A complete rewrite of the Linux scripts

Postby lindesbs » 19.07.2017, 18:04

OK /client directory is one solution. But i have downloaded the updates for Win10 32/64, Win Server 2012/2016 and Office Updates.
So, this directory will grow larger than 30GB.

I need bigger USB sticks
lindesbs
 

PreviousNext

Return to Linux

Who is online

Users browsing this forum: No registered users and 7 guests