Skip to content

Instantly share code, notes, and snippets.

@Alex4386
Last active August 9, 2019 11:58
Show Gist options
  • Save Alex4386/29d0224357458e7ccbcd07765790c3ee to your computer and use it in GitHub Desktop.
Save Alex4386/29d0224357458e7ccbcd07765790c3ee to your computer and use it in GitHub Desktop.
domistyle/docker-idrac6 launch
#!/bin/bash
echo ===================================
echo " _ ____ ____ _ ____ __ "
echo "(_) _ \\| _ \\ / \\ / ___/ /_ "
echo "| | | | | |_) | / _ \\| | | '_ \\ "
echo "| | |_| | _ < / ___ \\ |__| (_) |"
echo "|_|____/|_| \\_\\/_/ \\_\\____\\___/ "
echo ===================================
## Configuration Section
echo "Configuration"
echo
while [ "$host" == "" ]; do
auto_complete=""
if [ -f "$HOME/.idrac-data/host" ]; then
getto_daze=$(cat "$HOME/.idrac-data/host")
auto_complete=" ($getto_daze)"
fi
read -p "idrac host$auto_complete: " host
if [ "$host" == "" ]; then
if [ -f "$HOME/.idrac-data/host" ]; then
host=$(cat "$HOME/.idrac-data/host")
else
echo "idrac host can not be blank"
fi
fi
done
if [ ! -d "$HOME/.idrac-data" ]; then
mkdir $HOME/.idrac-data
fi
if [ ! -f "$HOME/.idrac-data/host" ]; then
touch $HOME/.idrac-data/host
fi
echo "${host}" > $HOME/.idrac-data/host
read -p "idrac user (root): " user
if [ "$user" == "" ]; then
user="root"
fi
while [ "$pw" == "" ]; do
echo -n "idrac pw: "
read -s pw
if [ "$pw" == "" ]; then
echo "idrac password can not be blank"
fi
done
echo
echo
echo "Configuration Checking"
echo "Host: $host"
echo "User: $user"
echo "Password: [REDACTED]"
echo
echo
echo "Please provide directory to mount at /app/tmp"
read -p "Directory to mount (Default: None): " mount_dir
mount_cmd=""
if [ "$mount_dir" != "" ]; then
mount_cmd="--volume ${mount_dir}:/app/tmp"
fi
echo
echo "Want Docker to be verbose?"
read -p "Type \"yes\" (without quotation marks, case-sensitive) for verbose: " verbose
if [ "$verbose" == "yes" ]; then
verbose_cmd="-a STDOUT"
else
verbose_cmd="-d"
fi
echo
echo
echo "Want to activate keycode hack?"
read -p "Type \"yes\" (without quotation marks, case-sensitive) for keycodehack: " keycode
if [ "$keycode" == "yes" ]; then
keycode_cmd=" -e IDRAC_KEYCODE_HACK=1"
else
keycode_cmd=""
fi
echo
echo "Docker will be online at localhost:5800"
sleep 1
docker run $mount_cmd $verbose_cmd -p 5800:5800 -p 5900:5900 -e IDRAC_HOST=$host -e IDRAC_USER=$user -e IDRAC_PASSWORD=$pw $keycode_cmd domistyle/idrac6
if [ $? -eq 0 ]; then
if [ "$verbose" == "yes" ]; then
echo
echo "Docker Terminated!"
else
echo
echo "Docker Online! at localhost:5800"
fi
else
echo
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "If you are using Docker for macOS, make sure that is turned on, do not launch this again on sudo"
echo "If you are using Docker for macOS, make sure your mount-directory is available for File Sharing"
echo "You can set it at: Docker Icon -> Preferences -> File Sharing"
exit 1
fi
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment