Refactor: change copyright info 2

This commit is contained in:
Suwings 2022-07-28 11:55:48 +08:00
parent cdc399e595
commit a135e55afe
80 changed files with 81 additions and 513 deletions

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { $t } from "./i18n";
import { getVersion, initVersionManager } from "./service/version";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import fs from "fs-extra";
import path from "path";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
export default class GlobalVariable {
public static readonly map = new Map<string, any>();

View File

@ -1,6 +1,5 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { Socket } from "socket.io";
// 应用实例数据流转发适配器

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
// Using SLT (Server List Ping) provided by Minecraft.
// Since it is part of the protocol it is always enabled contrary to Query

View File

@ -1,6 +1,5 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { ChildProcess, exec, execSync } from "child_process";
import os from "os";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
interface IMap {
size: number;

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import os from "os";
import osUtils from "os-utils";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import path from "path";
import fs from "fs-extra";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
export function configureEntityParams(self: any, args: any, key: string, typeFn?: Function): any {
const selfDefaultValue = self[key] ?? null;

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import os from "os";
import path from "path";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
export default class InstanceCommand {
constructor(public info?: string) {}

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
export function commandStringToArray(cmd: string) {
const QUOTES_KEY = "{quotes}";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../instance/instance";
import InstanceCommand from "./base/command";

View File

@ -1,6 +1,5 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import path from "path";
import fs from "fs-extra";
import Instance from "../instance/instance";

View File

@ -1,23 +1,4 @@
/*
Copyright (C) 2022 RimuruChan <RealSprite233@outlook.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
According to the AGPL, it is forbidden to delete all copyright notices,
and if you modify the source code, you must open source the
modified source code.
(C) 2022 RimuruChan <RealSprite233@outlook.com>
/ GNU Affero
3
AGPL
https://mcsmanager.com/ 阅读用户协议,申请闭源开发授权等。
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com> and RimuruChan
import Instance from "../../instance/instance";
import InstanceCommand from "../base/command";

View File

@ -1,23 +1,4 @@
/*
Copyright (C) 2022 Suwings <Suwings@outlook.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
According to the AGPL, it is forbidden to delete all copyright notices,
and if you modify the source code, you must open source the
modified source code.
(C) 2022 Suwings <Suwings@outlook.com>
/ GNU Affero
3
AGPL
https://mcsmanager.com/ 阅读用户协议,申请闭源开发授权等。
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../../instance/instance";
import InstanceCommand from "../base/command";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../../instance/instance";
import { encode } from "iconv-lite";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../../instance/instance";
import InstanceCommand from "../base/command";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../../instance/instance";
import InstanceCommand from "../base/command";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import os from "os";
import Instance from "../../instance/instance";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../../instance/instance";
import InstanceCommand from "../base/command";

View File

@ -1,6 +1,5 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { killProcess } from "../../../common/process_tools";
import { ChildProcess, exec, spawn } from "child_process";
import logger from "../../../service/log";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../instance/instance";
import InstanceCommand from "./base/command";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../instance/instance";
import InstanceCommand from "./base/command";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import InstanceCommand from "./base/command";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { ProcessConfig } from "../instance/process_config";
import pidusage from "pidusage";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import os from "os";
import Instance from "../../instance/instance";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../../instance/instance";
import InstanceCommand from "../base/command";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../instance/instance";
import InstanceCommand from "./base/command";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../instance/instance";
import logger from "../../service/log";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../instance/instance";
import InstanceCommand from "./base/command";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { ILifeCycleTask } from "../../instance/life_cycle";
import Instance from "../../instance/instance";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { ILifeCycleTask } from "../../instance/life_cycle";
import Instance from "../../instance/instance";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../instance/instance";
import InstanceCommand from "./base/command";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { v4 } from "uuid";
import StorageSubsystem from "../common/system_storage";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { Socket } from "socket.io";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "./instance";
import { IDockerConfig } from "./interface";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import iconv from "iconv-lite";
import path from "path";

View File

@ -1,6 +1,5 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { EventEmitter } from "events";
// interface of docker config

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "./instance";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
export interface IExecutable {
exec: (a: any, b?: any) => Promise<any>;

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import yaml from "yaml";
import properties from "properties";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../instance/instance";
import InstanceCommand from "../commands/base/command";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
const dgram = require("dgram");

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Instance from "../instance/instance";
import InstanceCommand from "../commands/base/command";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import i18next from "i18next";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import fs from "fs-extra";
import * as protocol from "../service/protocol";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { routerApp } from "../service/router";
import * as protocol from "../service/protocol";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { DockerManager } from "../service/docker_service";
import * as protocol from "../service/protocol";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import * as protocol from "../service/protocol";
import { routerApp } from "../service/router";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Router from "@koa/router";
import fs from "fs-extra";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import * as protocol from "../service/protocol";
import { routerApp } from "../service/router";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import path from "path";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { routerApp } from "../service/router";
import { missionPassport } from "../service/mission_passport";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { routerApp } from "../service/router";
import * as protocol from "../service/protocol";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import * as protocol from "../service/protocol";
import { routerApp } from "../service/router";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import dockerode from "dockerode";
import Docker from "dockerode";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import InstanceSubsystem from "../service/system_instance";
import FileManager from "./system_file";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import Koa from "koa";
import koaBody from "koa-body";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import os from "os";
import fs from "fs-extra";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import InstanceConfig from "../entity/instance/Instance_config";
export interface IInstanceDetail {

View File

@ -1,6 +1,5 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import fs from "fs-extra";
import * as log4js from "log4js";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
// 任务接口
interface IMission {

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { globalConfiguration } from "../entity/config";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { Socket } from "socket.io";
import RouterContext from "../entity/ctx";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import { EventEmitter } from "events";
import { Socket } from "socket.io";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import path from "path";
import fs from "fs-extra";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import fs from "fs-extra";
import path from "path";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import schedule from "node-schedule";
import InstanceSubsystem from "./system_instance";

View File

@ -1,6 +1,5 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import readline from "readline";
import * as protocol from "./protocol";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
import * as fs from "fs-extra";
import GlobalVariable from "../common/global_variable";

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
export function checkFileName(fileName: string) {
const blackKeys = ["/", "\\", "|", "?", "*", ">", "<", ";", '"'];

View File

@ -1,6 +1,4 @@
/*
Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
*/
// Copyright (C) 2022 MCSManager Team <mcsmanager-dev@outlook.com>
declare module "properties" {
function parse(data: string, options?: any): any;

View File

@ -1 +0,0 @@
你好中国123ABC你好

View File

@ -1,116 +0,0 @@
var Docker = require("dockerode");
// const path = require("path")
var localDocker = new Docker();
// console.log("PATH:", __dirname)
async function main() {
// 镜像列表
// const res = await localDocker.listImages();
// console.log(res)
// [
// {
// Containers: -1,
// Created: 1628797142,
// Id: 'sha256:f4489eef8885a8c994a0e9f5094b19596df58a89d1b18471ebb46cfbb84314c9',
// Labels: null,
// ParentId: '',
// RepoDigests: [
// 'openjdk@sha256:ad240a929c34ed18ca8a4e1eec679813513391e74e882b15d69d9131ff72ec41'
// ],
// RepoTags: [ 'openjdk:16.0.2' ],
// SharedSize: -1,
// Size: 466931413,
// VirtualSize: 466931413
// }
// ]
// 创建镜像
try {
// const res2 = await localDocker.buildImage(path.join(__dirname, "Dockerfile"), { t: "test1" });
const res2 = await localDocker.buildImage(
{
context: "/home/suwings/Project2104-Daemon/test_file/test_docker",
src: ["Dockerfile"]
},
{ t: "test1:16" }
);
console.log("创建指令发送");
} catch (error) {
console.log("创建错误", error);
}
// 删除镜像
// await localDocker.getImage("test1").remove();
// 利用镜像创建容器
// const container = await localDocker.createContainer({
// Image: "openjdk:16.0.2",
// AttachStdin: true,
// AttachStdout: true,
// AttachStderr: true,
// Tty: true,
// User: `${process.getuid()}:${process.getgid()}`,
// WorkingDir: "/workspace/",
// Cmd: ["java", "-jar", "paper-1.17.1-186.jar"],
// OpenStdin: true,
// StdinOnce: false,
// HostConfig: {
// Binds: ["/home/suwings/dockernode/test_file/:/workspace/"]
// }
// });
// // 启动容器
// await container.start();
// const stream = await container.attach({ stream: true, stdout: true, stderr: true, stdin: true });
// stream.on("data", (data) => {
// process.stdout.write("[Container]" + data.toString());
// });
// stream.on("error", (data) => {
// console.log("[Container error]", data.toString());
// });
// stream.on("close", async () => {
// console.log("[Container close] ----------------");
// });
// // stream.write("help\n")
// // stream.write("java -jar spigot-1.16.5.jar\n")
// // stream.write("exit\n")
// // 等待容器退出
// container.wait(async () => {
// console.log("-------------------- container.wait() --------------------");
// await container.remove();
// });
// setTimeout(() => {
// stream.write("stop\n");
// }, 10000);
// setTimeout(async () => {
// await container.kill();
// await container.remove();
// }, 3000);
// [
// {
// Id: '2882659c40c60cd1ebca058b8b65014887a7126f7cda7c1309c88b510fc4852d',
// Names: [ '/musing_dirac' ],
// Image: 'openjdk:16.0.2',
// ImageID: 'sha256:f4489eef8885a8c994a0e9f5094b19596df58a89d1b18471ebb46cfbb84314c9',
// Command: '/bin/bash',
// Created: 1629017421,
// Ports: [],
// Labels: {},
// State: 'running',
// Status: 'Up Less than a second',
// HostConfig: { NetworkMode: 'default' },
// NetworkSettings: { Networks: [Object] },
// Mounts: []
// }
// ]
// const res3 = await localDocker.listContainers()
// console.log("容器列表:", res3)
}
main();

View File

View File

@ -1,75 +0,0 @@
const path = require("path");
const fs = require("fs");
const compressing = require("compressing");
const fsex = require("fs-extra");
// const os = require('os');
// 此处使用临时解决方案
// let SYSTEM_CODE = null;
// if (os.platform() == "win32")
const SYSTEM_CODE = "GBK";
// else
// SYSTEM_CODE = 'UTF-8';
// 任务参数获取
const argv = process.argv;
const realArgv = argv.filter((val, index) => {
return index >= 2;
});
// 特殊文件操作子进程
// 为了防止用户解压/压缩/删除 文件数量过大导致整个面板反应速度下降或者无反应
// 所有耗时的文件操作(除非异步)均写入此。
if (realArgv.length >= 1) {
const ACTION = realArgv[0];
//解压子进程开始执行
if (ACTION === "extract") {
//执行解压
const absPath = realArgv[1];
//目录名与原文件同名
const zipExtractDir = path.normalize(path.dirname(absPath) + "/解压文件_" + path.basename(absPath, path.extname(absPath)));
// 创建目标目录
try {
fs.mkdirSync(zipExtractDir);
} catch (ignore) {
// 忽略创建目录错误
}
// 进行解压操作
compressing.zip
.uncompress(absPath, zipExtractDir, {
zipFileNameEncoding: SYSTEM_CODE
})
.then(() => {
// BUG note: 此处无法使用 MCSM 全局变量,此为额外任务子进程。感谢 @ColorfulGhost
console.log("解压任务", absPath, "成功.");
})
.catch((err) => {
console.log("解压任务", absPath, "失败,原因:\n", err);
});
}
// 文件删除子进程开始执行
// 此进程用于删除大量文件时使用,以防造成面板卡顿
if (ACTION === "remove") {
fsex.removeSync(realArgv[1]);
}
// 文件压缩子进程
// 此压缩库支持异步写法,但以防不测,依然列入子进程
if (ACTION === "compress") {
const absPath = realArgv[1];
const compressZipPath = path.normalize(path.dirname(absPath) + "/压缩文件_" + path.basename(absPath) + ".zip");
// 进行压缩操作
compressing.zip
.compressDir(absPath, compressZipPath, {
zipFileNameEncoding: SYSTEM_CODE
})
.then(() => {
console.log("压缩任务", absPath, "成功.");
})
.catch((err) => {
console.log("压缩任务", absPath, "失败,原因:\n", err);
});
}
}

View File

@ -1,48 +0,0 @@
/*
* @Author: Copyright(c) 2021 Suwings
* @Date: 2021-08-24 19:34:48
* @LastEditTime: 2021-08-24 20:12:02
* @Description:
* @Projcet: MCSManager Daemon
*/
import child_process from "child_process";
function zipFiles(zipName: string, files: string[]) {
const cmd = `7z.exe a ${zipName} ${files.join(" ")}`.split(" ");
console.log(`[7zip 压缩任务] ${cmd}`);
return new Promise((resolve, reject) => {
const p = cmd.splice(1);
const process = child_process.spawn(cmd[0], [...p], {
cwd: "../7zip/"
});
if (!process || !process.pid) return reject(false);
process.on("exit", (code) => {
if (code) return reject(false);
return resolve(true);
});
});
}
async function unzipArchive(sourceZip: string, destDir: string) {
// ./7z.exe x archive.zip -oD:\7-Zip
const cmd = `7z.exe x ${sourceZip} -o${destDir}`.split(" ");
console.log(`[7zip 解压任务] ${cmd.join(" ")}`);
return new Promise((resolve, reject) => {
const process = child_process.spawn(cmd[0], [cmd[1], cmd[2], cmd[3]], {
cwd: "../7zip/"
});
if (!process || !process.pid) return reject(false);
process.on("exit", (code) => {
if (code) return reject(false);
return resolve(true);
});
});
}
async function main() {
await zipFiles("a.zip", ["D:/MineSuwings/Project2104-Daemon/test_file"]);
await unzipArchive("a.zip", "D:/MineSuwings/Project2104-Daemon/test_file/a");
}
main();

View File

@ -1,17 +0,0 @@
/*
* @Author: Copyright(c) 2021 Suwings
* @Date: 2021-08-24 20:05:46
* @LastEditTime: 2021-08-24 20:10:03
* @Description:
* @Projcet: MCSManager Daemon
*/
const zlib = require("zlib");
const fs = require("fs");
// const Buffer = zlib.unzipSync(fs.readFileSync("abc.zip"));
let gzip = zlib.createGunzip();
let inFile = fs.createReadStream("./a.zip");
let out = fs.createWriteStream("./2.txt");
inFile.pipe(gzip).pipe(out);