Patching a few Linux boxes

This forums is to discuss issues and features of the Linux update Manager plugin for LabTech RMM
User avatar
Cubert
Posts: 2457
Joined: Tue Dec 29, 2015 7:57 pm
8
Contact:

Re: Patching a few Linux boxes

Post by Cubert »

Not sure that would make since.

Either it is or is not there so if you can get a listing from

Code: Select all

ls -al /root/LUM/
Then executing the same should not result in not found errors...

Code: Select all

/root/LUM/lum.sh SCAN

maxgruv
Posts: 8
Joined: Wed Aug 19, 2020 2:53 pm
3

Re: Patching a few Linux boxes

Post by maxgruv »

You are correct, it doesn't make sense. This is all taken from the same session:
#ls -al /root/LUM/

total 12
drwxr-xr-x 2 root root 4096 Jul 12 08:28 .
drwx------ 6 root root 4096 Jul 12 07:59 ..
-rwxrwxrwx 1 root root 2553 Jul 12 08:28 lum.sh

#/root/LUM/lum.sh SCAN

sh: 1: /root/LUM/lum.sh: not found
If you have no other suggestions then I'll chalk this up to a weird system issue. I've seen other indicators of things not working when they should on it as well, so I don't think it's necessarily a problem with the script or file. BUT if you have any other ideas (since I am most certainly not a Linux guru) then I would be all ears.

User avatar
Cubert
Posts: 2457
Joined: Tue Dec 29, 2015 7:57 pm
8
Contact:

Re: Patching a few Linux boxes

Post by Cubert »

Yea that's a new one for me?


lets try a few things be for giving up....

Can you cat that file?

Code: Select all

cat /root/LUM/lum.sh

Can you copy file to TMP?

Code: Select all

cp /root/LUM/lum.sh /var/tmp/

If copy is successful can you now execute file in tmp dir?

Code: Select all

/var/tmp/lum.sh SCAN
You can modify the LUM maintenance script located at "/script/maintenance/LUM Maintenances"

Edit the Write file line to write file into different directory, change line that executes file so it looks to new location and change the line that test for the file so it now looks to new location to see if file exists.

same with the line that changes the permissions on file to executable.

Seeing that services run as root this should not have any effect but seeing this odd behavior, this may be a means to see if its some security app block you.

maxgruv
Posts: 8
Joined: Wed Aug 19, 2020 2:53 pm
3

Re: Patching a few Linux boxes

Post by maxgruv »

Here are the results of the cat:
#cat /root/LUM/lum.sh

#!/usr/bin/bash

#----------------------------------------------------------
# Linux Update Manager
# desc: This script is used with the Linux Update Manager tool
# This tools scans for packages
# needing updates and the status of the linux host.
#
scriptVersion=1.0.25
#
#
#---------------------------------------------------------



if [ $EUID -ne 0 ]; then
echo "ERROR: Must be run as root"
exit 1
fi

deb=(ubuntu debian raspbian kali linuxmint)
rhe=(fedora rocky centos rhel amzn arch opensuse)
distroID=$(. /etc/os-release; echo $ID)
distroIDLIKE=$(. /etc/os-release; echo $ID_LIKE)
PM="apt"

if [[ " ${deb[*]} " =~ " ${distroID} " ]]; then
PM="apt"
elif [[ " ${deb[*]} " =~ " ${distroIDLIKE} " ]]; then
PM="apt"
elif [[ " ${rhe[*]} " =~ " ${distroID} " ]]; then
PM="yum"
else
PM="yum"
fi

CMD=$1
REBOOT=0
if [[ "$CMD" == *"SCAN"* ]]; then
if [[ "$PM" == *"apt"* ]]; then

a=$(apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\ ] )\s\[([\w,\-,\d,\.,~,:,\ ] )\]\s\(([\w,\-,\d,\.,~,:,\ ] )\)? /i){print "\(\"39\", \"8423\", \"$1\", \"$2\", \"$3\"),"}')

elif [[ "$PM" == *"yum"* ]]; then

update=$(yum check-update)
installed=$(yum list installed)
a=$(awk 'BEGIN {FS=OFS=" "} NR==FNR {v[$1]=$2; next} {print (v[$1] ? "(\"39\",\"8423\", \"" $1 "\",\"" $2 "\",\"" v[$1] "\")," : "")}' <(echo "$update") <(echo "$installed") | column -t)

else
exit 1
fi

echo -n $a | sed 's/.$//'


elif [[ "$CMD" == *"TESTREBOOT"* ]] ; then

if [[ "$PM" == *"apt"* ]]; then
PM="apt"
PMV=$(apt -v |awk '{print $2}')
if [ -f /var/run/reboot-required ]; then
REBOOT=1
fi
elif [[ "$PM" == *"yum"* ]]; then
PM="yum"
PMV=$(yum list installed | grep yum.noarch | awk '{print $2}')
if ! command -v needs-restarting &> /dev/null
then
yum install yum-utils -y
fi
TESTREBOOT=$(needs-restarting -r)
if [[ $TESTREBOOT == *"Reboot is probably not necessary"* ]]; then
REBOOT=0
else
REBOOT=1
fi
else
exit 1
fi

ba='("39", "8423", "STG-COLO-UNMS", "Scout", "'$REBOOT'", "'$PM'", "'$PMV'",NOW())'
echo -n "$ba"


elif [[ "$CMD" == *"UPDATE"* ]] ; then

if [[ "$PM" == *"apt"* ]]; then

PM="apt"
apt-get update
apt-get upgrade -y
exit 0

elif [[ "$PM" == "yum" ]]; then

PM="yum"
yum check-update
yum update -y
exit 0
else
exit 1
fi

else
exit 1

fi
File copied to tmp:
#cp /root/LUM/lum.sh /var/tmp/

OK
However, trying to execute from tmp gives the same "not found" error:
#/var/tmp/lum.sh SCAN

sh: 1: /var/tmp/lum.sh: not found
I'm guess the problem is not that the file exists but that it simply doesn't want to execute due to some other weird system issue, but the error message is misleading. To my knowledge we don't have any special security software on this device, but it was something of a custom build so I'll check with the guy that deployed it to see if he might have any insight.

Post Reply

Return to “Linux Update Manager”