This commit is contained in:
Zsolt Ero
2024-02-24 14:08:33 +01:00
parent 5a8b8c5338
commit b11a46fee1
8 changed files with 112 additions and 27 deletions

View File

@@ -81,6 +81,8 @@ def lego(c):
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('chmod +x /tmp/lego/lego')
c.run('mv /tmp/lego/lego /usr/local/bin')
c.run('rm -rf /tmp/lego*')
c.run('mkdir -p /data/nginx/acme-challenges/')

View File

@@ -1,9 +1,11 @@
import os
import secrets
import string
import sys
from pathlib import Path
import requests
from invoke import UnexpectedExit
def put(
@@ -76,7 +78,22 @@ def append_str(c, remote_path, str_):
def sudo_cmd(c, cmd, *, user=None):
cmd = cmd.replace('"', '\\"')
c.sudo(f'bash -c "{cmd}"', user=user)
try:
c.sudo(f'bash -c "{cmd}"', user=user)
except UnexpectedExit as e:
print(f'Command failed: {e.result.command}')
print(f'Error: {e.result.stderr}')
sys.exit(1)
def run_nice(c, cmd):
try:
c.run(cmd)
except UnexpectedExit as e:
print(f'Command failed: {e.result.command}')
print(f'Error: {e.result.stderr}')
sys.exit(1)
def set_permission(c, path, *, permissions=None, user=None, group=None):