Commits

Erik Southworth  committed 3040958

colorize terminal output

  • Participants
  • Parent commits 11ebbce

Comments (0)

Files changed (2)

 Changes in 45:
   o Code Changes:
     * Added: use ionice IDLE class schuduler to minimize disk thrashing.
+    * Added: colorize the terminal output.
+    * Added: --wipe the /appcache folder from /Steam.
   o Doc Changes:
     * various: Counter-Strike: Source now has its own depot at /css.
 

File src/boiler.in

 #~ set -o errexit # Exit when simple command fails.
 #~ set -o nounset # Trigger error when expanding unset variables.
 
+# [colors]
+if [ "$NOCOLOR" ] ; then
+    NORMAL=""
+    BOLD=""
+    RED=""
+    YELLOW=""
+    GREEN=""
+else
+    NORMAL='\033[0m'
+    BOLD='\033[01;1m'
+    RED='\033[01;91m'
+    YELLOW='\033[00;33m'
+    GREEN='\033[01;92m'
+fi
+
 # [invoke path]
 BINNAME="$0"
 BINDIR=$(dirname "$BINNAME")
 	# retry N times if there is an update/failure
 	i=0; iter=3
 	while [ $i -lt $iter ]; do
-	    [ $i -gt 0 ] && test ! ${operation_is_silent} && echo "+ Retrying command ..."
+	    [ $i -gt 0 ] && test ! ${operation_is_silent} && printf "${YELLOW}+ Retrying command ...${NORMAL}\n"
 
 	    if test ${operation_is_silent}; then
 		($IONICE "${STEAMBIN}" "${cmd[@]}" &>/dev/null)
 	    # sanity check, CONFDIR exists?
 	    if ! test -d "${CONFDIR}"; then
 		$INSTALL_DIR "${CONFDIR}" &&
-		echo "+ Creating directory ${CONFDIR} ..." ||
+		printf "${YELLOW}+ Creating directory ${CONFDIR} ...${NORMAL}\n" ||
 		${error:?Creating directory ${CONFDIR}: exited with exit code ${RETVAL-$?}}
 	    fi
 
 	    # install users steambin
 	    $INSTALL_PROGRAM "${HLDSUPDATETOOL}" "${STEAMBIN}" &&
-	    echo "+ Installing ${HLDSUPDATETOOL} to ${STEAMBIN} ..." ||
+	    printf "${YELLOW}+ Installing ${HLDSUPDATETOOL} to ${STEAMBIN} ...${NORMAL}\n" ||
 	    ${error:?Installing ${HLDSUPDATETOOL} to ${STEAMBIN}: exited with exit code ${RETVAL-$?}}
 	fi
 }
 _command_feedback()
 {
 	if test ${opt_is_noionice}; then
-	    echo "+ steam ${cmd[@]}"
+	    printf "${BOLD}+ steam ${cmd[@]}${NORMAL}\n"
 	else
-	    echo "+ ${IONICE} steam ${cmd[@]}"
+	    printf "${BOLD}+ ${IONICE} steam ${cmd[@]}${NORMAL}\n"
 	fi
 }
 
 	    # is link, check if correct
 	    link_target=$(readlink --canonicalize "${steamlink}")
 	    if test "${link_target}" = "${FILENAME}"; then
-		    printf -v reply "ok\n"
+		    printf -v reply "${GREEN}ok${NORMAL}\n"
 	    else
-		    printf -v reply "bad -> \`${link_target}'"
+		    printf -v reply "${RED}bad -> \`${link_target}'${NORMAL}"
 		    action=Repairing
 	    fi
 	elif ! test -e "${steamlink}"; then
-	    printf -v reply "missing"
+	    printf -v reply "${RED}missing${NORMAL}"
 	    action=Creating
 	elif test -x "${steamlink}"; then
-	    printf -v reply "program"
+	    printf -v reply "${RED}program${NORMAL}"
 	    action=WARNING
 	elif test -f "${steamlink}"; then
-	    printf -v reply "file"
+	    printf -v reply "${RED}file${NORMAL}"
 	    action=WARNING
 	else
-	    printf -v reply "unknown"
+	    printf -v reply "${RED}unknown${NORMAL}"
 	    action=WARNING
 	fi
 
-	printf "\n\n+ Checking steam symlink in ${rundir} ... \t${reply}"
+	printf "\n\n${YELLOW}+ Checking steam symlink in ${rundir} ... \t${reply}${NORMAL}"
 
 	# touch link, if required.
 	if [ "${action}" = "Repairing" ] || [ "${action}" = "Creating" ]; then
 
 	    # do the symlink
 	    $SYMLINK "${binlink}" "steam" &&
-	    printf "+ ${action} symlink ${steamlink} -> \`${binlink}'\n" ||
+	    printf "${YELLOW}+ ${action} symlink ${steamlink} -> \`${binlink}'${NORMAL}\n" ||
 	    ${error:?${action} symlink ${steamlink} -> ${binlink}: exited with exit code ${RETVAL-$?}}
 
 	    popd >/dev/null
 
 	elif [ "${action}" = "WARNING" ]; then
-	    printf "\n${action}: Conflict file type ${steamlink}. Expected symlink. Ignore if intentional.\n"
+	    printf "\n${RED}${action}: Conflict file type ${steamlink}. Expected symlink. Ignore if intentional.${NORMAL}\n"
 	fi
 }
 
 	_check_steam_installdir
 	_command_feedback
 
-	echo "+ removing blobs ..."
+	printf "${GREEN}+ removing blobs ...${YELLOW}\n"
 	$FIND "${installdir}" -maxdepth 2 -name "InstallRecord.blob" -print -delete
 	$FIND ${CONFDIR} -name "ClientRegistry.blob" -print -delete
 	$FIND ${CONFDIR} -name "test*.so" -print -delete
 	# remove some strange dirs if exists
+	$REMOVE -frv ${CONFDIR}/appcache
 	$REMOVE -frv ${CONFDIR}/config
 	$REMOVE -frv ${CONFDIR}/logs
 	# clean & remove old conf dir if exists (fail silently)
 	$FIND ${OLDCONFDIR} -name "steam" -print -delete 2>/dev/null
 	$FIND ${OLDCONFDIR} -name "last-run-path" -print -delete 2>/dev/null
 	$REMOVE_EMPTY_DIR ${OLDCONFDIR} 2>/dev/null
+	printf "${NORMAL}"
 	exit
 }