Add install certbot for ubuntu 14.04(kernel < 4.4)
This commit is contained in:
parent
613081a3f5
commit
ce266fcd78
|
@ -36,16 +36,35 @@ namespace :create_site do
|
||||||
Net::SSH.start(@site_server.ip , @site_server.account , password: @site_server.password) do |ssh|
|
Net::SSH.start(@site_server.ip , @site_server.account , password: @site_server.password) do |ssh|
|
||||||
certbot_path = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'which certbot'",false,true).strip
|
certbot_path = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'which certbot'",false,true).strip
|
||||||
snap_path = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'which snap'",false,true).strip
|
snap_path = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'which snap'",false,true).strip
|
||||||
|
already_apt_update = false
|
||||||
if certbot_path.blank?
|
if certbot_path.blank?
|
||||||
update_thread_infos("checking kernel version")
|
update_thread_infos("checking kernel version")
|
||||||
kernel_version = exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' uname -r",false,true).strip.to_f rescue 0.0
|
kernel_version = exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' uname -r",false,true).strip.to_f rescue 0.0
|
||||||
update_thread_infos("kernel_version: #{kernel_version}")
|
update_thread_infos("kernel_version: #{kernel_version}")
|
||||||
if kernel_version < 4.4
|
if kernel_version < 4.4
|
||||||
raise "Kernel version need upgrade to >= 4.4(snap need kernel >= 4.4)"
|
update_thread_infos("Downloading certbot by using python3(since kernel < 4.4)...")
|
||||||
end
|
exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' add-apt-repository ppa:deadsnakes/ppa -y",false)
|
||||||
if snap_path.blank?
|
|
||||||
update_thread_infos("execing apt update...")
|
update_thread_infos("execing apt update...")
|
||||||
exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' apt-get -y -o DPkg::options::='--force-confdef' -o DPkg::options::='--force-confold' update",true,false)
|
exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' apt-get -y -o DPkg::options::='--force-confdef' -o DPkg::options::='--force-confold' update",true,false)
|
||||||
|
already_apt_update = true
|
||||||
|
update_thread_infos("Installing python3.6 python3.6-venv libaugeas0 ...")
|
||||||
|
exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' apt-get install python3.6 python3.6-venv libaugeas0 -y",false)
|
||||||
|
exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' rm -rf /opt/certbot/",false)
|
||||||
|
update_thread_infos("generating venv for certbot ...")
|
||||||
|
exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' python3.6 -m venv /opt/certbot/",false)
|
||||||
|
exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' /opt/certbot/bin/pip install --trusted-host pypi.python.org --upgrade pip",false)
|
||||||
|
update_thread_infos("Installing certbot on python3.6 ...")
|
||||||
|
exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' /opt/certbot/bin/pip install --trusted-host pypi.python.org certbot certbot-nginx",true)
|
||||||
|
exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' rm -f /usr/bin/certbot",true)
|
||||||
|
exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' ln -s /opt/certbot/bin/certbot /usr/bin/certbot",true)
|
||||||
|
update_thread_infos("Finish install certbot!")
|
||||||
|
certbot_path = "/usr/bin/certbot"
|
||||||
|
else
|
||||||
|
if snap_path.blank?
|
||||||
|
unless already_apt_update
|
||||||
|
update_thread_infos("execing apt update...")
|
||||||
|
exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' apt-get -y -o DPkg::options::='--force-confdef' -o DPkg::options::='--force-confold' update",true,false)
|
||||||
|
end
|
||||||
update_thread_infos("Installing snap...")
|
update_thread_infos("Installing snap...")
|
||||||
exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' apt install snapd -y",true,false)
|
exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' apt install snapd -y",true,false)
|
||||||
snap_path = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'which snap'",false,true).strip
|
snap_path = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'which snap'",false,true).strip
|
||||||
|
@ -63,6 +82,7 @@ namespace :create_site do
|
||||||
update_thread_infos("There was some error when installing snap!")
|
update_thread_infos("There was some error when installing snap!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
if certbot_path.present?
|
if certbot_path.present?
|
||||||
@site_server.has_certbot = true
|
@site_server.has_certbot = true
|
||||||
@site_server.save
|
@site_server.save
|
||||||
|
|
Loading…
Reference in New Issue