Merge pull request #16 from TannerFilip/main

Rewrite Install.sh
This commit is contained in:
Jack 2022-05-20 21:13:13 +01:00 committed by GitHub
commit 6108ba21ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,76 +1,65 @@
GNU nano 4.8 Install.sh Modified #!/bin/bash
##!/bin/bash
if [ $(id -u) -ne 0 ]; then
echo -e "\e[31mThis must be run as root!\e[0m"
exit 126
fi
echo "You are about to download and install the required items for HP ILO4 fan control." echo "You are about to download and install the required items for HP ILO4 fan control."
echo "Do you accept? [yes] or [no] :" read -rep "Do you accept? (y/N): " ACCEPTED
read input if [[ ${ACCEPTED,,} =~ ^[y] ]]; then
if [ $input = yes ] ; then mkdir -p ~/autofan
# agreement confirmed cd ~/autofan
# refresh OR create agreement file status echo "Installing required packages..."
echo "Installing required apt packages; sshpass, lm-sensors, and wget"
apt install sshpass wget lm-sensors jq -y apt install sshpass wget lm-sensors jq -y
echo "Installed required apt packages" echo -e "\e[92mDownloading ILO_250 for ROM upgrade\e[0m"
cd / wget -q https://github.com/That-Guy-Jack/HP-ILO-Fan-Control/tree/main/Files/ilo_250
echo "Downloading ILO_250 for ROM upgrade to the / directory." echo -e "\e[92m Creating autofan service\e[0m"
wget https://github.com/That-Guy-Jack/HP-ILO-Fan-Control/tree/main/Files/ilo_250 wget -q https://raw.githubusercontent.com/That-Guy-Jack/HP-ILO-Fan-Control/main/Files/autofan.service
echo "Download finished!" mv autofan.service /etc/systemd/system/
echo "Making autofan.service" echo -e "\e[92m autofan service created\e[0m"
cd /etc/systemd/system/ read -rep $'Which server are you running? (Enter 1-4)
wget https://raw.githubusercontent.com/That-Guy-Jack/HP-ILO-Fan-Control/main/Files/autofan.service 1. DL360p G8 (No ESXi)
echo "Finished making autofan.service" 2. DL380p G8 (no ESXi)
echo "Is Your host based on EXSI? (uses ILO temps over lm-sensors) [Y]/[N]" 3. DL360p G8 (ESXi-based)
read exsi 4. DL380p G8 (ESXi-based)\n' HOSTCHOICE
if [ $exsi = Y ] case $HOSTCHOICE in
echo "Which server are you running? DL360p G8 (1) or DL380p G8 (2) [1] or [2] :" 1)
read server AUTOFANFILE="autofan.sh"
if [ $server = 1 ] ; then HOSTTYPE="DL360p G8 (No ESXi)"
echo "Preping autofan.sh for DL360p G8" ;;
cd / 2)
AUTOFANFILE="autofan-dl380p-g8.sh"
HOSTTYPE="DL380p G8 (No ESXi)"
;;
3)
AUTOFANFILE="autofan-dl360p-g8-EXSI.sh"
HOSTTYPE="DL360p G8 (ESXi-based)"
;;
4)
AUTOFANFILE="autofan-dl380p-g8-EXSI.sh"
HOSTTYPE="DL370p G8 (ESXi-based)"
;;
*)
echo -e "\e[31mInvalid choice. Exiting.\e[0m"
exit 1
;;
esac
echo "Preping autofan.sh for $HOSTTYPE"
echo "Downloading latest autofan.sh" echo "Downloading latest autofan.sh"
wget https://raw.githubusercontent.com/That-Guy-Jack/HP-ILO-Fan-Control/main/Files/autofan-dl360p-g8-EXSI.sh wget -q https://raw.githubusercontent.com/That-Guy-Jack/HP-ILO-Fan-Control/main/Files/$AUTOFANFILE -O autofan.sh
echo "Downloaded autofan.sh, please change the placeholders with correct info" read -rep 'Enter iLO Username: ' ILOUSERNAME
echo "Please cisit the GitHub page to follow the instructions!" read -rep 'Enter iLO Password: ' ILOPASSWORD
echo "https://github.com/That-Guy-Jack/HP-ILO-Fan-Control" read -rep 'Enter iLO IP/hostname: ' ILOHOST
exit 1 sed -ri "s/your username/$ILOUSERNAME/" autofan.sh
elif [ $server = 2 ] ; then sed -ri "s/your password/$ILOPASSWORD/" autofan.sh
echo "Preping autofan.sh for DL380p G8" sed -ri "s/your ilo ip/$ILOHOST/" autofan.sh
cd / mv autofan.sh /
echo "Downloading latest autofan.sh for DL380p G8"
wget https://raw.githubusercontent.com/That-Guy-Jack/HP-ILO-Fan-Control/main/Files/autofan-dl380p-g8-EXSI.sh echo -e "\e[92mDone! Please visit the GitHub page to follow the instructions!\e[0m"
echo "Renaming file" echo -e "\e[1\https://github.com/That-Guy-Jack/HP-ILO-Fan-Control\e[0m"
mv autofan-dl380p-g8.sh autofan.sh
echo "Downloaded autofan.sh, please change the placeholders with correct info"
echo "Please cisit the GitHub page to follow the instructions!"
echo "https://github.com/That-Guy-Jack/HP-ILO-Fan-Control"
exit 1
fi
else else
echo " :( exitting" echo -e "\e[31m:( exiting\e[0m"
exit 1 exit 0
else
echo "Which server are you running? DL360p G8 (1) or DL380p G8 (2) [1] or [2] :"
read server
if [ $server = 1 ] ; then
echo "Preping autofan.sh for DL360p G8"
cd /
echo "Downloading latest autofan.sh"
wget https://raw.githubusercontent.com/That-Guy-Jack/HP-ILO-Fan-Control/main/Files/autofan.sh
echo "Downloaded autofan.sh, please change the placeholders with correct info"
echo "Please cisit the GitHub page to follow the instructions!"
echo "https://github.com/That-Guy-Jack/HP-ILO-Fan-Control"
exit 1
elif [ $server = 2 ] ; then
echo "Preping autofan.sh for DL380p G8"
cd /
echo "Downloading latest autofan.sh"
wget https://raw.githubusercontent.com/That-Guy-Jack/HP-ILO-Fan-Control/main/Files/autofan-dl380p-g8.sh
echo "Renaming file"
mv autofan-dl380p-g8.sh autofan.sh
echo "Downloaded autofan.sh, please change the placeholders with correct info"
echo "Please cisit the GitHub page to follow the instructions!"
echo "https://github.com/That-Guy-Jack/HP-ILO-Fan-Control"
exit 1
fi
else
echo " :( exitting"
exit 1
fi fi