最新 追記

雑記帳


2014-05-22 (Thu) [長年日記]

[AWS] Amazon Linuxでclamavのパッケージがamzn-updatesに追加された

最近、いつからか分からないけど、Amazon LinuxにClamAVパッケージが追加された模様。

[ec2-user@localhost ~]$ yum info clamav
Loaded plugins: priorities, security, update-motd, upgrade-helper
network_ha-clustering_Stable                                                                                      68/68
treasuredata                                                                                                      28/28
18 packages excluded due to repository priority protections
Installed Packages
Name        : clamav
Arch        : x86_64
Version     : 0.98.3
Release     : 1.el6
Size        : 3.5 M
Repo        : installed
From repo   : epel
Summary     : Anti-virus software
URL         : http://www.clamav.net/
License     : GPLv2
Description : Clam AntiVirus is a GPL anti-virus toolkit for UNIX. The main purpose of
            : this software is the integration with mail servers (attachment scanning).
            : The package provides a flexible and scalable multi-threaded daemon, a
            : command line scanner, and a tool for automatic updating via Internet.
            :
            : The programs are based on a shared library distributed with the Clam
            : AntiVirus package, which you can use with your own software. Most
            : importantly, the virus database is kept up to date

Available Packages
Name        : clamav
Arch        : x86_64
Version     : 0.98.1
Release     : 1.3.amzn1
Size        : 1.0 M
Repo        : amzn-updates
Summary     : End-user tools for the Clam Antivirus scanner
URL         : http://www.clamav.net
License     : GPLv2
Description : Clam AntiVirus is an anti-virus toolkit for UNIX. The main purpose of this
            : software is the integration with mail servers (attachment scanning). The
            : package provides a flexible and scalable multi-threaded daemon, a command
            : line scanner, and a tool for automatic updating via Internet. The programs
            : are based on a shared library distributed with the Clam AntiVirus package,
            : which you can use with your own software. The virus database is based on
            : the virus database from OpenAntiVirus, but contains additional signatures
            : (including signatures for popular polymorphic viruses, too) and is KEPT UP
            : TO DATE.

すでにepelからclamavをインストールしている状態で単純にアップデートしようとすると、競合してエラーになってしまう。解決策は単純で、対象となるリポジトリのみを指定すれば良い。

$ sudo yum update --disablerepo=* --enablerepo=epel clamav

参考: AWS Developer Forums: ClamAV on Amazon Linux ...


2014-05-30 (Fri) [長年日記]

[AWS] EC2にマウントされているEBSのボリュームIDを取得するワンライナー

$ aws ec2 describe-instances \
  --instance-ids `curl -s http://169.254.169.254/latest/meta-data/instance-id` \
  --region `curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | \
  jq -r ".region"` --query 'Reservations[*].Instances[*].BlockDeviceMappings[*].[Ebs.VolumeId, DeviceName]' --output text

出力例

vol-deadbeef	/dev/sda1
vol-baddcafe	/dev/sdb

EC2が稼働しているリージョンと、インスタンスIDはメタデータサーバから取得して使っている。あとは、AWS CLIのqueryオプションを使って、EBSのIDとBlockDeviceMappingsを出力している。