From 763f0d43d9f48587015dea6fa744bbaabf846d9f Mon Sep 17 00:00:00 2001 From: shylinux Date: Fri, 10 Mar 2023 22:14:45 +0800 Subject: [PATCH] opt some --- Makefile | 22 +++++++++--------- README.md | 11 ++------- etc/exit.shy | 7 ------ etc/init.shy | 63 ++++++-------------------------------------------- src/webview.go | 22 ++++-------------- 5 files changed, 24 insertions(+), 101 deletions(-) diff --git a/Makefile b/Makefile index b1544ff6..01b306bc 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,22 @@ -export CGO_ENABLED=0 - +publish = usr/publish binarys = bin/ice.bin +version = src/version.go +binpack = src/binpack.go all: def @date +"%Y-%m-%d %H:%M:%S" - go build -v -o ${binarys} src/main.go src/version.go src/binpack.go && ./${binarys} forever restart &>/dev/null + go build -v -o ${binarys} src/main.go ${version} ${binpack} && ./${binarys} forever restart &>/dev/null app: def - CGO_ENABLED=1 go build -v -o usr/publish/contexts.app/Contents/MacOS/contexts src/webview.go src/version.go src/binpack.go && ./${binarys} forever restart &>/dev/null - # hdiutil create usr/publish/tmp.dmg -ov -volname "ContextsInstall" -fs HFS+ -srcfolder "usr/publish/contexts.app" - # rm -f usr/publish/ContextsInstall.dmg - # hdiutil convert usr/publish/tmp.dmg -format UDZO -o usr/publish/ContextsInstall.dmg + CGO_ENABLED=1 go build -v -o ${publish}/contexts.app/Contents/MacOS/contexts src/webview.go ${version} ${binpack} && ./${binarys} forever restart &>/dev/null + # hdiutil create ${publish}/tmp.dmg -ov -volname "ContextsInstall" -fs HFS+ -srcfolder "${publish}/contexts.app" + # rm -f ${publish}/ContextsInstall.dmg + # hdiutil convert ${publish}/tmp.dmg -format UDZO -o ${publish}/ContextsInstall.dmg %: src/%.go def @date +"%Y-%m-%d %H:%M:%S" - go build -v -o usr/publish/$@ src/$@.go src/version.go && chmod u+x usr/publish/$@ + go build -v -o ${publish}/$@ src/$@.go ${version} && chmod u+x ${publish}/$@ def: - @ [ -f src/version.go ] || echo "package main" > src/version.go - @ [ -f src/binpack.go ] || echo "package main" > src/binpack.go - + @[ -f ${version} ] || echo "package main">${version} + @[ -f ${binpack} ] || echo "package main">${binpack} diff --git a/README.md b/README.md index 0fa98c61..d6dea5be 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,7 @@ # contexts - -contexts 通过集群化、模块化、自动化的方式,用一个 20M 的程序文件, 就可以在各种设备上,一键搭起完整的云计算与云研发服务。 +contexts 通过集群化、模块化、自动化的方式,用一个 20M 的程序文件,就可以在各种设备上,一键搭起完整的云计算与云研发服务。 ## 安装项目 - ```sh -ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL https://shylinux.com; source $ctx_temp binary port 9020 +temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL https://shylinux.com; else wget -O $temp -q https://shylinux.com; fi; source $temp binary ``` - -## 使用项目 -如果是本地启动,直接免登录打开网页,http://localhost:9020 , -如果是远程或容器启动,输入相应地址后,输入默认的 username: root password: root 即可登录 - diff --git a/etc/exit.shy b/etc/exit.shy index 0dbd8c49..e69de29b 100644 --- a/etc/exit.shy +++ b/etc/exit.shy @@ -1,7 +0,0 @@ -~web.chat - favor export -~aaa - sess export - user export -~cli - daemon export diff --git a/etc/init.shy b/etc/init.shy index 169c37c2..9a60a945 100644 --- a/etc/init.shy +++ b/etc/init.shy @@ -1,73 +1,24 @@ -~cli - daemon import - -~aaa - user import - sess import - -~web.chat - favor import - -~aaa - role white void web.code.git.spide - role white void web.code.git.trend - role white void web.code.input.find - role white void web.wiki.alpha.find - role white void require/src - -~web.code - alpine mirrors - alpine tzone - ~web.code webpack insert xterm webpack insert xterm-addon-fit webpack insert xterm-addon-web-links webpack insert xterm/css/xterm.css - favor remove zone _system_app - favor insert zone _system_app type "open -a 'System Preferences'" text "System Preferences.png" - favor insert zone _system_app type "open -a 'Launchpad'" text "Launchpad.png" - favor insert zone _system_app type "open -a 'Mission Control'" text "Mission Control.png" - favor insert zone _system_app type "open -a 'Activity Monitor'" text "Activity Monitor.png" - favor insert zone _system_app type "open -a 'Google Chrome'" text "Google Chrome.png" - favor insert zone _system_app type "open -a 'QuickTime Player'" text "QuickTime Player.png" - favor insert zone _system_app type "open -a 'Preview'" text "Preview.png" - favor insert zone _system_app type "open -a 'Finder'" text "Finder.png" - favor insert zone _system_app type "open -a 'Docker'" text "Docker.png" - favor insert zone _system_app type "open -a 'Safari'" text "Safari.png" - favor insert zone _system_app type "open -a 'Terminal'" text "Terminal.png" - favor insert zone _system_app type "open -a 'Contexts'" text "Contexts.png" - favor insert zone _system_app type "open 'http://localhost:9020'" name localhost text "Google Chrome.png" - favor insert zone _system_app type "open 'https://shylinux.com'" name shylinux text "Google Chrome.png" - - favor remove zone _system_term - favor insert zone _system_term type "docker run -w /root -it alpine" - favor insert zone _system_term type "docker run -it contexts" - favor insert zone _system_term type "ice.bin source stdio" - favor insert zone _system_term type "tmux attach -t miss" - favor insert zone _system_term type "vim src/main.go" - favor insert zone _system_term type "python" - favor insert zone _system_term type "node" - -~web.code - config inner meta.show.tabs "" - config inner meta.show.plug "" - config vimer meta.show.tabs "" - config vimer meta.show.plug "web.code.xterm,web.chat.iframe" - ~web.code.input # wubi load file usr/wubi-dict/wubi86 # wubi load file usr/wubi-dict/person zone person +~aaa + role white void web.code.git.spide + role white void web.code.git.trend + role white void web.code.input.find + role white void web.wiki.alpha.find + ~gdb # config timer meta.enable true - event listen event dream.create cmd web.code.tmux.session # event listen event serve.start cmd web.code.publish - event listen event sess.create cmd aaa.sess - event listen event user.create cmd aaa.sess + event listen event dream.create cmd web.code.tmux.session ~ssh target web.code source local.shy - diff --git a/src/webview.go b/src/webview.go index 6e03560a..dcfb7df1 100644 --- a/src/webview.go +++ b/src/webview.go @@ -2,31 +2,17 @@ package main import ( "os" - "time" "shylinux.com/x/ice" - "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/tcp" "shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/misc/webview" kit "shylinux.com/x/toolkits" - - _ "shylinux.com/x/contexts/src/h2" ) -type view struct{ *webview.WebView } - func main() { - if os.Chdir(kit.HomePath(ice.CONTEXTS)); len(os.Args) == 1 { - for { - if ice.Run(cli.SYSTEM, os.Args[0], "webview"); cli.IsSuccess(ice.Pulse) { - break - } - time.Sleep(time.Second) - } - } else { - go ice.Run(web.SERVE, tcp.START) - defer ice.Pulse.Cmd("exit") - webview.Run(func(w *webview.WebView) ice.Any { return view{w} }) - } + os.Chdir(kit.HomePath(ice.CONTEXTS)) + go ice.Run(web.SERVE, tcp.START) + defer ice.Pulse.Cmd("exit") + webview.Run(nil) }