任意のコマンドをtelnet経由で呼び出せるようにする
/usr/local/bin/hello.sh
に以下のような実行ファイル(コマンド)があるとする。
telnetでアクセスしたときにこれを実行したい。
/etc/systemd/system/hello.socket
に以下の内容でファイルを作成する
/etc/systemd/system/hello@.service
に以下の内容でファイルを作成する
*@.service
というファイル名の、テンプレートユニットであることに注意
/etc/systemd/system/hello@.service[Unit]
Description=Hello Server (implementation)
[Service]
Environment=LANG=C
ExecStart=/usr/local/bin/hello.sh
StandardInput=socket
StandardOutput=socket
StandardError=journal
[Install]
WantedBy=hello.socket
socketとserviceを有効化する
shsystemctl enable hello.socket
systemctl enable hello@.service
socketを開始する
shsystemctl start hello.socket
ローカルからtelnetコマンドでアクセスしてみる
参考:
See Also: