1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-28 18:22:02 +08:00
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-09-17 15:40:28 +08:00
parent ac9335f46e
commit 6e6041aa88
4 changed files with 43 additions and 4 deletions

View File

@ -15,18 +15,22 @@ import (
const ( const (
CMD = "cmd" CMD = "cmd"
OSID = "osid" OSID = "osid"
REPOS = "repos"
UBUNTU = "ubuntu" UBUNTU = "ubuntu"
CENTOS = "centos" CENTOS = "centos"
ALPINE = "alpine" ALPINE = "alpine"
BUSYBOX = "busybox" BUSYBOX = "busybox"
RELEASE = "release" RELEASE = "release"
ETC_OS_RELEASE = "/etc/os-release"
ETC_APK_REPOS = "/etc/apk/repositories"
) )
const MIRRORS = "mirrors" const MIRRORS = "mirrors"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
MIRRORS: {Name: "mirrors cli auto", Help: "软件镜像", Actions: ice.MergeActions(ice.Actions{ MIRRORS: {Name: "mirrors cli auto repos", Help: "软件镜像", Actions: ice.MergeActions(ice.Actions{
mdb.INSERT: {Name: "insert cli* osid cmd*"}, mdb.INSERT: {Name: "insert cli* osid cmd*"},
CMD: {Name: "cmd cli osid", Hand: func(m *ice.Message, arg ...string) { CMD: {Name: "cmd cli osid", Hand: func(m *ice.Message, arg ...string) {
osid := kit.Select(mdb.Conf(m, RUNTIME, kit.Keys(HOST, OSID)), m.Option(OSID)) osid := kit.Select(mdb.Conf(m, RUNTIME, kit.Keys(HOST, OSID)), m.Option(OSID))
@ -35,7 +39,37 @@ func init() {
}) })
}}, }},
ALPINE: {Name: "alpine cli cmd", Hand: func(m *ice.Message, arg ...string) { IsAlpine(m, arg...) }}, ALPINE: {Name: "alpine cli cmd", Hand: func(m *ice.Message, arg ...string) { IsAlpine(m, arg...) }},
}, mdb.ZoneAction(mdb.SHORT, CLI, mdb.FIELD, "time,id,osid,cmd"), mdb.ClearOnExitHashAction())}, REPOS: {Help: "镜像源", Hand: func(m *ice.Message, arg ...string) {
switch {
case strings.Contains(release(m.Spawn()), ALPINE):
m.Cmd(nfs.SAVE, ETC_APK_REPOS, strings.ReplaceAll(m.Cmdx(nfs.CAT, ETC_APK_REPOS), "dl-cdn.alpinelinux.org", "mirrors.tencent.com"))
m.Cmdy(SYSTEM, "apk", "update")
m.StatusTimeCount()
}
}},
"add": {Help: "安装", Hand: func(m *ice.Message, arg ...string) {
mdb.ZoneSelect(m, m.Option(CLI)).Table(func(value ice.Maps) {
m.Push("res", m.Cmdx(kit.Split(value[CMD])))
})
}},
}, mdb.ZoneAction(mdb.SHORT, CLI, mdb.FIELD, "time,id,osid,cmd"), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
if mdb.ZoneSelect(m, arg...); len(arg) == 0 {
m.Table(func(value ice.Maps) {
p := SystemFind(m, value[CLI])
m.Push("path", p)
if p == "" {
m.PushButton("add")
} else {
m.PushButton("")
}
})
m.StatusTimeCount("release", release(m.Spawn()))
}
switch {
case strings.Contains(release(m.Spawn()), ALPINE):
m.Cmdy(nfs.CAT, ETC_APK_REPOS)
}
}},
}) })
} }
@ -43,11 +77,11 @@ var _release = ""
func release(m *ice.Message) string { func release(m *ice.Message) string {
list := []string{runtime.GOOS} list := []string{runtime.GOOS}
if list[0] != LINUX || !nfs.Exists(m, "/etc/os-release") { if list[0] != LINUX || !nfs.Exists(m, ETC_OS_RELEASE) {
return list[0] return list[0]
} }
m.Option(nfs.CAT_CONTENT, _release) m.Option(nfs.CAT_CONTENT, _release)
_release = m.Cmdx(nfs.CAT, "/etc/os-release", kit.Dict(ice.MSG_USERROLE, aaa.ROOT), func(text string, _ int) string { _release = m.Cmdx(nfs.CAT, ETC_OS_RELEASE, kit.Dict(ice.MSG_USERROLE, aaa.ROOT), func(text string, _ int) string {
if ls := kit.Split(text, mdb.EQ); len(ls) > 1 { if ls := kit.Split(text, mdb.EQ); len(ls) > 1 {
kit.Switch(ls[0], []string{"ID", "ID_LIKE"}, func() { list = append(list, strings.TrimSpace(ls[1])) }) kit.Switch(ls[0], []string{"ID", "ID_LIKE"}, func() { list = append(list, strings.TrimSpace(ls[1])) })
} }

View File

@ -28,6 +28,9 @@ func init() {
cli.IsAlpine(m, "python", "python2") cli.IsAlpine(m, "python", "python2")
cli.IsAlpine(m, "python2") cli.IsAlpine(m, "python2")
cli.IsAlpine(m, "python3") cli.IsAlpine(m, "python3")
cli.IsCentos(m, "python", "python2")
cli.IsCentos(m, "python2")
cli.IsCentos(m, "python3")
}}, }},
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { ProcessXterm(m, "python -i "+path.Join(arg[2], arg[1]), "") }}, mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { ProcessXterm(m, "python -i "+path.Join(arg[2], arg[1]), "") }},
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _py_exec(m, path.Join(arg[2], arg[1])) }}, mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _py_exec(m, path.Join(arg[2], arg[1])) }},

View File

@ -22,6 +22,7 @@ type node struct {
func (s node) Init(m *ice.Message) { func (s node) Init(m *ice.Message) {
cli.IsAlpine(m.Message, NODE, "nodejs") cli.IsAlpine(m.Message, NODE, "nodejs")
cli.IsCentos(m.Message, NODE, "nodejs")
} }
func (s node) Install(m *ice.Message, arg ...string) { func (s node) Install(m *ice.Message, arg ...string) {
s.Code.Install(m, arg...) s.Code.Install(m, arg...)

View File

@ -15,6 +15,7 @@ type npm struct {
func (s npm) Init(m *ice.Message) { func (s npm) Init(m *ice.Message) {
cli.IsAlpine(m.Message, NPM) cli.IsAlpine(m.Message, NPM)
cli.IsCentos(m.Message, NPM, "nodejs")
} }
func (s npm) List(m *ice.Message) { func (s npm) List(m *ice.Message) {
m.Cmdy(nfs.DIR, ice.USR_MODULES) m.Cmdy(nfs.DIR, ice.USR_MODULES)