@lazycatcloud/lzc-cli 1.1.7 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -11
- package/lib/api.js +71 -36
- package/lib/app/index.js +79 -23
- package/lib/app/lpk_build.js +96 -52
- package/lib/app/lpk_create.js +63 -41
- package/lib/app/lpk_create_generator.js +202 -0
- package/lib/app/lpk_devshell.js +393 -328
- package/lib/app/lpk_devshell_docker.js +211 -0
- package/lib/app/lpk_installer.js +63 -26
- package/lib/app/lpk_log.js +68 -0
- package/lib/app/lpk_status.js +18 -0
- package/lib/app/lpk_uninstall.js +19 -0
- package/lib/appstore/index.js +37 -0
- package/lib/appstore/login.js +137 -0
- package/lib/appstore/publish.js +62 -0
- package/lib/autologin.js +0 -80
- package/lib/box/api/clientapi.js +1322 -0
- package/lib/box/api/empty.js +35 -0
- package/lib/box/check_qemu.js +1 -0
- package/lib/box/index.js +41 -94
- package/lib/box/qemu_vm_mgr.js +208 -239
- package/lib/box/schemes/vm_box_system_debian.json +1 -1
- package/lib/docker-compose.js +1 -2
- package/lib/env.js +23 -142
- package/lib/key.js +1 -0
- package/lib/sdk.js +10 -25
- package/lib/utils.js +156 -233
- package/package.json +19 -11
- package/scripts/cli.js +14 -135
- package/template/_lpk/README.md +31 -0
- package/template/_lpk/exec.sh +19 -0
- package/template/_lpk/golang.manifest.yml.in +16 -0
- package/template/_lpk/lazycat.png +0 -0
- package/template/_lpk/lite.manifest.yml.in +19 -0
- package/template/_lpk/local_devshell/Dockerfile +16 -0
- package/template/_lpk/local_devshell/build.sh +5 -0
- package/template/_lpk/local_devshell/entrypoint.sh +87 -0
- package/template/{_lazycat/debug/shell → _lpk/local_devshell}/sshd_config +8 -8
- package/template/_lpk/manifest.yml.in +0 -1
- package/template/{vue/lzc-build.yml → _lpk/vue.lzc-build.yml.in} +9 -1
- package/template/golang/README.md +0 -2
- package/template/golang/_gitignore +2 -0
- package/template/golang/build.sh +6 -0
- package/template/golang/lazycat.png +0 -0
- package/template/golang/lzc-build.yml +9 -1
- package/template/golang/rego.go +15 -16
- package/template/golang/rego_test.go +13 -0
- package/template/ionic_vue3/lazycat.png +0 -0
- package/template/ionic_vue3/lzc-build.yml +9 -1
- package/template/lite/error_pages/502.html.tpl +13 -0
- package/template/lite/lazycat.png +0 -0
- package/template/lite/lzc-build.yml +60 -0
- package/cmds/app.js +0 -133
- package/cmds/config.js +0 -55
- package/cmds/create.js +0 -55
- package/cmds/dev.js +0 -130
- package/cmds/init.js +0 -125
- package/cmds/log.js +0 -103
- package/cmds/publish.js +0 -116
- package/lib/archiver.js +0 -105
- package/lib/box/hportal.js +0 -120
- package/lib/builder.js +0 -313
- package/lib/dev.js +0 -314
- package/lib/generator.js +0 -146
- package/template/_lazycat/_gitignore +0 -1
- package/template/_lazycat/app-config +0 -1
- package/template/_lazycat/debug/devforward/50x.html +0 -30
- package/template/_lazycat/debug/devforward/Dockerfile +0 -16
- package/template/_lazycat/debug/devforward/docker-compose.override.yml.in +0 -11
- package/template/_lazycat/debug/devforward/entrypoint.sh +0 -10
- package/template/_lazycat/debug/devforward/nginx.conf.template +0 -56
- package/template/_lazycat/debug/devforward/sshd_config +0 -116
- package/template/_lazycat/debug/shell/50x.html +0 -32
- package/template/_lazycat/debug/shell/Dockerfile +0 -18
- package/template/_lazycat/debug/shell/build.sh +0 -15
- package/template/_lazycat/debug/shell/docker-compose.override.yml.in +0 -13
- package/template/_lazycat/debug/shell/entrypoint.sh +0 -12
- package/template/_lazycat/docker-compose.yml.in +0 -15
- package/template/_lazycat/icon.svg +0 -1
- package/template/_lazycat/screenshot.png +0 -0
- package/template/_lpk/sync/Dockerfile +0 -16
- package/template/_lpk/sync/build.sh +0 -5
- package/template/_lpk/sync/entrypoint.sh +0 -8
- package/template/_lpk/sync/sshd_config +0 -117
- package/template/_lpk/sync.manifest.yml.in +0 -3
- package/template/release/golang/Dockerfile +0 -18
- package/template/release/golang/build.sh +0 -13
- package/template/release/ionic_vue3/Dockerfile +0 -10
- package/template/release/ionic_vue3/build.sh +0 -7
- package/template/release/ionic_vue3/docker-compose.yml.in +0 -3
- package/template/release/vue/Dockerfile +0 -10
- package/template/release/vue/build.sh +0 -10
- package/template/release/vue/docker-compose.yml.in +0 -3
- package/template/vue/README.md +0 -29
- package/template/vue/_dockerignore +0 -1
- package/template/vue/babel.config.js +0 -3
- package/template/vue/package.json +0 -43
- package/template/vue/public/favicon.ico +0 -0
- package/template/vue/public/index.html +0 -33
- package/template/vue/src/App.vue +0 -39
- package/template/vue/src/main.js +0 -8
- package/template/vue/src/todo.vue +0 -640
- package/template/vue/src/top-bar.vue +0 -100
- package/template/vue/src/webdav.vue +0 -183
- package/template/vue/vue.config.js +0 -21
package/scripts/cli.js
CHANGED
|
@@ -7,13 +7,14 @@ import yargs from "yargs";
|
|
|
7
7
|
import { hideBin } from "yargs/helpers";
|
|
8
8
|
import chalk from "chalk";
|
|
9
9
|
|
|
10
|
-
import { contextDirname
|
|
11
|
-
import Env from "../lib/env.js";
|
|
10
|
+
import { contextDirname } from "../lib/utils.js";
|
|
12
11
|
import { boxCommand } from "../lib/box/index.js";
|
|
12
|
+
import { appstoreCommand } from "../lib/appstore/index.js";
|
|
13
13
|
import { lpkAppCommand, lpkProjectCommand } from "../lib/app/index.js";
|
|
14
14
|
const pkgInfo = JSON.parse(
|
|
15
15
|
fs.readFileSync(path.join(contextDirname(import.meta.url), "../package.json"))
|
|
16
16
|
);
|
|
17
|
+
import env from "../lib/env.js";
|
|
17
18
|
|
|
18
19
|
// logger level middleware
|
|
19
20
|
const logLevelOriginalFactory = logger.methodFactory;
|
|
@@ -38,8 +39,9 @@ logger.methodFactory = function (methodName, logLevel, loggerName) {
|
|
|
38
39
|
color = chalk.bold.red;
|
|
39
40
|
break;
|
|
40
41
|
}
|
|
42
|
+
const prefix = loggerName ?? methodName;
|
|
41
43
|
rawMethod(
|
|
42
|
-
`[${
|
|
44
|
+
`[${prefix}] ` +
|
|
43
45
|
args
|
|
44
46
|
.map((a) => {
|
|
45
47
|
let res = a;
|
|
@@ -73,150 +75,26 @@ const program = yargs(hideBin(process.argv))
|
|
|
73
75
|
})
|
|
74
76
|
.completion("completion", false);
|
|
75
77
|
|
|
76
|
-
// Set desc to false to create a hidden command. Hidden commands don’t show up
|
|
77
|
-
// in the help output and aren’t available for completion.
|
|
78
|
-
program.command({
|
|
79
|
-
command: "create <name>",
|
|
80
|
-
desc: false,
|
|
81
|
-
aliases: ["c"],
|
|
82
|
-
handler: async ({ name }) => {
|
|
83
|
-
let create = await importDefault("../cmds/create.js");
|
|
84
|
-
await create({ name });
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
program.command({
|
|
89
|
-
command: "init",
|
|
90
|
-
desc: false,
|
|
91
|
-
handler: async () => {
|
|
92
|
-
const { Init } = await import("../cmds/init.js");
|
|
93
|
-
new Init({ cwd: process.cwd() }).create();
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
program.command({
|
|
98
|
-
command: "uninstall",
|
|
99
|
-
desc: false,
|
|
100
|
-
handler: async () => {
|
|
101
|
-
const { uninstall } = await importDefault("../cmds/app.js");
|
|
102
|
-
await uninstall();
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
program.command({
|
|
107
|
-
command: "publish",
|
|
108
|
-
desc: false,
|
|
109
|
-
handler: async () => {
|
|
110
|
-
// 第一步 打包镜像
|
|
111
|
-
const Publisher = await importDefault("../cmds/publish.js");
|
|
112
|
-
const publisher = new Publisher();
|
|
113
|
-
await publisher.run();
|
|
114
|
-
// const b = builder();
|
|
115
|
-
// const contextDir = process.cwd()
|
|
116
|
-
// const dockerfile = Env.get("BUILD_CONTEXT")
|
|
117
|
-
// b.dockerRemoteBuildV2()
|
|
118
|
-
// 第二步
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
program.command({
|
|
123
|
-
command: "deploy",
|
|
124
|
-
desc: false,
|
|
125
|
-
handler: async () => {
|
|
126
|
-
const { deploy } = await importDefault("../cmds/app.js");
|
|
127
|
-
await deploy();
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
program.command({
|
|
132
|
-
command: "build [context]",
|
|
133
|
-
desc: false,
|
|
134
|
-
builder: (args) => {
|
|
135
|
-
args.option("f", {
|
|
136
|
-
alias: "file",
|
|
137
|
-
describe: "Dockerfile",
|
|
138
|
-
default: "Dockerfile",
|
|
139
|
-
});
|
|
140
|
-
},
|
|
141
|
-
handler: async ({ context, file }) => {
|
|
142
|
-
const Builder = await importDefault("../lib/builder.js");
|
|
143
|
-
Env.load(process.cwd());
|
|
144
|
-
const b = new Builder({ env: Env.all });
|
|
145
|
-
b.dockerRemoteBuildV2(context, file);
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
let devSubCommands = [
|
|
150
|
-
{
|
|
151
|
-
command: "forward [addr]",
|
|
152
|
-
desc: "本地端口转发",
|
|
153
|
-
handler: async ({ addr }) => {
|
|
154
|
-
const { dev } = await importDefault("../cmds/dev.js");
|
|
155
|
-
await dev(addr);
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
command: "shell",
|
|
160
|
-
desc: "远程连接盒子",
|
|
161
|
-
builder: (args) => {
|
|
162
|
-
args.option("b", {
|
|
163
|
-
alias: "build",
|
|
164
|
-
desc: "重新部署应用",
|
|
165
|
-
type: "boolean",
|
|
166
|
-
});
|
|
167
|
-
},
|
|
168
|
-
handler: async (args) => {
|
|
169
|
-
const { devShell } = await importDefault("../cmds/dev.js");
|
|
170
|
-
await devShell(args);
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
];
|
|
174
|
-
program.command({
|
|
175
|
-
command: "dev",
|
|
176
|
-
desc: false,
|
|
177
|
-
builder: (args) => {
|
|
178
|
-
args.command(devSubCommands);
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
program.command({
|
|
183
|
-
command: "log [project]",
|
|
184
|
-
desc: false,
|
|
185
|
-
builder: (args) => {
|
|
186
|
-
args.option("u", {
|
|
187
|
-
alias: "user",
|
|
188
|
-
describe: "多实例对应的用户",
|
|
189
|
-
demandOption: false,
|
|
190
|
-
type: "string",
|
|
191
|
-
});
|
|
192
|
-
},
|
|
193
|
-
handler: async (args) => {
|
|
194
|
-
const { monitor } = await importDefault("../cmds/log.js");
|
|
195
|
-
await monitor(args.project, args);
|
|
196
|
-
},
|
|
197
|
-
});
|
|
198
|
-
|
|
199
78
|
program.command({
|
|
200
79
|
command: "config [key] [value]",
|
|
201
80
|
desc: false,
|
|
202
81
|
builder: (args) => {
|
|
203
82
|
args.implies("key", "value");
|
|
204
|
-
args.option("g", {
|
|
205
|
-
alias: "global",
|
|
206
|
-
describe: "global config",
|
|
207
|
-
type: "boolean",
|
|
208
|
-
default: false,
|
|
209
|
-
});
|
|
210
83
|
},
|
|
211
|
-
handler: async (
|
|
212
|
-
|
|
213
|
-
|
|
84
|
+
handler: async ({ key, value }) => {
|
|
85
|
+
if (!key && !value) {
|
|
86
|
+
console.log(env.stringify());
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const pair = Object.fromEntries([[key, value]]);
|
|
90
|
+
env.set(pair, true);
|
|
214
91
|
},
|
|
215
92
|
});
|
|
216
93
|
|
|
217
94
|
boxCommand(program);
|
|
218
95
|
lpkAppCommand(program);
|
|
219
96
|
lpkProjectCommand(program);
|
|
97
|
+
appstoreCommand(program);
|
|
220
98
|
|
|
221
99
|
const parser = program
|
|
222
100
|
.strict()
|
|
@@ -232,6 +110,7 @@ const parser = program
|
|
|
232
110
|
case "box":
|
|
233
111
|
case "app":
|
|
234
112
|
case "project":
|
|
113
|
+
case "appstore":
|
|
235
114
|
program.showHelp();
|
|
236
115
|
return;
|
|
237
116
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
# 懒猫云应用
|
|
3
|
+
|
|
4
|
+
## 构建
|
|
5
|
+
```
|
|
6
|
+
lzc-cli project build -o you-awesome.lpk
|
|
7
|
+
```
|
|
8
|
+
将会在当前的目录下构建出一个 lpk 包。
|
|
9
|
+
|
|
10
|
+
## 安装
|
|
11
|
+
```
|
|
12
|
+
lzc-cli app install you-awesome.lpk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 开发
|
|
16
|
+
```
|
|
17
|
+
lzc-cli project devshell -b
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 成为懒猫云应用开发者
|
|
21
|
+
在 https://developer.lazycat.cloud/ 注册一个开发者帐号,注册开发者帐号后,你可以申请自己的应用,并发布到[商店](https://appstore.lazycat.cloud/)中。
|
|
22
|
+
|
|
23
|
+
## 使用 lzc-cli 发布应用
|
|
24
|
+
在你申请应用成功后,后面的应用升级可以直接通过 `lzc-cli` 进行发布
|
|
25
|
+
`lzc-cli appstore publish <lpk包地址>`
|
|
26
|
+
|
|
27
|
+
# 查看发布的应用
|
|
28
|
+
发布成功后,你可以在 https://appstore.lazycat.cloud/#/shop 中查看你的应用。
|
|
29
|
+
|
|
30
|
+
## 交流和帮助
|
|
31
|
+
你可以在 https://bbs.lazycat.cloud/ 畅所欲言。
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
# 执行 setupscript 脚本
|
|
4
|
+
SETUPSCRIPT=/lzcapp/pkg/content/devshell/setupscript
|
|
5
|
+
if [ -f $SETUPSCRIPT ];then
|
|
6
|
+
. $SETUPSCRIPT
|
|
7
|
+
fi
|
|
8
|
+
|
|
9
|
+
set -e
|
|
10
|
+
|
|
11
|
+
# 切换目录
|
|
12
|
+
cd /lzcapp/cache/devshell
|
|
13
|
+
if command -v $SHELL &> /dev/null
|
|
14
|
+
then
|
|
15
|
+
exec $SHELL
|
|
16
|
+
else
|
|
17
|
+
echo "$SHELL 不存在,执行默认的 /bin/sh"
|
|
18
|
+
exec /bin/sh
|
|
19
|
+
fi
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
lzc-sdk-version: 0.1
|
|
2
|
+
|
|
3
|
+
package: ${package} # app的唯一标识符
|
|
4
|
+
version: ${version} # app的版本
|
|
5
|
+
name: ${name} # app名称
|
|
6
|
+
description: ${description} # app描述
|
|
7
|
+
|
|
8
|
+
license: https://choosealicense.com/licenses/mit/
|
|
9
|
+
homepage: ${homepage} # 出现bug时候提交反馈的地方
|
|
10
|
+
author: ${author} # app author
|
|
11
|
+
|
|
12
|
+
#application作为一个特殊的container运行,对应的service名称为固定的`app`,其他service可以通过此名称与app进行通讯
|
|
13
|
+
application:
|
|
14
|
+
subdomain: ${subdomain} #期望的app域名
|
|
15
|
+
routes:
|
|
16
|
+
- /=exec://3000,/lzcapp/pkg/content/rego -html /lzcapp/pkg/content/index.html
|
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
lzc-sdk-version: 0.1
|
|
2
|
+
|
|
3
|
+
package: ${package} # app的唯一标识符
|
|
4
|
+
version: ${version} # app的版本
|
|
5
|
+
name: ${name} # app名称
|
|
6
|
+
description: ${description} # app描述
|
|
7
|
+
|
|
8
|
+
license: https://choosealicense.com/licenses/mit/
|
|
9
|
+
homepage: ${homepage} # 出现bug时候提交反馈的地方
|
|
10
|
+
author: ${author} # app author
|
|
11
|
+
|
|
12
|
+
#application作为一个特殊的container运行,对应的service名称为固定的`app`,其他service可以通过此名称与app进行通讯
|
|
13
|
+
application:
|
|
14
|
+
subdomain: ${subdomain} #期望的app域名
|
|
15
|
+
routes:
|
|
16
|
+
- /=https://www.linakesi.com
|
|
17
|
+
handlers:
|
|
18
|
+
error_page_templates:
|
|
19
|
+
502: /lzcapp/pkg/content/502.html.tpl
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
FROM alpine:3.16
|
|
2
|
+
|
|
3
|
+
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
|
|
4
|
+
|
|
5
|
+
RUN apk add --no-cache openssh openssl inotify-tools curl tzdata \
|
|
6
|
+
&& echo "root:root" | chpasswd
|
|
7
|
+
|
|
8
|
+
COPY sshd_config /etc/ssh/sshd_config
|
|
9
|
+
COPY entrypoint.sh /entrypoint.sh
|
|
10
|
+
|
|
11
|
+
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
|
12
|
+
echo "Asia/Shanghai" > /etc/timezone && \
|
|
13
|
+
date && \
|
|
14
|
+
chmod +x /entrypoint.sh
|
|
15
|
+
|
|
16
|
+
CMD ["./entrypoint.sh"]
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
ssh-keygen -A
|
|
5
|
+
|
|
6
|
+
free_port(){
|
|
7
|
+
# $1 最小端口
|
|
8
|
+
local port="$1"
|
|
9
|
+
port="${port:-8192}"
|
|
10
|
+
local ports
|
|
11
|
+
ports="$(cut -c 16-19 /proc/net/tcp)"
|
|
12
|
+
while echo "$ports" | grep -q "$(printf '%.4X' "$port")"; do
|
|
13
|
+
port=$((port+1))
|
|
14
|
+
done
|
|
15
|
+
echo $port
|
|
16
|
+
}
|
|
17
|
+
local_ssh_port="$(free_port 22812)"
|
|
18
|
+
|
|
19
|
+
# do not detach (-D), log to stderr (-e), passthrough other arguments
|
|
20
|
+
/usr/sbin/sshd -e -p $local_ssh_port
|
|
21
|
+
|
|
22
|
+
OPTIONS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectionAttempts=3 -o ConnectTimeout=30 -o ServerAliveInterval=5"
|
|
23
|
+
|
|
24
|
+
# 生成key
|
|
25
|
+
cat >/tmp/prepare.sh <<EOF
|
|
26
|
+
#!/bin/sh
|
|
27
|
+
mkdir -p /tmp/$PKGID/.ssh
|
|
28
|
+
|
|
29
|
+
if [ ! -f /tmp/$PKGID/.ssh/id_ed25519 ]; then
|
|
30
|
+
ssh-keygen -t ed25519 -f /tmp/$PKGID/.ssh/id_ed25519 -P ""
|
|
31
|
+
fi
|
|
32
|
+
EOF
|
|
33
|
+
ssh $OPTIONS -p $SDK_PORT -i /sdk/privateKey $SDK_HOST "$(cat /tmp/prepare.sh)"
|
|
34
|
+
|
|
35
|
+
# 复制生成的 key 到本地的 devshell 容器中
|
|
36
|
+
scp -O -i /sdk/privateKey -P $SDK_PORT $OPTIONS $SDK_HOST:/tmp/$PKGID/.ssh/id_ed25519.pub /tmp/id_ed25519.pub
|
|
37
|
+
# 输出到本地 devshell 容器中的 authorized_keys 中
|
|
38
|
+
mkdir -p /root/.ssh
|
|
39
|
+
cat /tmp/id_ed25519.pub >> /root/.ssh/authorized_keys
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# 生成 ssh port
|
|
43
|
+
cat >/tmp/sdk_port.sh <<\EOF
|
|
44
|
+
#!/bin/sh
|
|
45
|
+
free_port(){
|
|
46
|
+
# $1 最小端口
|
|
47
|
+
local port="$1"
|
|
48
|
+
port="${port:-8192}"
|
|
49
|
+
local ports
|
|
50
|
+
ports="$(cut -c 16-19 /proc/net/tcp)"
|
|
51
|
+
while echo "$ports" | grep -q "$(printf '%.4X' "$port")"; do
|
|
52
|
+
port=$((port+1))
|
|
53
|
+
done
|
|
54
|
+
echo $port
|
|
55
|
+
}
|
|
56
|
+
echo "ssh_port:$(free_port 12282)"
|
|
57
|
+
EOF
|
|
58
|
+
ssh_port=$(ssh $OPTIONS -p $SDK_PORT -i /sdk/privateKey $SDK_HOST "$(cat /tmp/sdk_port.sh)" 2>&1 |\
|
|
59
|
+
grep ssh_port | awk -F: '{ print $2 }')
|
|
60
|
+
echo "ssh port: $ssh_port"
|
|
61
|
+
|
|
62
|
+
# inotify script
|
|
63
|
+
cat >/tmp/inotify.sh <<EOF
|
|
64
|
+
#!/bin/sh
|
|
65
|
+
cd /project
|
|
66
|
+
while [ -d /project/$PKGID ]
|
|
67
|
+
do
|
|
68
|
+
cd /project/$PKGID
|
|
69
|
+
inotifywait -q -m -r -e "modify,move,create,delete" --timefmt "%Y-%m-%d %X" --format "%T,%:e,%w%f,$PKGID" .
|
|
70
|
+
done
|
|
71
|
+
EOF
|
|
72
|
+
chmod +x /tmp/inotify.sh
|
|
73
|
+
|
|
74
|
+
# 反代本地的 $local_ssh_port 端口到 sdk 容器中的端口 ssh_port
|
|
75
|
+
cat >/tmp/sshfs.sh <<EOF
|
|
76
|
+
#!/bin/sh
|
|
77
|
+
set -ex
|
|
78
|
+
|
|
79
|
+
mkdir -p /var/lib/box-server/lzcapps/$PKGID/lzcapp/cache/devshell
|
|
80
|
+
|
|
81
|
+
sshfs -v root@localhost:/project/$PKGID /var/lib/box-server/lzcapps/$PKGID/lzcapp/cache/devshell -o allow_other,default_permissions -o direct_io -o dir_cache=no -o IdentityFile=/tmp/$PKGID/.ssh/id_ed25519 -o auto_unmount $OPTIONS -p $ssh_port -o uid=$HOSTUID -o gid=$HOSTGID
|
|
82
|
+
|
|
83
|
+
echo "sshfs running"
|
|
84
|
+
ssh root@localhost $OPTIONS -p $ssh_port -i /tmp/$PKGID/.ssh/id_ed25519 sh -c '/tmp/inotify.sh' | /lzc-cli-backend -inotify
|
|
85
|
+
EOF
|
|
86
|
+
|
|
87
|
+
exec ssh -R 127.0.0.1:$ssh_port:127.0.0.1:$local_ssh_port -p $SDK_PORT $OPTIONS -i /sdk/privateKey $SDK_HOST "$(cat /tmp/sshfs.sh)"
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
# possible, but leave them commented. Uncommented options override the
|
|
11
11
|
# default value.
|
|
12
12
|
|
|
13
|
-
#Port
|
|
13
|
+
# Port 22456
|
|
14
14
|
#AddressFamily any
|
|
15
|
-
|
|
15
|
+
ListenAddress 127.0.0.1
|
|
16
16
|
#ListenAddress ::
|
|
17
17
|
|
|
18
18
|
#HostKey /etc/ssh/ssh_host_rsa_key
|
|
@@ -49,9 +49,9 @@ AuthorizedKeysFile .ssh/authorized_keys
|
|
|
49
49
|
#HostbasedAuthentication no
|
|
50
50
|
# Change to yes if you don't trust ~/.ssh/known_hosts for
|
|
51
51
|
# HostbasedAuthentication
|
|
52
|
-
|
|
52
|
+
IgnoreUserKnownHosts yes
|
|
53
53
|
# Don't read the user's ~/.rhosts and ~/.shosts files
|
|
54
|
-
|
|
54
|
+
IgnoreRhosts yes
|
|
55
55
|
|
|
56
56
|
# To disable tunneled clear text passwords, change to no here!
|
|
57
57
|
PasswordAuthentication no
|
|
@@ -79,9 +79,9 @@ PermitEmptyPasswords no
|
|
|
79
79
|
# If you just want the PAM account and session checks to run without
|
|
80
80
|
# PAM authentication, then enable this but set PasswordAuthentication
|
|
81
81
|
# and KbdInteractiveAuthentication to 'no'.
|
|
82
|
-
#UsePAM no
|
|
82
|
+
# UsePAM no
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
AllowAgentForwarding yes
|
|
85
85
|
# Feel free to re-enable these if your use case requires them.
|
|
86
86
|
AllowTcpForwarding yes
|
|
87
87
|
GatewayPorts yes
|
|
@@ -94,8 +94,8 @@ X11Forwarding no
|
|
|
94
94
|
#TCPKeepAlive yes
|
|
95
95
|
#PermitUserEnvironment no
|
|
96
96
|
#Compression delayed
|
|
97
|
-
ClientAliveInterval
|
|
98
|
-
ClientAliveCountMax
|
|
97
|
+
ClientAliveInterval 5
|
|
98
|
+
ClientAliveCountMax 3
|
|
99
99
|
#UseDNS no
|
|
100
100
|
#PidFile /run/sshd.pid
|
|
101
101
|
#MaxStartups 10:30:100
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
buildscript: npm run build
|
|
7
7
|
|
|
8
8
|
# manifest: 指定 lpk 包的 manifest.yml 文件路径
|
|
9
|
-
manifest: ./manifest.yml
|
|
9
|
+
# manifest: ./lzc-manifest.yml
|
|
10
10
|
|
|
11
11
|
# contentdir: 指定打包的内容,将会打包到 lpk 中
|
|
12
12
|
contentdir: ./dist
|
|
@@ -51,3 +51,11 @@ devshell:
|
|
|
51
51
|
- nodejs
|
|
52
52
|
- vim
|
|
53
53
|
- npm
|
|
54
|
+
# setupscript 每次进入到app container后都会执行的配置脚本
|
|
55
|
+
# - 可以为脚本的路径地址
|
|
56
|
+
# - 如果构建命令简单,也可以直接写 sh 的命令
|
|
57
|
+
# setupscript: export GOPROXY=https://goproxy.cn
|
|
58
|
+
# setupscript: ./setupscript.sh
|
|
59
|
+
setupscript: |
|
|
60
|
+
export GOPROXY=https://goproxy.cn
|
|
61
|
+
export npm_config_registry=https://registry.npmmirror.com
|
package/template/golang/build.sh
CHANGED
|
Binary file
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
buildscript: ./build.sh
|
|
7
7
|
|
|
8
8
|
# manifest: 指定 lpk 包的 manifest.yml 文件路径
|
|
9
|
-
manifest: ./manifest.yml
|
|
9
|
+
# manifest: ./lzc-manifest.yml
|
|
10
10
|
|
|
11
11
|
# contentdir: 指定打包的内容,将会打包到 lpk 中
|
|
12
12
|
contentdir: ./build
|
|
@@ -50,3 +50,11 @@ devshell:
|
|
|
50
50
|
dependencies:
|
|
51
51
|
- go
|
|
52
52
|
- vim
|
|
53
|
+
# setupscript 每次进入到app container后都会执行的配置脚本
|
|
54
|
+
# - 可以为脚本的路径地址
|
|
55
|
+
# - 如果构建命令简单,也可以直接写 sh 的命令
|
|
56
|
+
# setupscript: export GOPROXY=https://goproxy.cn
|
|
57
|
+
# setupscript: ./setupscript.sh
|
|
58
|
+
setupscript: |
|
|
59
|
+
export GOPROXY=https://goproxy.cn
|
|
60
|
+
export npm_config_registry=https://registry.npmmirror.com
|
package/template/golang/rego.go
CHANGED
|
@@ -2,11 +2,11 @@ package main
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"encoding/json"
|
|
5
|
+
"flag"
|
|
5
6
|
"fmt"
|
|
6
7
|
"html/template"
|
|
7
8
|
"log"
|
|
8
9
|
"net/http"
|
|
9
|
-
"os"
|
|
10
10
|
"regexp"
|
|
11
11
|
"strconv"
|
|
12
12
|
)
|
|
@@ -16,11 +16,6 @@ type MatchResultResponse struct {
|
|
|
16
16
|
GroupsName []string `json:"groupsName"`
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
func handler(rw http.ResponseWriter, req *http.Request) {
|
|
20
|
-
t, _ := template.ParseFiles("index.html")
|
|
21
|
-
t.Execute(rw, nil)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
19
|
func regExpHandler(rw http.ResponseWriter, req *http.Request) {
|
|
25
20
|
var matches [][]string
|
|
26
21
|
|
|
@@ -34,7 +29,6 @@ func regExpHandler(rw http.ResponseWriter, req *http.Request) {
|
|
|
34
29
|
log.Printf("Find all : %t", findAllSubmatch)
|
|
35
30
|
|
|
36
31
|
m := &MatchResultResponse{}
|
|
37
|
-
|
|
38
32
|
r, err := regexp.Compile(regexpString)
|
|
39
33
|
if err != nil {
|
|
40
34
|
log.Printf("Invalid RegExp : %s \n", regexpString)
|
|
@@ -61,23 +55,28 @@ func regExpHandler(rw http.ResponseWriter, req *http.Request) {
|
|
|
61
55
|
}
|
|
62
56
|
|
|
63
57
|
func main() {
|
|
58
|
+
indexHtml := flag.String("html", "index.html", "The html template file.")
|
|
59
|
+
port := flag.String("port", "3000", "The http port.")
|
|
60
|
+
flag.Parse()
|
|
61
|
+
|
|
64
62
|
// Main handler (index.html)
|
|
65
|
-
http.HandleFunc("/",
|
|
63
|
+
http.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) {
|
|
64
|
+
t, err := template.ParseFiles(*indexHtml)
|
|
65
|
+
if err != nil {
|
|
66
|
+
log.Fatal(err)
|
|
67
|
+
}
|
|
68
|
+
t.Execute(rw, nil)
|
|
69
|
+
})
|
|
70
|
+
|
|
66
71
|
// Regex testing service
|
|
67
72
|
http.HandleFunc("/test_regexp/", regExpHandler)
|
|
68
73
|
// Static file serving
|
|
69
74
|
http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets"))))
|
|
70
75
|
|
|
71
|
-
port := os.Getenv("PORT")
|
|
72
|
-
if port == "" {
|
|
73
|
-
port = "3000"
|
|
74
|
-
}
|
|
75
|
-
|
|
76
76
|
// Launch server
|
|
77
|
-
|
|
78
|
-
err := http.ListenAndServe(":"
|
|
77
|
+
log.Printf("server listen to %s \n", ":"+*port)
|
|
78
|
+
err := http.ListenAndServe(":"+*port, nil)
|
|
79
79
|
if err != nil {
|
|
80
80
|
log.Fatal(err)
|
|
81
81
|
}
|
|
82
|
-
|
|
83
82
|
}
|
|
Binary file
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
buildscript: npm run build
|
|
7
7
|
|
|
8
8
|
# manifest: 指定 lpk 包的 manifest.yml 文件路径
|
|
9
|
-
manifest: ./manifest.yml
|
|
9
|
+
# manifest: ./lzc-manifest.yml
|
|
10
10
|
|
|
11
11
|
# contentdir: 指定打包的内容,将会打包到 lpk 中
|
|
12
12
|
contentdir: ./dist
|
|
@@ -51,3 +51,11 @@ devshell:
|
|
|
51
51
|
- nodejs
|
|
52
52
|
- vim
|
|
53
53
|
- npm
|
|
54
|
+
# setupscript 每次进入到app container后都会执行的配置脚本
|
|
55
|
+
# - 可以为脚本的路径地址
|
|
56
|
+
# - 如果构建命令简单,也可以直接写 sh 的命令
|
|
57
|
+
# setupscript: export GOPROXY=https://goproxy.cn
|
|
58
|
+
# setupscript: ./setupscript.sh
|
|
59
|
+
setupscript: |
|
|
60
|
+
export GOPROXY=https://goproxy.cn
|
|
61
|
+
export npm_config_registry=https://registry.npmmirror.com
|
|
Binary file
|