release
- A new management command sysrc(8) available
FreeBSD 9.
2-RELEASEでの導入を目指して、 FreeBSD 10-CURRENTおよびFreeBSD 9-STABLEに対して新しい管理コマンド 「sysrc(8)」 が追加されました。sysrc(8)は/etc/ rc. confおよび/etc/ rc. conf. localファイル (以下rc. conf(5)と表記) の内容をコマンドラインから操作するためのコマンドです。 FreeBSDはシステムの設定やサービスの設定をrc.
conf(5)で集中管理できるところが便利です。/etc/ rc. confを読めば対象のシステムがどのような状態かわかりますので、 サーバ管理に役立ちます。 これまでrc.
conf(5)はエディタで書き換えたり、 コマンドを組み合わせて処理していました。sysrc(8)を使うことで、 これをコマンド一発で処理できるようになります。システム管理の自動化においてとても有益なコマンドです。次のsysrc(8)の利用例を掲載します。 rc. conf(5)に新しく設定を追加 # grep sshd_
enable /etc/ rc. conf /etc/ rc. conf. local # sysrc sshd_ enable=YES sshd_ enable: NO -> YES # grep sshd_ enable /etc/ rc. conf /etc/ rc. conf. local /etc/ rc. conf:sshd_ enable="YES" # rc. conf(5)から項目そのものを削除 # sysrc -x sshd_
enable # grep sshd_ enable /etc/ rc. conf /etc/ rc. conf. local # rc. conf(5)の設定内容を書き換える # grep sshd_
enable /etc/ rc. conf sshd_ enable="NO" # sysrc sshd_ enable=YES sshd_ enable: NO -> YES # grep sshd_ enable /etc/ rc. conf sshd_ enable="YES" # sysrc sshd_ enable sshd_ enable: YES # sysrc(8)はrc_ conf_ filesで設定されるファイルに対して適用される。デフォルトで/etc/ rc. confおよび/etc/ rc. conf. local # sysrc rc_
conf_ files rc_ conf_ files: /etc/ rc. conf /etc/ rc. conf. local # grep background_ fsck /etc/ rc. conf /etc/ rc. conf. local /etc/ rc. conf. local:background_ fsck="YES" # sysrc background_ fsck=NO background_ fsck="YES -> NO # grep background_ fsck /etc/ rc. conf /etc/ rc. conf. local /etc/ rc. conf. local:background_ fsck="NO" # 指定した変数のデフォルト値を表示 # sysrc -D sshd_
enable sshd_ enable: NO # ユーザが設定したrc. conf(5)の設定内容一覧 # sysrc -a background_
fsck: YES bsdstats_ enable: YES clear_ tmp_ enable: YES devfs_ system_ ruleset: localrules dumpdev: AUTO hostname: parancell. ongs. co. jp ifconfig_ em0: DHCP keymap: us. pc-ctrl ldconfig_ paths: /usr/ lib/ compat /usr/ local/ lib /usr/ local/ lib/ portaudio2 /usr/ local/ lib/ compat/ pkg linux_ enable: YES lpd_ enable: YES moused_ enable: NO nfscbd_ enable: YES nfsclient_ enable: YES nfsuserd_ enable: YES nfsuserd_ flags: -domain ongs. co. jp rctl_ enable: YES rpc_ lockd_ enable: NO rpc_ statd_ enable: NO rpcbind_ enable: YES smartd_ enable: YES sshd_ enable: YES zfs_ enable: YES # システムのデフォルト設定も含めたrc. conf(5)設定一覧 # sysrc -A | grep ^sshd sshd_
enable: YES sshd_ flags: sshd_ program: /usr/ sbin/ sshd # システム管理の自動化においては、
エディタで手動編集しているような作業は自動化しにくいタスクです。sysrc(8)のように編集作業をコマンドで実行できるようになると、 システム管理の自動化がとても簡単になります。