aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rwxr-xr-xdocker/auto-backup/daemon.bash2
-rw-r--r--tool/.gitignore3
-rwxr-xr-xtool/aio.py27
4 files changed, 31 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 95d34cf..490616a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,5 @@ docker-compose.yaml
mailserver.env
data
nginx-config
-__pycache__ \ No newline at end of file
+__pycache__
+coscli-config.yaml
diff --git a/docker/auto-backup/daemon.bash b/docker/auto-backup/daemon.bash
index 6a39fa5..5dd8cfe 100755
--- a/docker/auto-backup/daemon.bash
+++ b/docker/auto-backup/daemon.bash
@@ -14,7 +14,7 @@ fi
xz --version
tar --version
-bucket_yaml=$(/coscli config show | yq ".buckets[] | select(.alias == \"crupest-backup\")")
+bucket_yaml=$(yq ".buckets[] | select(.alias == \"crupest-backup\")" ~/.cos.yaml)
# check bucket_yaml is not empty
if [[ -z "$bucket_yaml" ]]; then
diff --git a/tool/.gitignore b/tool/.gitignore
index 512ee29..01bc268 100644
--- a/tool/.gitignore
+++ b/tool/.gitignore
@@ -1 +1,2 @@
-docker-mailserver-setup.sh \ No newline at end of file
+docker-mailserver-setup.sh
+coscli \ No newline at end of file
diff --git a/tool/aio.py b/tool/aio.py
index 703b4f2..8a07802 100755
--- a/tool/aio.py
+++ b/tool/aio.py
@@ -7,6 +7,7 @@ import grp
import sys
import argparse
import shutil
+import json
import urllib.request
from rich.console import Console
from rich.prompt import Prompt, Confirm
@@ -90,14 +91,38 @@ def check_domain_is_defined() -> str:
exit(1)
+def get_coscli_download_url() -> str:
+ request = urllib.request.urlopen(
+ "https://api.github.com/repos/tencentyun/coscli/releases/latest")
+ response = request.read()
+ # parse with json
+ data = json.loads(response)
+ assets = data["assets"]
+ for asset in assets:
+ if asset["name"] == "coscli-linux":
+ return asset["browser_download_url"]
+ raise ValueError("Cannot find coscli-linux in the latest release.")
+
+
def download_tools():
+ # if we are not linux, we prompt the user
+ if sys.platform != "linux":
+ console.print(
+ "You are not running this script on linux. The tools will not work.", style="yellow")
+ if not Confirm.ask("Do you want to continue?", default=False, console=console):
+ exit(0)
+
SCRIPTS = [("docker-mailserver setup script", "docker-mailserver-setup.sh",
- "https://raw.githubusercontent.com/docker-mailserver/docker-mailserver/master/setup.sh")]
+ "https://raw.githubusercontent.com/docker-mailserver/docker-mailserver/master/setup.sh"),
+ ("coscli", "coscli", get_coscli_download_url)]
for index, script in enumerate(SCRIPTS):
number = index + 1
total = len(SCRIPTS)
print_order(number, total)
name, filename, url = script
+ # if url is callable, call it
+ if callable(url):
+ url = url()
path = os.path.join(tool_dir, filename)
skip = False
if os.path.exists(path):