Last active
February 15, 2022 12:21
-
-
Save dorentus/4689543 to your computer and use it in GitHub Desktop.
dynamically generated /etc/motd using fortune, cowsay & lolcat,save it as /etc/update-motd.d/95-lolcat.Google `pam_motd` or `update-motd` for more details of dynamically generated message-of-the-day.
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 | |
# see: http://blog.tomtung.com/2009/11/cowsay-fortune | |
# http://www.commandlinefu.com/commands/view/3584/remove-color-codes-special-characters-with-sed | |
# https://github.com/busyloop/lolcat | |
# https://github.com/dorentus/mruby-lolcat-bin | |
# | |
# requires `fortune`, `cowsay`, | |
# and ruby gem `lolcat` or its mruby version equivalent | |
export LANG="en_US.UTF-8" | |
export PATH="/usr/games:/usr/local/bin:$PATH" | |
printf "\n" | |
msg=`fortune -a -s` | |
# Randomly pick a mode of the cow | |
modes=("" -b -d -g -p -s -t -w -y ); mode=${modes[$(($RANDOM % 9))]} | |
# cowsay or cowthink? | |
cowdos=(cowsay cowthink); cowdo=${cowdos[$(($RANDOM % 2))]} | |
# Radomly pick a cow picture file | |
speaker=`cowsay -l | sed '1d;s/ /\n/g'| sort -R | head -1` | |
# lolcat | |
cmd_lolcat="$(command -v lolcat_m)" || cmd_lolcat="$(command -v lolcat)" | |
# That's it ^^ | |
echo "$msg" | $cowdo -n -f $speaker $mode | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | $cmd_lolcat -f | |
printf "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this command
" sudo chmod a+x /etc/update.motd.d/* " (without double-quote)