このガイドは、DragonFlyBSD、FreeBSD、HardenedBSD オペレーティングシステムで機能するはずです。パッケージの更新/アップグレード_のみ_を対象としており、ベースシステムやカーネルには他のパッチを適用しません。
If you are running FreeBSD 15.0-RELEASE or above, the base system will be updated via pkg as well. Otherwise you would still need to rely on freebsd-update or building it from source. For more information, please see the official FreeBSD Wiki or the Handbook.
注意: このページに記載されているすべての手順は、あなたのサーバーが Tor (ブリッジ/ガード/出口) リレーサービス専用であることを前提としています。ここに書かれている自動ソフトウェア更新処理中に_サービスが再起動される_ことにご注意ください。
1. 更新スクリプトの作成
セットアップには /root/bin/pkg-upgrade.sh を使います。これは以下のようになります。
#!/bin/sh
PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
RAND=$(jot -r 1 1980 5940)
ENV="BATCH=yes IGNORE_OSVERSION=yes"
sleep ${RAND}
env ${ENV} pkg update -q -f && \
env ${ENV} pkg upgrade -q -U -y --fetch-only && \
env ${ENV} HANDLE_RC_SCRIPTS=yes pkg upgrade -q -U -y
2. cron ジョブのスケジュール
For this particular schedule we opt to run the script every 0h00 (depending on your timezone), and will trigger the packages updates process itself depending on the value set to the $RAND variable - it's configured to produce a sleep between 1980 and 5940 seconds (or: 33 and 99 minutes).
More information about the use of jot in there can be found here - thanks to our anonymous cypherpunks. Adapt that to your needs should it be more suited to you.
# echo "0 0 * * * root /bin/sh /root/bin/pkg-upgrade.sh" > /etc/cron.d/pkg-upgrade
3. cron の再起動
最後に、cron デーモンを再起動して、設定の変更を適用します。
# service cron restart