Skip to content

Instantly share code, notes, and snippets.

@radium226
Created April 5, 2017 16:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radium226/87e9b9d4ab89a07a85aa58ed595e99fd to your computer and use it in GitHub Desktop.
Save radium226/87e9b9d4ab89a07a85aa58ed595e99fd to your computer and use it in GitHub Desktop.
5 services que m'a rendu systemd
#!/bin/bash
export RED_COLOR="\033[0;31m"
export DEFAULT_COLOR="\033[0m"
declare message=" ${RED_COLOR}/!\ ${DEFAULT_COLOR}${1}${RED_COLOR} /!\ ${DEFAULT_COLOR}"
declare index=
ls -1 "/dev/pts" | grep -E '[0-9]+' | while read index; do
echo -e "${message}" >>"/dev/pts/${index}"
done
#!/bin/bash
export DELAY=.5
export LOG_FILE_PATH="/var/log/spoutnik.log"
export MAX_NUMBER_OF_LINES=2
while sleep ${DELAY}; do
if [[ $( cat "${LOG_FILE_PATH}" | wc -l ) -gt ${MAX_NUMBER_OF_LINES} ]]; then
echo "Truncating ${LOG_FILE_PATH}"
truncate --size=0 "${LOG_FILE_PATH}"
else
echo "No need to truncate ${LOG_FILE_PATH}"
fi
done
#!/bin/bash
set -o pipefail
echo "Spoutnik started! " | tee -a "/var/log/spoutnik.log"
while sleep ${SPOUTNIK_DELAY:-1}; do
# Comment this if you don't want Spoutnik to bug!
if [[ $(( RANDOM % 4 )) -eq 0 ]]; then
# A wild bug appears!
echo "FAILURE!!1!"
exit 1
fi
echo "${SPOUTNIK_MESSAGE:-"Bip"}"
done | tee -a "/var/log/spoutnik.log"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment