Fix update cmd bug

This commit is contained in:
iwumingz 2022-04-10 10:24:44 +08:00
parent 3c02b2983b
commit 3ca1a8d4be
4 changed files with 19 additions and 13 deletions

View File

@ -8,6 +8,10 @@ bash <(curl -fsL "https://raw.githubusercontent.com/iwumingz/sycgram/main/instal
``` ```
## 指令说明
- 使用`-help`查看指令列表
## 迁移备份 ## 迁移备份
@ -19,7 +23,7 @@ bash <(curl -fsL "https://raw.githubusercontent.com/iwumingz/sycgram/main/instal
## 自定义指令前缀及指令别名 ## 自定义指令前缀及指令别名
- 每次通过脚本更新【建议使用指令更新】都会覆盖本地的`command.yml`,原文件会备份到`command目录` - 每次通过脚本更新都会覆盖本地的`command.yml`,原文件会备份到`command目录`。指令更新,则会本地的`command.yml`不会被覆盖
- 可以通过指令修改前缀和别名 - 可以通过指令修改前缀和别名
- 指令别名只支持单别名和源名(不再支持多别名) - 指令别名只支持单别名和源名(不再支持多别名)

View File

@ -144,7 +144,7 @@ install_sycgram(){
--hostname ${CONTAINER_NAME} \ --hostname ${CONTAINER_NAME} \
-v ${PROJECT_PATH}/data:/sycgram/data \ -v ${PROJECT_PATH}/data:/sycgram/data \
-v /var/run/docker.sock:/var/run/docker.sock \ -v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/local/bin/docker \ -v /usr/bin/docker:/usr/bin/docker \
${GITHUB_IMAGE_PATH}:latest ${GITHUB_IMAGE_PATH}:latest
} }

View File

@ -1,5 +1,6 @@
import asyncio import asyncio
import sys import sys
from subprocess import PIPE, Popen
from core import command from core import command
from loguru import logger from loguru import logger
@ -7,7 +8,7 @@ from pyrogram import Client
from pyrogram.types import Message from pyrogram.types import Message
from tools.constants import (SYCGRAM, SYCGRAM_ERROR, SYCGRAM_INFO, from tools.constants import (SYCGRAM, SYCGRAM_ERROR, SYCGRAM_INFO,
SYCGRAM_WARNING, UPDATE_CMD) SYCGRAM_WARNING, UPDATE_CMD)
from tools.helpers import Parameters, basher, show_cmd_tip, show_exception from tools.helpers import Parameters, show_cmd_tip, show_exception
from tools.updates import (get_alias_of_cmds, pull_and_update_command_yml, from tools.updates import (get_alias_of_cmds, pull_and_update_command_yml,
reset_cmd_alias, update_cmd_alias, reset_cmd_alias, update_cmd_alias,
update_cmd_prefix) update_cmd_prefix)
@ -28,7 +29,8 @@ async def update(_: Client, msg: Message):
await msg.edit_text(text, parse_mode='md') await msg.edit_text(text, parse_mode='md')
try: try:
await pull_and_update_command_yml() await pull_and_update_command_yml()
_ = await basher(UPDATE_CMD, timeout=60) p = Popen(UPDATE_CMD, stdout=PIPE, shell=True)
p.communicate()
except asyncio.exceptions.TimeoutError: except asyncio.exceptions.TimeoutError:
text = f"**{SYCGRAM_WARNING}**\n> # `Update Timeout`" text = f"**{SYCGRAM_WARNING}**\n> # `Update Timeout`"
except Exception as e: except Exception as e:

View File

@ -7,14 +7,14 @@ SYCGRAM_ERROR: str = f"{SYCGRAM.title()} | ERROR"
SYCGRAM_WARNING: str = f"{SYCGRAM.title()} | WARNING" SYCGRAM_WARNING: str = f"{SYCGRAM.title()} | WARNING"
COMMAND_YML: str = './data/command.yml' COMMAND_YML: str = './data/command.yml'
CMD_YML_REMOTE: str = "https://raw.githubusercontent.com/iwumingz/sycgram/main/data/command.yml" CMD_YML_REMOTE: str = "https://raw.githubusercontent.com/iwumingz/sycgram/main/data/command.yml"
UPDATE_CMD: str = f""" UPDATE_CMD: str = "docker run --rm " \
docker run --rm \ "-v /var/run/docker.sock:/var/run/docker.sock " \
-v /var/run/docker.sock:/var/run/docker.sock \ "containrrr/watchtower " \
containrrr/watchtower \ "--trace " \
--cleanup \ "--cleanup " \
--run-once \ "--run-once " \
{SYCGRAM} f"{SYCGRAM}"
"""
# ------------- Load -------------- # ------------- Load --------------
DOWNLOAD_PATH: str = './data/download/' DOWNLOAD_PATH: str = './data/download/'
@ -29,7 +29,7 @@ HTTP_HEADERS: Dict[str, str] = {
# ------------- speedtest -------------- # ------------- speedtest --------------
SPEEDTEST_PATH_FILE: str = './data/speedtest' SPEEDTEST_PATH_FILE: str = './data/speedtest'
SPEEDTEST_INSTALL_URL: str = "https://install.speedtest.net/app/cli/ookla-speedtest-1.1.1-linux-$(uname -m).tgz" SPEEDTEST_INSTALL_URL: str = "https://install.speedtest.net/app/cli/ookla-speedtest-1.1.1-linux-$(uname -m).tgz"
INSTALL_SPEEDTEST: str = f"""wget -qO- "{SPEEDTEST_INSTALL_URL}" | tar zx -C ./data speedtest""" INSTALL_SPEEDTEST: str = f"""wget - qO - "{SPEEDTEST_INSTALL_URL}" | tar zx - C ./data speedtest"""
SPEEDTEST_RUN: str = f'{SPEEDTEST_PATH_FILE} --accept-license --accept-gdpr -f json' SPEEDTEST_RUN: str = f'{SPEEDTEST_PATH_FILE} --accept-license --accept-gdpr -f json'
# ------------- sticker -------------- # ------------- sticker --------------