□VineLinux用のcertbot-autoのパッチ(と作業)
Let’s EncryptのパッケージがGithubからのD/L方式になってから、VineLinuxで
動かなくなってしまった。
cd /usr/sbin/ git clone https://github.com/certbot/certbot cd /usr/sbin/certbot ./certbot-auto
とやってみても
Sorry, I don't know how to bootstrap Certbot on your operating system! You will need to bootstrap, configure virtualenv, and run pip install manually. Please see https://letsencrypt.readthedocs.org/en/latest/contributing.html#prerequisites for more info.
なんで?と思って調べてみると、インストールされているパッケージを調べる
処理でどのディストリビューションにも該当しないから…(´Д`)ハァ。
/usr/sbin/certbot/certbot-auto
の中身を見てみると、
:
# Install required OS packages:
Bootstrap() {
if [ -f /etc/debian_version ]; then
echo "Bootstrapping dependencies for Debian-based OSes..."
BootstrapDebCommon
elif [ -f /etc/mageia-release ] ; then
# Mageia has both /etc/mageia-release and /etc/redhat-release
ExperimentalBootstrap "Mageia" BootstrapMageiaCommon
elif [ -f /etc/redhat-release ]; then
echo "Bootstrapping dependencies for RedHat-based OSes..."
BootstrapRpmCommon
elif [ -f /etc/os-release ] && `grep -q openSUSE /etc/os-release` ; then
echo "Bootstrapping dependencies for openSUSE-based OSes..."
BootstrapSuseCommon
elif [ -f /etc/arch-release ]; then
if [ "$DEBUG" = 1 ]; then
echo "Bootstrapping dependencies for Archlinux..."
BootstrapArchCommon
else
echo "Please use pacman to install letsencrypt packages:"
echo "# pacman -S certbot certbot-apache"
echo
echo "If you would like to use the virtualenv way, please run the script again with the"
echo "--debug flag."
exit 1
fi
elif [ -f /etc/manjaro-release ]; then
ExperimentalBootstrap "Manjaro Linux" BootstrapArchCommon
elif [ -f /etc/gentoo-release ]; then
ExperimentalBootstrap "Gentoo" BootstrapGentooCommon
elif uname | grep -iq FreeBSD ; then
ExperimentalBootstrap "FreeBSD" BootstrapFreeBsd
elif uname | grep -iq Darwin ; then
ExperimentalBootstrap "Mac OS X" BootstrapMac
elif [ -f /etc/issue ] && grep -iq "Amazon Linux" /etc/issue ; then
ExperimentalBootstrap "Amazon Linux" BootstrapRpmCommon
elif [ -f /etc/product ] && grep -q "Joyent Instance" /etc/product ; then
ExperimentalBootstrap "Joyent SmartOS Zone" BootstrapSmartOS
else
echo "Sorry, I don't know how to bootstrap Certbot on your operating system!"
echo
echo "You will need to bootstrap, configure virtualenv, and run pip install manually."
echo "Please see https://letsencrypt.readthedocs.org/en/latest/contributing.html#prerequisites"
echo "for more info."
exit 1
fi
}
:
となっているが、ここのどのディストリビューションにも該当しない。
させようとして
/etc/debian_version (→ BootstrapDebCommon)
とか
/etc/redhat-release (→ BootstrapRpmCommon)
を置いても、それぞれのディストリビューション用のコマンド(dpkgとかdnf,yum)がないのでエラーとなる。
というわけで、VineLinuxように同じ処理を追加(パッチ)してみる。
BootstrapRpmCommonの処理を見ると、手っ取り早くは、
:
pkgs="
gcc
dialog
augeas-libs
openssl
openssl-devel
libffi-devel
redhat-rpm-config
ca-certificates
"
:
pkgs="$pkgs
python27
python27-devel
python27-virtualenv
python27-tools
python27-pip
"
このあたりのパッケージがあればいい。
ただし、augeas-libsに関するパッケージはないので手動インストールしないといけない。
(インストールする際にはlibxml2-develが必要)
apt-get -y install libxml2-devel mkdir /usr/src/package cd /usr/src/package wget http://download.augeas.net/augeas-1.5.0.tar.gz cd ../ tar xvzf package/augeas-1.5.0.tar.gz cd augeas-1.5.0/ ./configure --prefix=/usr make make install ldconfig ldconfig -p | grep libaugeas
さらに、certbot-autoは内部の処理でpipの古いバージョン(8.0.3)を落としてくるのだが、
新しいバージョンがあると(現に8.1.2があるけど)「pipが古いからアップグレードしろ」と
メッセージがでる。
でも、certbot-autoによるパッケージのインストール自体を仮の環境で実行しているので、
certbot-autoの内部処理でアップグレードを実行するにしないといけない。
cp /usr/sbin/certbot/certbot-auto /usr/sbin/certbot/certbot-auto.org
emacs /usr/sbin/certbot/certbot-auto
:
:
BootstrapVineCommon() {
# Tested with:
# - Vine Linux 6.3
if type apt-get 2>/dev/null
then
tool=apt-get
else
echo "Neither apt-get found. Aborting bootstrap!"
exit 1
fi
pkgs="
gcc
dialog
openssl
openssl-devel
mod_ssl-apache2
libffi-devel
rpm-utils
ca-certificates
python27
python27-devel
python27-tools
python-virtualenv
"
if [ "$ASSUME_YES" = 1 ]; then
yes_flag="-y"
fi
if ! $SUDO $tool install $yes_flag $pkgs; then
echo "Could not install OS dependencies. Aborting bootstrap!"
exit 1
fi
}
:
:
elif [ -f /etc/vine-release ]; then
echo "Bootstrapping dependencies for VineLinux..."
BootstrapVineCommon
:
:
def main():
temp = mkdtemp(prefix='pipstrap-')
try:
downloads = [hashed_download(url, temp, digest)
for url, digest in PACKAGES]
check_output('pip install --upgrade pip; ' +
'pip install --no-index --no-deps -U ' +
' '.join(quote(d) for d in downloads),
shell=True)
:
:
※Python2.6でも、やろうと思えばできるけど、2.7の方がいいと思う。
diff -up /usr/sbin/certbot/certbot-auto.org /usr/sbin/certbot/certbot-auto > \
/usr/sbin/certbot/vine-certbot-auto.patch
これで以下のようなパッチができるので、実際はこれを当ててくれればOK。
cat > /usr/sbin/certbot/vine-certbot-auto.patch
--- /usr/sbin/certbot/certbot-auto.org 2016-07-26 16:08:04.836061304 +0900
+++ /usr/sbin/certbot/certbot-auto 2016-07-26 16:10:55.247319519 +0900
@@ -323,6 +323,44 @@ BootstrapRpmCommon() {
fi
}
+BootstrapVineCommon() {
+ # Tested with:
+ # - Vine Linux 6.3
+
+ if type apt-get 2>/dev/null
+ then
+ tool=apt-get
+
+ else
+ echo "Neither apt-get found. Aborting bootstrap!"
+ exit 1
+ fi
+
+ pkgs="
+ gcc
+ dialog
+ openssl
+ openssl-devel
+ mod_ssl-apache2
+ libffi-devel
+ rpm-utils
+ ca-certificates
+ python27
+ python27-devel
+ python27-tools
+ python-virtualenv
+ "
+
+ if [ "$ASSUME_YES" = 1 ]; then
+ yes_flag="-y"
+ fi
+
+ if ! $SUDO $tool install $yes_flag $pkgs; then
+ echo "Could not install OS dependencies. Aborting bootstrap!"
+ exit 1
+ fi
+}
+
BootstrapSuseCommon() {
# SLE12 don't have python-virtualenv
@@ -494,6 +532,9 @@ Bootstrap() {
elif [ -f /etc/redhat-release ]; then
echo "Bootstrapping dependencies for RedHat-based OSes..."
BootstrapRpmCommon
+ elif [ -f /etc/vine-release ]; then
+ echo "Bootstrapping dependencies for VineLinux..."
+ BootstrapVineCommon
elif [ -f /etc/os-release ] && `grep -q openSUSE /etc/os-release` ; then
echo "Bootstrapping dependencies for openSUSE-based OSes..."
BootstrapSuseCommon
@@ -890,7 +931,8 @@ def main():
try:
downloads = [hashed_download(url, temp, digest)
for url, digest in PACKAGES]
- check_output('pip install --no-index --no-deps -U ' +
+ check_output('pip install --upgrade pip; ' +
+ 'pip install --no-index --no-deps -U ' +
' '.join(quote(d) for d in downloads),
shell=True)
except HashError as exc:
cert-botが新しくなったりしたら、これを参考にパッチ作って充てればいいかなぁ?
cd /usr/sbin/certbot/ patch < /usr/sbin/certbot/vine-certbot-auto.patch
で、インストールできたらcertbot-autoを実行すればよい。
/usr/sbin/certbot/certbot-auto -v
OKなら、
/usr/sbin/certbot/certbot-auto certonly \ --webroot --webroot-path /var/www/html -d example.jp \ --agree-tos -m 自分のメールアドレス
でさっそくドメイン認証(DV)を取得してみよう。
※ちなみにテスト用にと設定した「~.mydns.jp」はまたしても使われすぎで取得できなかった…(´Д`)ハァ…