diff --git a/das_fanctl.sh b/das_fanctl.sh new file mode 100755 index 0000000..5c1182d --- /dev/null +++ b/das_fanctl.sh @@ -0,0 +1,17 @@ +#/bin/bash + +#Zeb H. +#Dell MD1200 Fan Silencing Script. + +#set TTY Flags +stty -F /dev/ttyS1 38400 raw -echoe -echok -echoctl -echoke + +#Run 12 times, sleeping 5 seconds in between (total runtime: 1 min) + +for i in $(seq 1 12) +do + + #Change the value vv here to set fan percentage + echo -e -n '_shutup 15\r' > /dev/ttyS1 + sleep 5 +done diff --git a/fan_control.sh b/fan_control.sh new file mode 100755 index 0000000..6da7cf0 --- /dev/null +++ b/fan_control.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# +# https://github.com/brezlord/iDRAC7_fan_control +# A simple script to control fan speeds on Dell generation 12 PowerEdge servers. +# If the inlet temperature is above $TEMP_THRESHOLD C enable iDRAC dynamic control and exit program. +# If inlet temp is below $TEMP_THRESHOLD C set fan control to manual and set fan speed to predetermined value. +# The tower servers T320, T420 & T620 inlet temperature sensor is after the HDDs so temperature will +# be higher than the ambient temperature. + +# Variables +IDRAC_IP="10.1.1.251" +IDRAC_USER="root" +IDRAC_PASSWORD="*^b#!efRhE8qULqUCa4U" +#ENCRYPT_KEY="9233879628486273445939847673574256378762" +# Fan speed in % +SPEED0="0x00" +SPEED5="0x05" +SPEED10="0x0a" +SPEED15="0x0f" +SPEED20="0x14" +SPEED25="0x19" +SPEED30="0x1e" +SPEED35="0x23" +TEMP_THRESHOLD="45" # iDRAC dynamic control enable thershold +#TEMP_SENSOR="04h" # Inlet Temp +TEMP_SENSOR="01h" # Exhaust Temp +#TEMP_SENSOR="0Eh" # CPU 1 Temp +#TEMP_SENSOR="0Fh" # CPU 2 Temp +SENSOR_NAME="Sensor" +if [ "$TEMP_SENSOR" == "04h" ] + then + SENSOR_NAME="Inlet" +elif [ "$TEMP_SENSOR" == "01h" ] + then + SENSOR_NAME="Exhaust" +elif [ "$TEMP_SENSOR" == "0Eh" ] + then + SENSOR_NAME="CPU1" +elif [ "$TEMP_SENSOR" == "0Fh" ] + then + SENSOR_NAME="CPU2" +fi +# Get system date & time. +DATE=$(date +%d-%m-%Y\ %H:%M:%S) +echo "Date $DATE" + +# Get temperature from iDARC. +T=$(ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD sdr type temperature | grep $TEMP_SENSOR | cut -d"|" -f5 | cut -d" " -f2) +echo "--> iDRAC IP Address: $IDRAC_IP" +echo "--> Current $SENSOR_NAME Temp: $T" + +# If ambient temperature is above $TEMP_THRESHOLD C enable dynamic control and exit, if below set manual control. +if [[ $T > $TEMP_THRESHOLD ]] +then + echo "--> Temperature is above $TEMP_THRESHOLD C" + echo "--> Enabled dynamic fan control" + ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD raw 0x30 0x30 0x01 0x01 + exit 1 +else + echo "--> Temperature is below $TEMP_THRESHOLD C" + echo "--> Disabled dynamic fan control" + ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD raw 0x30 0x30 0x01 0x00 +fi + +# Set fan speed dependant on ambient temperature if inlet temperaturte is below $TEMP_THRESHOLD C. +# If inlet temperature between 0 and 19deg C then set fans to 15%. +if [ "$T" -ge 0 ] && [ "$T" -le 19 ] +then + echo "--> Setting fan speed to 15%" + ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD raw 0x30 0x30 0x02 0xff $SPEED15 + +# If inlet temperature between 20 and 24deg C then set fans to 20% +elif [ "$T" -ge 20 ] && [ "$T" -le 24 ] +then + echo "--> Setting fan speed to 20%" + ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD raw 0x30 0x30 0x02 0xff $SPEED20 + +# If inlet temperature between 25 and 29deg C then set fans to 25% +elif [ "$T" -ge 25 ] && [ "$T" -le 29 ] +then + echo "--> Setting fan speed to 25%" + ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD raw 0x30 0x30 0x02 0xff $SPEED25 + +# If inlet temperature between 30 and $TEMP_THRESHOLD C then set fans to 30% +elif [ "$T" -ge 30 ] && [ "$T" -le $TEMP_THRESHOLD ] +then + echo "--> Setting fan speed to 25%" + ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD raw 0x30 0x30 0x02 0xff $SPEED25 +fi + + diff --git a/izebra-linux-oneshot-sh4d0w.sh b/izebra-linux-oneshot-sh4d0w.sh new file mode 100644 index 0000000..a561178 --- /dev/null +++ b/izebra-linux-oneshot-sh4d0w.sh @@ -0,0 +1,97 @@ +#!/bin/bash +#Zebra +#Linux Onboarding Oneshot script for izebra networks. +#Installs fish, starship, and sets up some shell tweaks that are nice to have. +#Check script is running as root +if [ "$EUID" -ne 0 ] + then echo "Please run as Root" + exit 1 +fi + +#define variables +fishconfig="https://git.izebra.net/izebra_projects/rmm-scripts/raw/branch/main/config-files/config.fish" +starshipconfig="https://git.izebra.net/izebra_projects/rmm-scripts/raw/branch/main/config-files/starship.toml" + +#Add fish shell repo and install +echo Installing fish... +sudo apt-add-repository --yes ppa:fish-shell/release-3 +sudo apt update +sudo apt install fish -y + + +#Copy fish config file to root and all users under /home/ + +echo Downloading Fish Config File. Storing in $HOME/.config/fish/config.fish +wget -O "$HOME/.config/fish/config.fish" $fishconfig +# Iterate over each user's home directory, including /root +for homedir in /root /home/*; do + if [ -d "$homedir" ]; then + # Ensure .config directory exists + echo Creating dir structure for $homedir + mkdir -p "$homedir/.config" + mkdir -p "$homedir/.config/fish" + + # Copy starship.toml to the user's .config directory + echo copying fish config to $homedir/.config/fish/config.fish + cp -f "$HOME/.config/fish/config.fish" "$homedir/.config/fish/config.fish" + + # Set ownership to the user of the home directory + echo Taking ownership of file under UID $homedir + chown -R $(basename "$homedir"):"$(id -gn $(basename "$homedir"))" "$homedir/.config/" + + # Optional: Set permissions to 0644 (readable by owner and group, readable by others) + echo setting file perms + chmod 0644 "$homedir/.config/fish/config.fish" + fi +done + +#install pyenv +curl https://pyenv.run | bash + +#Download starship and copy config file to root and all users under /home/ +echo Downloading starship installer to $HOME/starship.sh +wget -O $HOME/starship.sh https://starship.rs/install.sh +chmod +x $HOME/starship.sh +sh $HOME/starship.sh --force +rm $HOME/starship.sh + +wget -O "$HOME/.config/starship.toml" $starshipconfig +# Iterate over each user's home directory, including /root +for homedir in /root /home/*; do + if [ -d "$homedir" ]; then + # Ensure .config directory exists + echo Creating directories for $homedir + mkdir -p "$homedir/.config" + + # Copy starship.toml to the user's .config directory + echo Copying config file to $homedir/.config/starship.toml + cp -f "$HOME/.config/starship.toml" "$homedir/.config/starship.toml" + + # Set ownership to the user of the home directory + echo Setting ownership for $homedir + chown -R $(basename "$homedir"):"$(id -gn $(basename "$homedir"))" "$homedir/.config" + + # Optional: Set permissions to 0644 (readable by owner and group, readable by others) + chmod 0644 "$homedir/.config/starship.toml" + fi +done + +#Change default shell to fish +echo Changing default shell to fish +# Minimum UID for regular user accounts (adjust as necessary) +MIN_UID=1000 + +# Loop through all users in /etc/passwd +while IFS=: read -r username _ uid _ _ homedir _; do + # Skip system accounts and users without a home directory + if [[ $uid -ge $MIN_UID && -d $homedir ]]; then + echo "Changing shell for user: $username" + sudo chsh -s /usr/bin/fish "$username" + if [ $? -ne 0 ]; then + echo "Failed to change shell for user: $username" + fi + else + echo "Skipping system account or user without home directory: $username" + fi +done < /etc/passwd +chsh -s /usr/bin/fish