LoginSignup
1
1

More than 5 years have passed since last update.

fortune-modとcowsayでログイン時にメッセージとAAを表示する

Posted at

AWSにsshログインした時にスライムを出現するようにしてみた。を読んで、以前社内サーバーのログインスクリプトにcowsayを仕込んでいたことを思い出しました。

下記環境はRaspberry pi (Raspbian 9.4)。ディストリビューションが違うとパス等は変わるかもしれません。
Redhat系OSではEPELにパッケージがあります。

cowsay

メッセージをアスキーアートと共に表示させるお遊びツール。

インストール

# apt-get install cowsay -y

使い方

$ /usr/games/cowsay [-f cowfile] MESSAGE

こんな風に呼び出します。 -f を省略すると牛が表示されます。

pi@raspberrypi:~$ /usr/games/cowsay "諦めたらそこで試合終了ですよ...?"
 __________________________________
< 諦めたらそこで試合終了ですよ...? >
 ----------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

-f でcowfileを指定できます。cowfileは/usr/share/cowsay/cows/にあります。
cowfileにはかなりきわどいものも含まれています。

pi@raspberrypi:~$ /usr/games/cowsay -f /usr/share/cowsay/cows/head-in.cow "諦めたらそこで試合終了ですよ...?"
 __________________________________
< 諦めたらそこで試合終了ですよ...? >
 ----------------------------------
    \
     \
    ^__^         /
    (oo)\_______/  _________
    (__)\       )=(  ____|_ \_____
        ||----w |  \ \     \_____ |
        ||     ||   ||           ||

fortune-mod

どこかで聞いたことがあるような、ないような明言を返してくれるツールです。

インストール

# apt-get install fortune-mod -y

使い方

pi@raspberrypi:~$ /usr/games/fortune
It is right that he too should have his little chronicle, his memories,
his reason, and be able to recognize the good in the bad, the bad in the
worst, and so grow gently old all down the unchanging days and die one
day like any other day, only shorter.
                -- Samuel Beckett, "Malone Dies"

なんだかそれっぽいメッセージが表示されました。

cowsay + fortune

cowsayとfortuneを組み合わせて、ランダムなAAにランダムな名言をつぶやかせることが出来ます。

pi@raspberrypi:~$ /usr/games/fortune | /usr/games/cowsay -f `find /usr/share/cowsay/cows/ -type f | sort -R | tail -1`
 ______________________________________
/ Your life would be very empty if you \
\ had nothing to regret.               /
 --------------------------------------
     \
      \
        ,__, |    | 
        (oo)\|    |___
        (__)\|    |   )\_
             |    |_w |  \
             |    |  ||   *

             Cower....

.bash_profileにスクリプトを仕込むと、ログインごとにAAと名言を表示できます。
名言の代わりにサーバー情報をつぶやかせた方が実用的かもしれません。

プロジェクトをフォークして slimesay とか fortune-anzai とか作りたい気もしますが、著作権違反ですね...

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1