mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 14:02:15 +00:00
lego
This commit is contained in:
@@ -4,6 +4,7 @@ from ssh_lib.utils import (
|
||||
apt_get_purge,
|
||||
apt_get_update,
|
||||
exists,
|
||||
get_latest_release_github,
|
||||
put,
|
||||
put_str,
|
||||
sudo_cmd,
|
||||
@@ -67,3 +68,19 @@ def certbot(c):
|
||||
|
||||
apt_get_purge(c, 'certbot')
|
||||
c.sudo('snap install --classic certbot', warn=True)
|
||||
|
||||
|
||||
def lego(c):
|
||||
lego_version = get_latest_release_github('go-acme', 'lego')
|
||||
|
||||
url = f'https://github.com/go-acme/lego/releases/download/{lego_version}/lego_{lego_version}_linux_amd64.tar.gz'
|
||||
|
||||
c.run('rm -rf /tmp/lego*')
|
||||
c.run('mkdir -p /tmp/lego')
|
||||
c.run(
|
||||
f'wget -q "{url}" -O /tmp/lego/out.tar.gz',
|
||||
)
|
||||
c.run('tar xzvf /tmp/lego/out.tar.gz -C /tmp/lego')
|
||||
c.run('mv /tmp/lego/lego /usr/bin')
|
||||
c.run('chmod +x /usr/bin/lego')
|
||||
c.run('rm -rf /tmp/lego*')
|
||||
|
||||
@@ -3,6 +3,8 @@ import secrets
|
||||
import string
|
||||
from pathlib import Path
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def put(
|
||||
c, local_path, remote_path, permissions=None, user='root', group=None, create_parent_dir=False
|
||||
@@ -159,3 +161,14 @@ def enable_sudo(c, username, nopasswd=False):
|
||||
put_str(c, '/etc/sudoers.d/tmp.', f'{username} ALL=(ALL) NOPASSWD:ALL')
|
||||
set_permission(c, '/etc/sudoers.d/tmp.', permissions='440', user='root')
|
||||
c.sudo(f'mv /etc/sudoers.d/tmp. /etc/sudoers.d/{username}')
|
||||
|
||||
|
||||
def get_latest_release_github(user, repo):
|
||||
url = f'https://api.github.com/repos/{user}/{repo}/releases/latest'
|
||||
r = requests.get(url)
|
||||
r.raise_for_status()
|
||||
|
||||
data = r.json()
|
||||
assert data['tag_name'] == data['name']
|
||||
|
||||
return data['tag_name']
|
||||
|
||||
Reference in New Issue
Block a user