LoginSignup
0
0

dnf-automaticのインストール&設定(通知をslackで受け取る)

Last updated at Posted at 2024-01-19

dnf-automaticのインストール

dnf install dnf-automatic

通知を送信するスクリプトの設置

vi /usr/local/bin/slack.sh
-----
#!/bin/bash

url=''https://hooks.slack.com/services/***' #slackのWebHookURL
channel="#channel_name" #slackのチャンネル名
username=`hostname` #slackのユーザー名(私はサーバーのホスト名にしています)
message=`cat -` #送信内容

payload="payload={\"channel\": \"${channel//\"/\\\"}\", \"username\": \"${username//\"/\\\"}\", \"text\": \"${message//\"/\\\"}\"}"
curl -m 5 --data-urlencode "${payload}" $url -A 'slack-alertscript'
-----

※参考
https://github.com/ericoc/zabbix-slack-alertscript

chmod 755 /usr/local/bin/slack.sh

dnf-automaticの設定

vi /etc/dnf/automatic.conf
-----
[commands]
upgrade_type = default
download_updates = yes
apply_updates = no
[emitters]
emit_via = command
[command]
command_format = "/usr/local/bin/slack.sh"
stdin_format = "{body}"
-----

※更新パッケージのダウンロードのみで自動更新はしない

dnf-automaticのチェック日時の設定

vi /usr/lib/systemd/system/dnf-automatic.timer
-----
OnCalendar=Mon *-*-* 6:00
-----

※月曜日の朝6時

起動

systemctl start dnf-automatic.timer
systemctl enable dnf-automatic.timer
systemctl daemon-reload

※参考
https://blog.denet.co.jp/dnf-automatic/

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