mirror of
https://github.com/saltstack/salt-bootstrap.git
synced 2025-04-16 09:40:21 +00:00
Remove color support.
It will be cumbersome if even possible to handle colors on shell output and no colors on logfile, and doin' this using the simplest and most portable `sh` way.
This commit is contained in:
parent
8b67922da0
commit
9887b234a3
1 changed files with 28 additions and 77 deletions
|
@ -16,8 +16,6 @@
|
|||
set -o nounset # Treat unset variables as an error
|
||||
|
||||
ScriptVersion="1.0"
|
||||
NOCOLORS=0
|
||||
|
||||
#=== FUNCTION ================================================================
|
||||
# NAME: usage
|
||||
# DESCRIPTION: Display usage information.
|
||||
|
@ -35,8 +33,6 @@ usage() {
|
|||
Options:
|
||||
-h|help Display this message
|
||||
-v|version Display script version
|
||||
-N|nocolor Do not use colors
|
||||
|
||||
EOT
|
||||
} # ---------- end of function usage ----------
|
||||
|
||||
|
@ -52,58 +48,13 @@ do
|
|||
|
||||
v|version ) echo "$0 -- Version $ScriptVersion"; exit 0 ;;
|
||||
|
||||
N|nocolor ) NOCOLORS=1 ;;
|
||||
|
||||
\? ) echo -e "\n Option does not exist : $OPTARG\n"
|
||||
\? ) echo "\n Option does not exist : $OPTARG\n"
|
||||
usage; exit 1 ;;
|
||||
|
||||
esac # --- end of case ---
|
||||
done
|
||||
shift $(($OPTIND-1))
|
||||
|
||||
# Define our colors
|
||||
if [ $NOCOLORS -eq 0 ]; then
|
||||
BLACK="\033[0;30m"
|
||||
BLUE="\033[0;34m"
|
||||
BROWN="\033[0;33m"
|
||||
CYAN="\033[0;36m"
|
||||
DARK_GRAY="\033[1;30m"
|
||||
DEFAULT_COLOR="\033[00m"
|
||||
ENDC="\033[0m"
|
||||
GREEN="\033[0;32m"
|
||||
LIGHT_BLUE="\033[1;34m"
|
||||
LIGHT_CYAN="\033[1;36m"
|
||||
LIGHT_GRAY="\033[0;37m"
|
||||
LIGHT_GREEN="\033[1;32m"
|
||||
LIGHT_PURPLE="\033[1;35m"
|
||||
LIGHT_RED="\033[1;31m"
|
||||
PURPLE="\033[0;35m"
|
||||
RED="\033[0;31m"
|
||||
RED_BOLD="\033[01;31m"
|
||||
WHITE="\033[1;37m"
|
||||
YELLOW="\033[1;33m"
|
||||
else
|
||||
BLACK=''
|
||||
BLUE=''
|
||||
BROWN=''
|
||||
CYAN=''
|
||||
DARK_GRAY=''
|
||||
DEFAULT_COLOR=''
|
||||
ENDC=''
|
||||
GREEN=''
|
||||
LIGHT_BLUE=''
|
||||
LIGHT_CYAN=''
|
||||
LIGHT_GRAY=''
|
||||
LIGHT_GREEN=''
|
||||
LIGHT_PURPLE=''
|
||||
LIGHT_RED=''
|
||||
PURPLE=''
|
||||
RED=''
|
||||
RED_BOLD=''
|
||||
WHITE=''
|
||||
YELLOW=''
|
||||
fi
|
||||
|
||||
# Define installation type
|
||||
if [ "$#" -eq 0 ];then
|
||||
ITYPE="stable"
|
||||
|
@ -112,20 +63,20 @@ else
|
|||
fi
|
||||
|
||||
if [ "$ITYPE" != "stable" -a "$ITYPE" != "daily" -a "$ITYPE" != "git" ]; then
|
||||
echo -e "${LIGHT_RED} ERROR: Installation type \"$ITYPE\" is not known...${ENDC}"
|
||||
echo " ERROR: Installation type \"$ITYPE\" is not known..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Root permissions are required to run this script
|
||||
if [ $(whoami) != "root" ] ; then
|
||||
echo -e "${LIGHT_RED} * ERROR: Salt requires root privileges to install. Please re-run this script as root.${ENDC}"
|
||||
echo " * ERROR: Salt requires root privileges to install. Please re-run this script as root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create a temporary directory used for any temp files created
|
||||
TMPDIR="/tmp/salty-temp"
|
||||
if [ ! -d $TMPDIR ]; then
|
||||
echo -e "${LIGHT_BLUE} * Creating temporary directory ${TMPDIR} ${ENDC}"
|
||||
echo " * Creating temporary directory ${TMPDIR} "
|
||||
mkdir $TMPDIR
|
||||
fi
|
||||
# Store current directory
|
||||
|
@ -182,31 +133,31 @@ shtool() {
|
|||
#===============================================================================
|
||||
download_shtool() {
|
||||
if [ ! -f $SHTOOL_COMMON ]; then
|
||||
echo -e "Download SHTOOL sh.common from $SHTOOL_COMMON_LINK"
|
||||
echo "Download SHTOOL sh.common from $SHTOOL_COMMON_LINK"
|
||||
wget $SHTOOL_COMMON_LINK -O $SHTOOL_COMMON
|
||||
MD5SUM=$(md5sum $SHTOOL_COMMON | awk '{ print $1 }')
|
||||
if [ "$MD5SUM" != "$SHTOOL_COMMON_MD5" ]; then
|
||||
echo -e "MD5 signature of sh.common does not match!"
|
||||
echo "MD5 signature of sh.common does not match!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f $SHTOOL_PLATFORM ]; then
|
||||
echo -e "Download sh.platform from $SHTOOL_PLATFORM_LINK"
|
||||
echo "Download sh.platform from $SHTOOL_PLATFORM_LINK"
|
||||
wget $SHTOOL_PLATFORM_LINK -O $SHTOOL_PLATFORM
|
||||
MD5SUM=$(md5sum $SHTOOL_PLATFORM | awk '{ print $1 }')
|
||||
if [ "$MD5SUM" != "$SHTOOL_PLATFORM_MD5" ]; then
|
||||
echo -e "MD5 signature of shtool.platform does not match!"
|
||||
echo "MD5 signature of shtool.platform does not match!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
echo -e "${LIGHT_BLUE} * Downloading shtool required scripts for system detection${ENDC}"
|
||||
echo " * Downloading shtool required scripts for system detection"
|
||||
download_shtool
|
||||
echo -e "${LIGHT_BLUE} * Downloaded required shtool scripts${ENDC}"
|
||||
echo " * Downloaded required shtool scripts"
|
||||
|
||||
echo -e "${LIGHT_BLUE} * Detecting system:${ENDC}"
|
||||
echo " * Detecting system:"
|
||||
|
||||
ARCH=$(shtool -F "%at")
|
||||
|
||||
|
@ -218,13 +169,13 @@ FULL_DISTRO=$(shtool -F '%<sp>' -L -S '|' -C '+')
|
|||
DISTRO_NAME=$(echo $FULL_DISTRO | cut -d \| -f1 )
|
||||
DISTRO_VERSION=$(echo $FULL_DISTRO | cut -d \| -f2 )
|
||||
|
||||
echo -e "${YELLOW} System Information:${ENDC}"
|
||||
echo -e "${YELLOW} System:\t\t${FULL_SYSTEM}${ENDC}"
|
||||
echo -e "${YELLOW} Architecture:\t${ARCH}${ENDC}"
|
||||
echo -e "${YELLOW} Distribution:\t${DISTRO_NAME} ${DISTRO_VERSION}${ENDC}"
|
||||
echo " System Information:"
|
||||
echo " System:\t\t${FULL_SYSTEM}"
|
||||
echo " Architecture:\t${ARCH}"
|
||||
echo " Distribution:\t${DISTRO_NAME} ${DISTRO_VERSION}"
|
||||
|
||||
if [ $SYSTEM_NAME != "linux" ]; then
|
||||
echo -e "${LIGHT_RED} * ERROR: Only Linux is currently supported${ENDC}"
|
||||
echo " * ERROR: Only Linux is currently supported"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -346,15 +297,15 @@ install_centos_63_stable_post() {
|
|||
# Let's get the dependencies install function
|
||||
DEPS_INSTALL_FUNC="install_${DISTRO_NAME}_$(echo $DISTRO_VERSION | tr -d '.')_${ITYPE}_deps"
|
||||
if [ "$(! type ${DEPS_INSTALL_FUNC} | grep -q 'shell function')" != "" ]; then
|
||||
echo -e "${BROWN} * INFO: ${DEPS_INSTALL_FUNC} not found..."
|
||||
echo " * INFO: ${DEPS_INSTALL_FUNC} not found..."
|
||||
# let's try and see if have a deps function which ignores the installation type
|
||||
DEPS_INSTALL_FUNC="install_${DISTRO_NAME}_$(echo $DISTRO_VERSION | tr -d '.')_deps"
|
||||
if [ "$( ! type ${DEPS_INSTALL_FUNC} | grep -q 'shell function' )" != "" ]; then
|
||||
echo -e "${BROWN} * INFO: ${DEPS_INSTALL_FUNC} not found..."
|
||||
echo " * INFO: ${DEPS_INSTALL_FUNC} not found..."
|
||||
# Let's try to see if we have a deps function which also ignores the distro version
|
||||
DEPS_INSTALL_FUNC="install_${DISTRO_NAME}_deps"
|
||||
if [ "$( ! type ${DEPS_INSTALL_FUNC} | grep -q 'shell function' )" != "" ]; then
|
||||
echo -e "${LIGHT_RED} * ERROR: Installation not supported not supported. Can't find ${DEPS_INSTALL_FUNC}()${ENDC}"
|
||||
echo " * ERROR: Installation not supported not supported. Can't find ${DEPS_INSTALL_FUNC}()"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
@ -363,11 +314,11 @@ fi
|
|||
# Let's get the install function
|
||||
INSTALL_FUNC="install_${DISTRO_NAME}_$(echo $DISTRO_VERSION | tr -d '.')_${ITYPE}"
|
||||
if [ "$( ! type ${INSTALL_FUNC} | grep -q 'shell function' )" != "" ]; then
|
||||
echo -e "${BROWN} * INFO: ${INSTALL_FUNC} not found..."
|
||||
echo " * INFO: ${INSTALL_FUNC} not found..."
|
||||
# Let see if we have an install function which ignores the distribution version
|
||||
INSTALL_FUNC="install_${DISTRO_NAME}_${ITYPE}"
|
||||
if [ "$( ! type ${INSTALL_FUNC} | grep -q 'shell function' )" != "" ]; then
|
||||
echo -e "${LIGHT_RED}ERROR: Installation not supported not supported. Can't find ${INSTALL_FUNC}()${ENDC}"
|
||||
echo " * ERROR: Installation not supported not supported. Can't find ${INSTALL_FUNC}()"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
@ -375,33 +326,33 @@ fi
|
|||
# Let's get the post function, if any, it's optional
|
||||
POST_INSTALL_FUNC="install_${DISTRO_NAME}_$(echo $DISTRO_VERSION | tr -d '.')_${ITYPE}_post"
|
||||
if [ "$( ! type ${POST_INSTALL_FUNC} | grep -q 'shell function' )" != "" ]; then
|
||||
echo -e "${BROWN} * INFO: ${POST_INSTALL_FUNC} not found..."
|
||||
echo " * INFO: ${POST_INSTALL_FUNC} not found..."
|
||||
# let's try and see if have a post function which ignores the installation type
|
||||
POST_INSTALL_FUNC="install_${DISTRO_NAME}_$(echo $DISTRO_VERSION | tr -d '.')_post"
|
||||
if [ "$( ! type ${POST_INSTALL_FUNC} | grep -q 'shell function' )" != "" ]; then
|
||||
echo -e "${BROWN} * INFO: ${POST_INSTALL_FUNC} not found..."
|
||||
echo " * INFO: ${POST_INSTALL_FUNC} not found..."
|
||||
# Let's try to see if we have a deps function which also ignores the distro version
|
||||
POST_INSTALL_FUNC="install_${DISTRO_NAME}_post"
|
||||
if [ "$( ! type ${POST_INSTALL_FUNC} | grep -q 'shell function' )" != "" ]; then
|
||||
echo -e "${BROWN} * INFO: ${POST_INSTALL_FUNC} not found..."
|
||||
echo " * INFO: ${POST_INSTALL_FUNC} not found..."
|
||||
POST_INSTALL_FUNC=""
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install dependencies
|
||||
echo -e "${LIGHT_BLUE} * Running ${DEPS_INSTALL_FUNC}()${ENDC}"
|
||||
echo " * Running ${DEPS_INSTALL_FUNC}()"
|
||||
$DEPS_INSTALL_FUNC
|
||||
|
||||
# Install Salt
|
||||
echo -e "${LIGHT_BLUE} * Running ${INSTALL_FUNC}()${ENDC}"
|
||||
echo " * Running ${INSTALL_FUNC}()"
|
||||
$INSTALL_FUNC
|
||||
|
||||
# Run any post install function
|
||||
if [ "$POST_INSTALL_FUNC" != "" ]; then
|
||||
echo -e "${LIGHT_BLUE} * Running ${POST_INSTALL_FUNC}()${ENDC}"
|
||||
echo " * Running ${POST_INSTALL_FUNC}()"
|
||||
$POST_INSTALL_FUNC
|
||||
fi
|
||||
|
||||
# Done!
|
||||
echo -e "${LIGHT_BLUE} * Salt installed!${ENDC}"
|
||||
echo " * Salt installed!"
|
||||
|
|
Loading…
Add table
Reference in a new issue