Created
April 5, 2017 16:32
-
-
Save radium226/87e9b9d4ab89a07a85aa58ed595e99fd to your computer and use it in GitHub Desktop.
5 services que m'a rendu systemd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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