From 1779b1821e1021b523d754eca250b28c7e233db7 Mon Sep 17 00:00:00 2001 From: Codepy <1942171924@qq.com> Date: Tue, 9 Apr 2024 19:18:04 +0800 Subject: [PATCH 1/7] Your commit message --- .gitignore | 2 +- .idea/.gitignore | 3 +++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 ++++++++ .idea/quick-panel.iml | 10 ++++++++++ .idea/vcs.xml | 6 ++++++ 7 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/quick-panel.iml create mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 5d947ca..0966463 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,7 @@ bin-release/ *.air *.ipa *.apk - +.venv/ # Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties` # should NOT be excluded as they contain compiler settings and other important # information for Eclipse / Flash Builder. diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..252e9a4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0dfac63 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/quick-panel.iml b/.idea/quick-panel.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/.idea/quick-panel.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file -- Gitee From f681dfb5158b9e784e81d7aae3d1a8ea3e499877 Mon Sep 17 00:00:00 2001 From: Codepy <1942171924@qq.com> Date: Tue, 9 Apr 2024 20:39:10 +0800 Subject: [PATCH 2/7] =?UTF-8?q?upd:=E6=9B=B4=E6=96=B0=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 3 ++ .../__pycache__/install.cpython-36.pyc | Bin 0 -> 347 bytes app/controller/install.py | 4 ++ app/utils/File.py | 9 ++++ app/utils/System.py | 4 ++ app/utils/__pycache__/File.cpython-36.pyc | Bin 0 -> 325 bytes app/utils/__pycache__/System.cpython-36.pyc | Bin 0 -> 298 bytes main.py | 39 ++++++++++++++++++ 8 files changed, 59 insertions(+) create mode 100644 app/controller/__pycache__/install.cpython-36.pyc create mode 100644 app/controller/install.py create mode 100644 app/utils/File.py create mode 100644 app/utils/System.py create mode 100644 app/utils/__pycache__/File.cpython-36.pyc create mode 100644 app/utils/__pycache__/System.cpython-36.pyc create mode 100644 main.py diff --git a/.idea/misc.xml b/.idea/misc.xml index 252e9a4..d72b3f9 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,7 @@ + + \ No newline at end of file diff --git a/app/controller/__pycache__/install.cpython-36.pyc b/app/controller/__pycache__/install.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..50118b4a59d76f26e43e8ea6096d1cdaf015c848 GIT binary patch literal 347 zcmYjMO-sW-5S>kvSfoWSf`1{02F06*iuG0~O7IdE%9346+RcYMn?pcP`e*u=_Ug&M z;K|uk#DVu_-p)LB=3+WMyg560E&$+@@D~A9w*)*Tk|3Fe4ci3yNCtBB0eL7{21)ou zU08be5RBMkPQVF~CD%K=!7I=-TPA@Eu+NXy%C4|StEyEkDwQx7@8u3mNVf0C`6Yis zWspBC7PE7HuW)Odmba!^8&UDh3UgOlUNlnim#!?fvsTnfbJ4c+SXfPT88Vp+@3`OJU6=c_4*>Wg{0%2{PQU??2F)6%KyxkLp<$K{c{G`I+@lg_sfUM=M`D1TvttXpm5b7$*C>C}^Hq;gJn z!8RyI^yi^_jp9n_)Pgw?u#E2!{5EN-PdjY%ruHB8$cXvrvejK<&eGbL-sb!lBnU>E literal 0 HcmV?d00001 diff --git a/app/utils/__pycache__/System.cpython-36.pyc b/app/utils/__pycache__/System.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..edad6602355ff96ebf8b49996e0315bb9f75c7bb GIT binary patch literal 298 zcmYL^!Ab)$5QZmdEsIck(T7;1E#gh26zfG6im-So10`(IvNmbbBzx#tU&dG3t0!N< zQzu*0f&b$lW|En?8xAjTrq`Qi0Qe&P1t&Krg)4#t$uz7$a@qTU6_c!ly#GxVSXPO@ z!N@E~AtOY1WA8wnY?<>mb6UiW^`;$!V~EOpg6~sTho53`kFP=bfGxh+=3J*的形式指定参数,默认接收到的参数类型是string + +# 检测安装 +if f.Had("data/config/panel.json"): + print("已安装") + + + @app.route("/index/", ) + def index(id): + if id == 1: + return 'first' + elif id == 2: + return 'second' + elif id == 3: + return 'thrid' + else: + return 'hello world!' + + + if __name__ == '__main__': + app.run() +else: + print("未安装面板") + install = input("是否安装面板(y/n):") + if install == "y": + # 安装面板 + print("开始安装面板...") + print(paninstall.install()) + else: + print("退出程序") + + + -- Gitee From 95be88f350905ffb66425d5b6faab18bb1463956 Mon Sep 17 00:00:00 2001 From: Codepy <1942171924@qq.com> Date: Tue, 9 Apr 2024 12:40:51 +0000 Subject: [PATCH 3/7] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 data/.keep diff --git a/data/.keep b/data/.keep new file mode 100644 index 0000000..e69de29 -- Gitee From 12b74f3415b605fbe648a3c9377f337f4fa37515 Mon Sep 17 00:00:00 2001 From: Codepy <1942171924@qq.com> Date: Tue, 9 Apr 2024 12:41:05 +0000 Subject: [PATCH 4/7] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/config/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 data/config/.keep diff --git a/data/config/.keep b/data/config/.keep new file mode 100644 index 0000000..e69de29 -- Gitee From f0fa609aeeb39cb7a63109002a57fb67be7b381d Mon Sep 17 00:00:00 2001 From: Codepy <1942171924@qq.com> Date: Tue, 9 Apr 2024 12:41:14 +0000 Subject: [PATCH 5/7] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20data?= =?UTF-8?q?/.keep?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 data/.keep diff --git a/data/.keep b/data/.keep deleted file mode 100644 index e69de29..0000000 -- Gitee From c1b76ce79c9dd303cca59a6ffb93cb8d6368b6d3 Mon Sep 17 00:00:00 2001 From: Codepy <1942171924@qq.com> Date: Tue, 9 Apr 2024 21:06:03 +0800 Subject: [PATCH 6/7] =?UTF-8?q?upd=EF=BC=9A=E6=96=B0=E5=A2=9E=E5=AE=89?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/install.py | 29 ++++++++++++++++++++++++++++- app/utils/System.py | 4 ++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app/controller/install.py b/app/controller/install.py index 284cc0b..c399637 100644 --- a/app/controller/install.py +++ b/app/controller/install.py @@ -1,4 +1,31 @@ import app.utils.System as sy +import os +import json +import random +import string +import hashlib + def install(): system = sy.get_system_name() - return system \ No newline at end of file + print("正在安装", system, "系统版本的面板...") + + # 生成数据 + # 生成随机字母 + username = ''.join(random.choices(string.ascii_letters, k=5)) + pw = ''.join(random.choices(string.ascii_letters + string.digits, k=8)) + port = random.randint(8888, 8900) + ip = sy.get_system_ip() + print("用户名:", username, "\n密码:", pw, "\n端口:", port) + print("面板访问地址: http://" + ip + ":" + str(port) + "/") + + # 写入文件 + json_data = {username: hashlib.sha256(pw.encode()).hexdigest(), "port": port} + with open("./data/config/panel.json", 'w') as file: + json.dump(json_data, file) + + if system == "Windows": + pass + else: + # 设置文件权限为root可读写,其它用户无法读写 + os.chmod("./data/config/panel.json", 0o600) + print("安装完成") diff --git a/app/utils/System.py b/app/utils/System.py index 8546683..2867ccc 100644 --- a/app/utils/System.py +++ b/app/utils/System.py @@ -1,4 +1,8 @@ import platform +import socket def get_system_name(): return platform.system() + +def get_system_ip(): + return socket.gethostbyname(socket.gethostname()) \ No newline at end of file -- Gitee From aa798c0987d0eb2e550f3a33cb4dcfb0b21590b3 Mon Sep 17 00:00:00 2001 From: Codepy <1942171924@qq.com> Date: Tue, 9 Apr 2024 21:16:43 +0800 Subject: [PATCH 7/7] =?UTF-8?q?upd=EF=BC=9A=E6=96=B0=E5=A2=9Ewin=E4=B8=8B?= =?UTF-8?q?=E6=9D=83=E9=99=90=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/install.py | 14 +++++++++++++- main.py | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/controller/install.py b/app/controller/install.py index c399637..442989f 100644 --- a/app/controller/install.py +++ b/app/controller/install.py @@ -24,7 +24,19 @@ def install(): json.dump(json_data, file) if system == "Windows": - pass + import subprocess + # 构建命令 + command = ['icacls', "./data/config/panel.json", '/grant', '*S-1-5-32-544:(OI)(CI)F'] + + # 执行命令 + process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + output, error = process.communicate() + + # 打印输出结果 + if process.returncode == 0: + print("文件权限设置成功") + else: + print("文件权限设置失败:", error.decode('utf-8')) else: # 设置文件权限为root可读写,其它用户无法读写 os.chmod("./data/config/panel.json", 0o600) diff --git a/main.py b/main.py index 23e69d0..9426731 100644 --- a/main.py +++ b/main.py @@ -31,7 +31,7 @@ else: if install == "y": # 安装面板 print("开始安装面板...") - print(paninstall.install()) + paninstall.install() else: print("退出程序") -- Gitee