4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

サーバーログイン時のメッセージ設定 /etc/motd

Posted at

ログイン時のメッセージ設定を行う場合に、/etc/motdを設定します。
どのサーバーにアクセスしているかが、わかりやすいので、作業ミス防止などに使ったりします。
今回は、気分を上げるために使います。

実行環境

  • PC:iMac 2011 mid
  • OS:macOS High Sierra
  • Homebrew:1.4.1
  • Go:1.9.2

goはGOPATHも設定しておいてください。

ansizeでグラフィカルにする。

まずansizeというライブラリで画像のアスキーアートを作成します。
変換する画像はgoogleで適当に持ってきましょう。「〜 png」とかで検索するとたくさん出てきますので。
私はミニオンが好きなので、こちらから拾ってきたミニオンの画像を使います。

ansizeは透過画像も変換できるので、きれいなアスキーアートができます。
go get でライブラリから持ってきます。

$ go get github.com/jhchen/ansize

以下のコマンドのように表示されればOKです。

$GOPATH/bin/ansize
Usage: ansize <image> <output> [width]>

goいれたけど、 echo $GOPATHで表示されなくて、どこいったんじゃいというときは

command
$ go env

で確認しましょう。
 
さっそく作成してみます。

command
$ $GOPATH/go/bin/ansize ./Pictures/minions.png ./minions.ascii

スクリーンショット 2017-12-26 8.35.13.png
第3引数で幅も指定できます。
デフォルトは100なのかな。
半分の50にすると少し荒くなりました。

command
$ $GOPATH/go/bin/ansize ./Pictures/minions.png ./minions.ascii 50

スクリーンショット 2017-12-26 8.39.04.png

これを使うことにします。
/etc/motd に出力します。

command
$ $GOPATH/go/bin/ansize ./Pictures/minions.png ./minions.ascii 50 >> /etc/motd

figletでメッセージを生成する。

figletは文字をアスキーアート化してくれます。
テクい感じじゃなくて普通に使用します。こちらはbrewコマンドでインストール。

$ brew install figlet

インストールしたらすぐに使用できます。
引数でアスキーアート化したい文字列を渡します。

$ figlet Welcome to iMac
__        __   _                            _          _ __  __            
\ \      / /__| | ___ ___  _ __ ___   ___  | |_ ___   (_)  \/  | __ _  ___ 
 \ \ /\ / / _ \ |/ __/ _ \| '_ ` _ \ / _ \ | __/ _ \  | | |\/| |/ _` |/ __|
  \ V  V /  __/ | (_| (_) | | | | | |  __/ | || (_) | | | |  | | (_| | (__ 
   \_/\_/ \___|_|\___\___/|_| |_| |_|\___|  \__\___/  |_|_|  |_|\__,_|\___|
                                              

これも/etc/motdに追記しましょう。
そしてターミナルでログイン!
スクリーンショット 2017-12-26 8.45.36.png

コンソールのデフォルトサイズで全体がきれいに表示されるようにするといいと思います。

4
4
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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?