Skip to content

Commit 800a2cb

Browse files
committed
Add cli
1 parent af8bad8 commit 800a2cb

File tree

3 files changed

+24
-38
lines changed

3 files changed

+24
-38
lines changed

apphub/src/cli/apphub_cli.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,26 @@ def setconfig(section, key, value):
5555
except Exception as e:
5656
raise click.ClickException(str(e))
5757

58+
# 新增 setsysconfig 方法
59+
@cli.command()
60+
@click.option('--section', required=True, help='The section name')
61+
@click.option('--key', required=True, help='The key name')
62+
@click.option('--value', required=True, help='The value of the key')
63+
def setsysconfig(section, key, value):
64+
"""Set a system config value"""
65+
try:
66+
system_config_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../config/system.ini'))
67+
config = configparser.ConfigParser()
68+
config.read(system_config_path, encoding="utf-8")
69+
if not config.has_section(section):
70+
config.add_section(section)
71+
config.set(section, key, value)
72+
with open(system_config_path, 'w', encoding="utf-8") as configfile:
73+
config.write(configfile)
74+
click.echo(f"Set [{section}] {key}={value} in system.ini successfully.")
75+
except Exception as e:
76+
raise click.ClickException(str(e))
77+
5878
@cli.command()
5979
@click.option('--section', help='The section name')
6080
@click.option('--key', help='The key name')

apphub/src/config/system.ini

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ path = /websoft9/media/json/
66

77
[volume_backup]
88
repopath = /data/backup/restic-repo
9-
hostname = websoft9-backup-host
9+
hostname = websoft9-backup-host
1010
image = restic/restic:latest
1111

1212
[max_apps]
@@ -16,8 +16,9 @@ key =
1616
keys = wordpress,wordpresspro
1717

1818
[php_apps]
19-
keys =wordpress,zentao,passbolt,moodle,mautic,espocrm,ttrss,discuz,mixpost,nextcloud,typo3,zabbix,magento,suitecrm,pimcore,phpmyadmin,filerun,snipeit,joomla,humhub,drupal,dolibarr,akaunting,akeneo,vtiger,discuzq
19+
keys = wordpress,zentao,passbolt,moodle,mautic,espocrm,ttrss,discuz,mixpost,nextcloud,typo3,zabbix,magento,suitecrm,pimcore,phpmyadmin,filerun,snipeit,joomla,humhub,drupal,dolibarr,akaunting,akeneo,vtiger,discuzq
2020

2121
[webhook]
2222
wechat = https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9393241f-05b6-45a2-a3e7-b3ab5275cf09
23-
monitor_api = https://monitor-gnfarrpanp.cn-zhangjiakou-vpc.fcapp.run
23+
monitor_api = https://monitor-gnfarrpanp.cn-zhangjiakou-vpc.fcapp.run
24+

apphub/test_config.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)