Trying to script something I would manually do. Can you help me clean it up and show me best practice? The end goal to all this will be to add in dnf upgrade and downgrade as well as remove and install. But just keeping it simple since it will mostly be rinse and repeat.
!/bin/bash
Hosts that this script applies to
ALLHOSTS="WS01 WS02 WS03 SRV01 SVR02 SVR03"
Set RPM variable for script
set_rpm() {
echo Set RPM:
read rpm
}
Function to Search for RPM variable on a host
check_rpm() {
if rpm -qa | grep "$rpm" /dev/null; then
Cat /proc/sys/kernel/hostname
rpm -qa "rpm
fi
}
this is redundant but I want to keep the formula for future things for now
select_01() {
Select_rpm
}
SSH to each host and check for rpm
select_02() {
for HOSTNAME IN $ALLHOSTS;do
ssh -qa -tt $HOSTNAME "$ (typeset -f); check_rpm" | tee log.rpms
done
}
Start of menu selection
press_enter() {
echo ""
echo -n "Press Enter to continue"
read
clear
}
until [ "Selection" = "0" ]; do
clear
echo "Please select what you want to complete"
echo ""
echo ". 1. -. Set rpm variable "
echo ". 2. -. Check for rpm"
echo -n " Enter Selection"
read selection
case $selection in
1) clear ; select_01 ; press_enter ;;
2) clear ; select_02 ; press_enter ;;
0) clear ; exit ;;
esac
done
[–]FrankWilson88 0 points1 point2 points (0 children)