diff --git a/lib/core/generator/generic/generate.v b/lib/core/generator/generic/generate.v index 02fa98de..843ac4e4 100644 --- a/lib/core/generator/generic/generate.v +++ b/lib/core/generator/generic/generate.v @@ -19,7 +19,7 @@ pub fn generate(args_ GenerateArgs) ! { mut args := args_ console.print_header('Generate code for path: ${args.path} (reset:${args.reset}, force:${args.force})') - console.print_debug(args) + if args.path == '' { return error('no path provided') } diff --git a/lib/core/generator/generic/model_meta.v b/lib/core/generator/generic/model_meta.v index 66c17e77..0c525779 100644 --- a/lib/core/generator/generic/model_meta.v +++ b/lib/core/generator/generic/model_meta.v @@ -21,6 +21,7 @@ pub mut: hasconfig bool = true play_name string // e.g. docusaurus is what we look for module_path string // e.g.incubaid.herolib.web.docusaurus + active bool = true // if false then we skip generation } pub enum Cat { @@ -29,8 +30,6 @@ pub enum Cat { } fn args_get(path string) !ModuleMeta { - console.print_debug('generate code for path: ${path}') - mut config_path := pathlib.get_file(path: '${path}/.heroscript', create: false)! if !config_path.exists() { @@ -74,6 +73,7 @@ fn args_get(path string) !ModuleMeta { startupmanager: p.get_default_true('startupmanager') hasconfig: p.get_default_true('hasconfig') build: p.get_default_false('build') + active: p.get_default_true('active') cat: .installer path: path } @@ -93,6 +93,7 @@ fn args_get(path string) !ModuleMeta { title: p.get_default('title', '')! default: p.get_default_true('default') singleton: p.get_default_false('singleton') + active: p.get_default_true('active') cat: .client path: path play_name: p.get_default('play_name', name)! diff --git a/lib/core/generator/generic/scanner.v b/lib/core/generator/generic/scanner.v index 447aec1c..f45552fe 100644 --- a/lib/core/generator/generic/scanner.v +++ b/lib/core/generator/generic/scanner.v @@ -19,8 +19,10 @@ pub fn scan(args_ ScannerArgs) ! { args.path = os.getwd() } + mut generateall := false if args.path == '' { args.path = '${os.home_dir()}/code/github/incubaid/herolib/lib' + generateall = true } // now walk over all directories, find .heroscript @@ -32,9 +34,6 @@ pub fn scan(args_ ScannerArgs) ! { )! console.print_debug('Found ${plist.paths.len} directories with .heroscript file.') - if args.generate && args.path != '' { - return error('when scanning without generation then we always need to start from the root path, so no . or path provided.') - } if args.generate { console.print_debug('Now generating code for all found .heroscript files.') for mut p in plist.paths { @@ -45,8 +44,15 @@ pub fn scan(args_ ScannerArgs) ! { mut res := []ModuleMeta{} for mut p in plist.paths { pparent := p.parent()! - res << args_get(pparent.path)! + mut t := args_get(pparent.path)! + if t.active { + res << t + } else { + console.print_debug('Skipping generation for ${t.name} as active is false.') + } + } + if generateall { + console.print_debug('Found ${res.len} generator args.') + generate_play_all(res)! } - console.print_debug('Found ${res.len} generator args.') - generate_play_all(res)! } diff --git a/lib/core/generator/generic/templates/play_all.vtemplate b/lib/core/generator/generic/templates/play_all.vtemplate index bdd4b37d..6a2cbee2 100644 --- a/lib/core/generator/generic/templates/play_all.vtemplate +++ b/lib/core/generator/generic/templates/play_all.vtemplate @@ -1,5 +1,7 @@ module playcmds +import incubaid.herolib.core.playbook + @for item in meta_items import @{item.module_path} @end diff --git a/lib/core/herocmds/generator.v b/lib/core/herocmds/generator.v index c6befa1f..bcf24ee9 100644 --- a/lib/core/herocmds/generator.v +++ b/lib/core/herocmds/generator.v @@ -32,6 +32,7 @@ pub fn cmd_generator(mut cmdroot Command) { flag: .bool required: false name: 'generate' + abbrev: 'g' description: 'generate the code only relevant for scanning.' }) diff --git a/lib/core/playcmds/play_all.v b/lib/core/playcmds/play_all.v index 5e33d223..48733b78 100644 --- a/lib/core/playcmds/play_all.v +++ b/lib/core/playcmds/play_all.v @@ -1,5 +1,6 @@ module playcmds +import incubaid.herolib.core.playbook import incubaid.herolib.clients.giteaclient import incubaid.herolib.clients.ipapi import incubaid.herolib.clients.jina @@ -18,12 +19,7 @@ import incubaid.herolib.clients.wireguard import incubaid.herolib.clients.zerodb_client import incubaid.herolib.clients.zinit import incubaid.herolib.develop.heroprompt -import incubaid.herolib.installers.db.cometbft import incubaid.herolib.installers.db.meilisearch_installer -import incubaid.herolib.installers.db.postgresql -import incubaid.herolib.installers.db.qdrant_installer -import incubaid.herolib.installers.db.zerodb -import incubaid.herolib.installers.db.zerofs import incubaid.herolib.installers.infra.coredns import incubaid.herolib.installers.infra.gitea import incubaid.herolib.installers.infra.livekit @@ -34,15 +30,8 @@ import incubaid.herolib.installers.lang.python import incubaid.herolib.installers.lang.rust import incubaid.herolib.installers.net.mycelium_installer import incubaid.herolib.installers.net.wireguard_installer -import incubaid.herolib.installers.net.yggdrasil -import incubaid.herolib.installers.sysadmintools.actrunner import incubaid.herolib.installers.sysadmintools.b2 -import incubaid.herolib.installers.sysadmintools.fungistor import incubaid.herolib.installers.sysadmintools.garage_s3 -import incubaid.herolib.installers.sysadmintools.grafana -import incubaid.herolib.installers.sysadmintools.prometheus -import incubaid.herolib.installers.sysadmintools.rclone -import incubaid.herolib.installers.sysadmintools.restic import incubaid.herolib.installers.threefold.griddriver import incubaid.herolib.installers.virt.cloudhypervisor import incubaid.herolib.installers.virt.docker @@ -52,13 +41,10 @@ import incubaid.herolib.installers.virt.pacman import incubaid.herolib.installers.virt.podman import incubaid.herolib.installers.virt.youki import incubaid.herolib.installers.web.bun -import incubaid.herolib.installers.web.imagemagick -import incubaid.herolib.installers.web.lighttpd import incubaid.herolib.installers.web.tailwind import incubaid.herolib.installers.web.tailwind4 import incubaid.herolib.installers.web.traefik import incubaid.herolib.installers.web.zola -import incubaid.herolib.threefold.grid3.deployer import incubaid.herolib.virt.hetznermanager pub fn run_all(args_ PlayArgs) ! { @@ -86,12 +72,7 @@ pub fn run_all(args_ PlayArgs) ! { zerodb_client.play(mut plbook)! zinit.play(mut plbook)! heroprompt.play(mut plbook)! - cometbft.play(mut plbook)! meilisearch_installer.play(mut plbook)! - postgresql.play(mut plbook)! - qdrant_installer.play(mut plbook)! - zerodb.play(mut plbook)! - zerofs.play(mut plbook)! coredns.play(mut plbook)! gitea.play(mut plbook)! livekit.play(mut plbook)! @@ -102,15 +83,8 @@ pub fn run_all(args_ PlayArgs) ! { rust.play(mut plbook)! mycelium_installer.play(mut plbook)! wireguard_installer.play(mut plbook)! - yggdrasil.play(mut plbook)! - actrunner.play(mut plbook)! b2.play(mut plbook)! - fungistor.play(mut plbook)! garage_s3.play(mut plbook)! - grafana.play(mut plbook)! - prometheus.play(mut plbook)! - rclone.play(mut plbook)! - restic.play(mut plbook)! griddriver.play(mut plbook)! cloudhypervisor.play(mut plbook)! docker.play(mut plbook)! @@ -120,12 +94,9 @@ pub fn run_all(args_ PlayArgs) ! { podman.play(mut plbook)! youki.play(mut plbook)! bun.play(mut plbook)! - imagemagick.play(mut plbook)! - lighttpd.play(mut plbook)! tailwind.play(mut plbook)! tailwind4.play(mut plbook)! traefik.play(mut plbook)! zola.play(mut plbook)! - deployer.play(mut plbook)! hetznermanager.play(mut plbook)! } diff --git a/lib/installers/db/cometbft/.heroscript b/lib/installers/db/cometbft/.heroscript index 9148589d..83908921 100644 --- a/lib/installers/db/cometbft/.heroscript +++ b/lib/installers/db/cometbft/.heroscript @@ -11,3 +11,4 @@ startupmanager:1 hasconfig:1 build:1 + active:0 \ No newline at end of file diff --git a/lib/installers/db/postgresql/.heroscript b/lib/installers/db/postgresql/.heroscript index b39d9a2a..def64d82 100644 --- a/lib/installers/db/postgresql/.heroscript +++ b/lib/installers/db/postgresql/.heroscript @@ -10,4 +10,5 @@ reset:0 startupmanager:1 hasconfig:1 - build:0 \ No newline at end of file + build:0 + active:false \ No newline at end of file diff --git a/lib/installers/db/qdrant_installer/.heroscript b/lib/installers/db/qdrant_installer/.heroscript index 05f8f908..f02a1d80 100644 --- a/lib/installers/db/qdrant_installer/.heroscript +++ b/lib/installers/db/qdrant_installer/.heroscript @@ -10,4 +10,5 @@ reset:0 startupmanager:1 hasconfig:1 - build:1 \ No newline at end of file + build:1 + active:0 \ No newline at end of file diff --git a/lib/installers/db/zerodb/.heroscript b/lib/installers/db/zerodb/.heroscript index e36bb19f..26a75fd9 100644 --- a/lib/installers/db/zerodb/.heroscript +++ b/lib/installers/db/zerodb/.heroscript @@ -9,3 +9,4 @@ build: true startupmanager: true supported_platforms: "" + active: false diff --git a/lib/installers/infra/gitea/play.v b/lib/installers/infra/gitea/play.v deleted file mode 100644 index 4ebbf5db..00000000 --- a/lib/installers/infra/gitea/play.v +++ /dev/null @@ -1,23 +0,0 @@ -module gitea - -import incubaid.herolib.core.playbook { PlayBook } -import incubaid.herolib.ui.console -import incubaid.herolib.installers.infra.gitea { install } - -pub fn play(mut plbook PlayBook) ! { - if !plbook.exists(filter: 'gitea.') { - return - } - - mut install_action := plbook.ensure_once(filter: 'gitea.install')! - mut p := install_action.params - - mut args := InstallArgs{ - reset: p.get_default_false('reset') - } - - console.print_header('Executing gitea.install action') - install(args)! - - install_action.done = true -} diff --git a/lib/installers/install_multi.v b/lib/installers/install_multi.v index 9344a52d..e4a214f9 100644 --- a/lib/installers/install_multi.v +++ b/lib/installers/install_multi.v @@ -129,7 +129,7 @@ pub fn install_multi(args_ InstallArgs) ! { // fungistor.install(reset: args.reset)! // } // 'lima' { - // lima.install_(reset: args.reset, uninstall: args.uninstall)! + // lima.install(reset: args.reset, uninstall: args.uninstall)! // } // 'herocontainers' { // mut podman_installer0 := podman_installer.get()! diff --git a/lib/installers/lang/herolib/herolib.v b/lib/installers/lang/herolib/herolib.v index a1c5be82..dfe1eaed 100644 --- a/lib/installers/lang/herolib/herolib.v +++ b/lib/installers/lang/herolib/herolib.v @@ -17,7 +17,7 @@ pub mut: reset bool // means reinstall } -fn install_(args InstallArgs) ! { +fn install0(args InstallArgs) ! { // install herolib if it was already done will return true console.print_header('install herolib (reset: ${args.reset})') // osal.package_refresh()! @@ -96,7 +96,7 @@ pub fn compile(args InstallArgs) ! { return } console.print_header('compile hero') - install_(args)! + install(args)! cmd := " cd /tmp diff --git a/lib/installers/sysadmintools/actrunner/.heroscript b/lib/installers/sysadmintools/actrunner/.heroscript index 8a02e772..112b7f66 100644 --- a/lib/installers/sysadmintools/actrunner/.heroscript +++ b/lib/installers/sysadmintools/actrunner/.heroscript @@ -9,3 +9,4 @@ build: true startupmanager: true supported_platforms: "" + active: false \ No newline at end of file diff --git a/lib/installers/sysadmintools/fungistor/.heroscript b/lib/installers/sysadmintools/fungistor/.heroscript index 6b80ab65..b8fb1e4d 100644 --- a/lib/installers/sysadmintools/fungistor/.heroscript +++ b/lib/installers/sysadmintools/fungistor/.heroscript @@ -8,4 +8,5 @@ templates: false build: true startupmanager: true + active: false diff --git a/lib/installers/sysadmintools/fungistor/fungistor_actions.v b/lib/installers/sysadmintools/fungistor/fungistor_actions.v index 6fa2268f..a2c9c306 100644 --- a/lib/installers/sysadmintools/fungistor/fungistor_actions.v +++ b/lib/installers/sysadmintools/fungistor/fungistor_actions.v @@ -27,7 +27,7 @@ fn startupcmd() ![]startupmanager.ZProcessNewArgs { return res } -fn running_() !bool { +fn running() !bool { mut installer := get()! // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // this checks health of fungistor @@ -64,7 +64,7 @@ fn stop_post() ! { //////////////////// following actions are not specific to instance of the object // checks if a certain version or above is installed -fn installed_() !bool { +fn installed() !bool { // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // res := os.execute('${osal.profile_path_source_and()!} fungistor version') // if res.exit_code != 0 { @@ -87,14 +87,14 @@ fn ulist_get() !ulist.UList { } // uploads to S3 server if configured -fn upload_() ! { +fn upload() ! { // installers.upload( // cmdname: 'fungistor' // source: '${gitpath}/target/x86_64-unknown-linux-musl/release/fungistor' // )! } -fn install_() ! { +fn install() ! { console.print_header('install fungistor') // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // mut url := '' @@ -125,7 +125,7 @@ fn install_() ! { // )! } -fn build_() ! { +fn build() ! { // url := 'https://github.com/threefoldtech/fungistor' // make sure we install base on the node @@ -154,7 +154,7 @@ fn build_() ! { // )! } -fn destroy_() ! { +fn destroy() ! { // mut systemdfactory := systemd.new()! // systemdfactory.destroy("zinit")! diff --git a/lib/installers/sysadmintools/grafana/.heroscript b/lib/installers/sysadmintools/grafana/.heroscript index b5f478f3..aa5fbd7d 100644 --- a/lib/installers/sysadmintools/grafana/.heroscript +++ b/lib/installers/sysadmintools/grafana/.heroscript @@ -8,4 +8,4 @@ templates: false build: true startupmanager: true - + active: false diff --git a/lib/installers/sysadmintools/grafana/grafana_actions.v b/lib/installers/sysadmintools/grafana/grafana_actions.v index 3a42d876..0278b1ab 100644 --- a/lib/installers/sysadmintools/grafana/grafana_actions.v +++ b/lib/installers/sysadmintools/grafana/grafana_actions.v @@ -27,7 +27,7 @@ fn startupcmd() ![]startupmanager.ZProcessNewArgs { return res } -fn running_() !bool { +fn running() !bool { mut installer := get()! // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // this checks health of grafana @@ -64,7 +64,7 @@ fn stop_post() ! { //////////////////// following actions are not specific to instance of the object // checks if a certain version or above is installed -fn installed_() !bool { +fn installed() !bool { // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // res := os.execute('${osal.profile_path_source_and()!} grafana version') // if res.exit_code != 0 { @@ -87,14 +87,14 @@ fn ulist_get() !ulist.UList { } // uploads to S3 server if configured -fn upload_() ! { +fn upload() ! { // installers.upload( // cmdname: 'grafana' // source: '${gitpath}/target/x86_64-unknown-linux-musl/release/grafana' // )! } -fn install_() ! { +fn install() ! { console.print_header('install grafana') // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // mut url := '' @@ -125,7 +125,7 @@ fn install_() ! { // )! } -fn build_() ! { +fn build() ! { // url := 'https://github.com/threefoldtech/grafana' // make sure we install base on the node @@ -154,7 +154,7 @@ fn build_() ! { // )! } -fn destroy_() ! { +fn destroy() ! { // mut systemdfactory := systemd.new()! // systemdfactory.destroy("zinit")! diff --git a/lib/installers/sysadmintools/prometheus/.heroscript b/lib/installers/sysadmintools/prometheus/.heroscript index 8b1c7189..24928e00 100644 --- a/lib/installers/sysadmintools/prometheus/.heroscript +++ b/lib/installers/sysadmintools/prometheus/.heroscript @@ -8,4 +8,4 @@ templates: false build: true startupmanager: true - + active: false diff --git a/lib/installers/sysadmintools/prometheus/prometheus_actions.v b/lib/installers/sysadmintools/prometheus/prometheus_actions.v index abbc6dc5..fe543d56 100644 --- a/lib/installers/sysadmintools/prometheus/prometheus_actions.v +++ b/lib/installers/sysadmintools/prometheus/prometheus_actions.v @@ -27,7 +27,7 @@ fn startupcmd() ![]startupmanager.ZProcessNewArgs { return res } -fn running_() !bool { +fn running() !bool { mut installer := get()! // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // this checks health of prometheus @@ -64,7 +64,7 @@ fn stop_post() ! { //////////////////// following actions are not specific to instance of the object // checks if a certain version or above is installed -fn installed_() !bool { +fn installed() !bool { // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // res := os.execute('${osal.profile_path_source_and()!} prometheus version') // if res.exit_code != 0 { @@ -87,14 +87,14 @@ fn ulist_get() !ulist.UList { } // uploads to S3 server if configured -fn upload_() ! { +fn upload() ! { // installers.upload( // cmdname: 'prometheus' // source: '${gitpath}/target/x86_64-unknown-linux-musl/release/prometheus' // )! } -fn install_() ! { +fn install() ! { console.print_header('install prometheus') // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // mut url := '' @@ -125,7 +125,7 @@ fn install_() ! { // )! } -fn build_() ! { +fn build() ! { // url := 'https://github.com/threefoldtech/prometheus' // make sure we install base on the node @@ -154,7 +154,7 @@ fn build_() ! { // )! } -fn destroy_() ! { +fn destroy() ! { // mut systemdfactory := systemd.new()! // systemdfactory.destroy("zinit")! diff --git a/lib/installers/sysadmintools/prometheus/prometheus_installer_factory.v b/lib/installers/sysadmintools/prometheus/prometheus_installer_factory.v index 0431248c..3f7a66fa 100644 --- a/lib/installers/sysadmintools/prometheus/prometheus_installer_factory.v +++ b/lib/installers/sysadmintools/prometheus/prometheus_installer_factory.v @@ -27,7 +27,7 @@ import time // // port int = 8888 // } -// pub fn install_(args_ InstallArgs) ! { +// pub fn install(args_ InstallArgs) ! { // install_prometheus(args_)! // install_alertmanager(args_)! // install_node_exporter(args_)! diff --git a/lib/installers/sysadmintools/rclone/.heroscript b/lib/installers/sysadmintools/rclone/.heroscript index 85efe1bb..9582912e 100644 --- a/lib/installers/sysadmintools/rclone/.heroscript +++ b/lib/installers/sysadmintools/rclone/.heroscript @@ -10,6 +10,6 @@ reset: 0 // regenerate all, dangerous !!! startupmanager:0 //managed by a startup manager, default true build:0 //will we also build the component - + active:0 //is the installer active by default diff --git a/lib/installers/sysadmintools/restic/.heroscript b/lib/installers/sysadmintools/restic/.heroscript index de55e0ef..683f3ab2 100644 --- a/lib/installers/sysadmintools/restic/.heroscript +++ b/lib/installers/sysadmintools/restic/.heroscript @@ -8,4 +8,5 @@ templates: false build: true startupmanager: true + active: false diff --git a/lib/installers/sysadmintools/restic/builder.v b/lib/installers/sysadmintools/restic/builder.v index b9512ee2..f8e21ecf 100644 --- a/lib/installers/sysadmintools/restic/builder.v +++ b/lib/installers/sysadmintools/restic/builder.v @@ -16,7 +16,7 @@ pub mut: } // install restic will return true if it was already installed -pub fn build_(args BuildArgs) ! { +pub fn build(args BuildArgs) ! { // make sure we install base on the node if core.platform() != .ubuntu { return error('only support ubuntu for now') diff --git a/lib/installers/sysadmintools/restic/restic_actions.v b/lib/installers/sysadmintools/restic/restic_actions.v index 05f78652..fd02c562 100644 --- a/lib/installers/sysadmintools/restic/restic_actions.v +++ b/lib/installers/sysadmintools/restic/restic_actions.v @@ -27,7 +27,7 @@ fn startupcmd() ![]startupmanager.ZProcessNewArgs { return res } -fn running_() !bool { +fn running() !bool { mut installer := get()! // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // this checks health of restic @@ -64,7 +64,7 @@ fn stop_post() ! { //////////////////// following actions are not specific to instance of the object // checks if a certain version or above is installed -fn installed_() !bool { +fn installed() !bool { // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // res := os.execute('${osal.profile_path_source_and()!} restic version') // if res.exit_code != 0 { @@ -87,14 +87,14 @@ fn ulist_get() !ulist.UList { } // uploads to S3 server if configured -fn upload_() ! { +fn upload() ! { // installers.upload( // cmdname: 'restic' // source: '${gitpath}/target/x86_64-unknown-linux-musl/release/restic' // )! } -fn install_() ! { +fn install() ! { console.print_header('install restic') // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // mut url := '' @@ -125,7 +125,7 @@ fn install_() ! { // )! } -fn build_() ! { +fn build() ! { // url := 'https://github.com/threefoldtech/restic' // make sure we install base on the node @@ -154,7 +154,7 @@ fn build_() ! { // )! } -fn destroy_() ! { +fn destroy() ! { // mut systemdfactory := systemd.new()! // systemdfactory.destroy("zinit")! diff --git a/lib/installers/threefold/tfrobot/tfrobot.v b/lib/installers/threefold/tfrobot/tfrobot.v index 5f90aa44..77aa46f3 100644 --- a/lib/installers/threefold/tfrobot/tfrobot.v +++ b/lib/installers/threefold/tfrobot/tfrobot.v @@ -15,7 +15,7 @@ pub mut: uninstall bool } -pub fn install_(args_ InstallArgs) ! { +pub fn install(args_ InstallArgs) ! { mut args := args_ version := '0.14.0' @@ -35,11 +35,11 @@ pub fn install_(args_ InstallArgs) ! { if args.reset { console.print_header('install tfrobot') - build_()! + build()! } } -pub fn build_() ! { +pub fn build() ! { mut g := golang.get()! g.install()! console.print_header('build tfrobot') diff --git a/lib/installers/upload.v b/lib/installers/upload.v index 2f4103db..76663ff3 100644 --- a/lib/installers/upload.v +++ b/lib/installers/upload.v @@ -11,7 +11,7 @@ pub mut: reset bool } -pub fn upload_(args_ UploadArgs) ! { +pub fn upload(args_ UploadArgs) ! { //_ := args_ panic('to implement') } diff --git a/lib/installers/virt/cloudhypervisor/.heroscript b/lib/installers/virt/cloudhypervisor/.heroscript index a97a0e84..87f7ba34 100644 --- a/lib/installers/virt/cloudhypervisor/.heroscript +++ b/lib/installers/virt/cloudhypervisor/.heroscript @@ -10,4 +10,4 @@ reset:0 startupmanager:0 hasconfig:0 - build:1 \ No newline at end of file + build:1 diff --git a/lib/installers/virt/cloudhypervisor/cloudhypervisor_actions.v b/lib/installers/virt/cloudhypervisor/cloudhypervisor_actions.v index 85d741ee..3689faff 100644 --- a/lib/installers/virt/cloudhypervisor/cloudhypervisor_actions.v +++ b/lib/installers/virt/cloudhypervisor/cloudhypervisor_actions.v @@ -3,12 +3,13 @@ module cloudhypervisor import incubaid.herolib.osal.core as osal import incubaid.herolib.ui.console import incubaid.herolib.core.texttools +import incubaid.herolib.core // import incubaid.herolib.core.pathlib import incubaid.herolib.installers.ulist // import incubaid.herolib.installers.lang.rust import os -fn installed_() !bool { +fn installed() !bool { res := os.execute('${osal.profile_path_source_and()!} cloud-hypervisor --version') if res.exit_code == 0 { r := res.output.split_into_lines().filter(it.contains('cloud-hypervisor')) @@ -27,7 +28,7 @@ fn installed_() !bool { return true } -fn install_() ! { +fn install() ! { console.print_header('install cloudhypervisor') // mut installer := get()! mut url := '' @@ -59,7 +60,7 @@ fn install_() ! { )! } -fn build_() ! { +fn build() ! { } // get the Upload List of the files @@ -70,7 +71,7 @@ fn ulist_get() !ulist.UList { } // uploads to S3 server if configured -fn upload_() ! { +fn upload() ! { // mut installer := get()! // installers.upload( // cmdname: 'cloudhypervisor' @@ -78,7 +79,7 @@ fn upload_() ! { // )! } -fn destroy_() ! { +fn destroy() ! { osal.process_kill_recursive(name: 'cloud-hypervisor')! osal.package_remove(' diff --git a/lib/installers/virt/lima/lima_actions.v b/lib/installers/virt/lima/lima_actions.v index 707abd74..182418d3 100644 --- a/lib/installers/virt/lima/lima_actions.v +++ b/lib/installers/virt/lima/lima_actions.v @@ -89,7 +89,7 @@ fn upload() ! { fn install() ! { console.print_header('install lima') - qemu.install_()! + qemu.install()! mut url := '' mut url2 := '' mut dest_on_os := '${os.home_dir()}/hero' diff --git a/lib/installers/virt/qemu/qemu_install.v b/lib/installers/virt/qemu/qemu_install.v index e48aed04..617948e6 100644 --- a/lib/installers/virt/qemu/qemu_install.v +++ b/lib/installers/virt/qemu/qemu_install.v @@ -14,7 +14,7 @@ pub mut: uninstall bool } -pub fn install_(args_ InstallArgs) ! { +pub fn install(args_ InstallArgs) ! { mut args := args_ mut version := '10.0.0' diff --git a/lib/installers/virt/youki/youki_actions.v b/lib/installers/virt/youki/youki_actions.v index bf678597..0b338cd2 100644 --- a/lib/installers/virt/youki/youki_actions.v +++ b/lib/installers/virt/youki/youki_actions.v @@ -12,7 +12,7 @@ import incubaid.herolib.installers.lang.python import os // checks if a certain version or above is installed -fn installed_() !bool { +fn installed() !bool { // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // res := os.execute('${osal.profile_path_source_and()!} youki version') // if res.exit_code != 0 { @@ -28,13 +28,13 @@ fn installed_() !bool { return false } -fn install_() ! { +fn install() ! { console.print_header('install youki') destroy()! build()! } -fn build_() ! { +fn build() ! { // mut installer := get()! url := 'https://github.com/containers/youki' @@ -73,7 +73,7 @@ fn ulist_get() !ulist.UList { } // uploads to S3 server if configured -fn upload_() ! { +fn upload() ! { // mut installer := get()! // installers.upload( // cmdname: 'youki' @@ -81,7 +81,7 @@ fn upload_() ! { // )! } -fn destroy_() ! { +fn destroy() ! { osal.package_remove(' runc ')! diff --git a/lib/installers/web/imagemagick/.heroscript b/lib/installers/web/imagemagick/.heroscript deleted file mode 100644 index 2d6c7f9a..00000000 --- a/lib/installers/web/imagemagick/.heroscript +++ /dev/null @@ -1,11 +0,0 @@ -!!hero_code.generate_installer - name: "imagemagick" - classname: "ImageMagick" - hasconfig: false - singleton: true - default: true - title: "" - templates: false - build: true - startupmanager: true - diff --git a/lib/installers/web/imagemagick/imagemagick.v b/lib/installers/web/imagemagick/imagemagick.v deleted file mode 100644 index 33037473..00000000 --- a/lib/installers/web/imagemagick/imagemagick.v +++ /dev/null @@ -1,18 +0,0 @@ -module imagemagick - -import incubaid.herolib.osal.core as osal -import incubaid.herolib.ui.console -import os - -// this gets the name of the directory -const installername = os.base(os.dir(@FILE)) - -// install imagemagick will return true if it was already installed -pub fn install_() ! { - console.print_header('install ${installername}') - if !osal.done_exists('install_${installername}') { - osal.package_install('imagemagick')! - osal.done_set('install_${installername}', 'OK')! - } - console.print_header('${installername} already done') -} diff --git a/lib/installers/web/imagemagick/imagemagick_actions.v b/lib/installers/web/imagemagick/imagemagick_actions.v deleted file mode 100644 index 9d16bfce..00000000 --- a/lib/installers/web/imagemagick/imagemagick_actions.v +++ /dev/null @@ -1,187 +0,0 @@ -module imagemagick - -import incubaid.herolib.osal.core as osal -import incubaid.herolib.ui.console -import incubaid.herolib.core.texttools -import incubaid.herolib.core.pathlib -import incubaid.herolib.osal.systemd -import incubaid.herolib.osal.startupmanager -import incubaid.herolib.installers.ulist -import incubaid.herolib.installers.lang.golang -import incubaid.herolib.installers.lang.rust -import incubaid.herolib.installers.lang.python -import os - -fn startupcmd() ![]startupmanager.ZProcessNewArgs { - mut installer := get()! - mut res := []startupmanager.ZProcessNewArgs{} - // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED - // res << startupmanager.ZProcessNewArgs{ - // name: 'imagemagick' - // cmd: 'imagemagick server' - // env: { - // 'HOME': '/root' - // } - // } - - return res -} - -fn running_() !bool { - mut installer := get()! - // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED - // this checks health of imagemagick - // curl http://localhost:3333/api/v1/s --oauth2-bearer 1234 works - // url:='http://127.0.0.1:${cfg.port}/api/v1' - // mut conn := httpconnection.new(name: 'imagemagick', url: url)! - - // if cfg.secret.len > 0 { - // conn.default_header.add(.authorization, 'Bearer ${cfg.secret}') - // } - // conn.default_header.add(.content_type, 'application/json') - // console.print_debug("curl -X 'GET' '${url}'/tags --oauth2-bearer ${cfg.secret}") - // r := conn.get_json_dict(prefix: 'tags', debug: false) or {return false} - // println(r) - // if true{panic("ssss")} - // tags := r['Tags'] or { return false } - // console.print_debug(tags) - // console.print_debug('imagemagick is answering.') - return false -} - -fn start_pre() ! { -} - -fn start_post() ! { -} - -fn stop_pre() ! { -} - -fn stop_post() ! { -} - -//////////////////// following actions are not specific to instance of the object - -// checks if a certain version or above is installed -fn installed_() !bool { - // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED - // res := os.execute('${osal.profile_path_source_and()!} imagemagick version') - // if res.exit_code != 0 { - // return false - // } - // r := res.output.split_into_lines().filter(it.trim_space().len > 0) - // if r.len != 1 { - // return error("couldn't parse imagemagick version.\n${res.output}") - // } - // if texttools.version(version) == texttools.version(r[0]) { - // return true - // } - return false -} - -// get the Upload List of the files -fn ulist_get() !ulist.UList { - // optionally build a UList which is all paths which are result of building, is then used e.g. in upload - return ulist.UList{} -} - -// uploads to S3 server if configured -fn upload_() ! { - // installers.upload( - // cmdname: 'imagemagick' - // source: '${gitpath}/target/x86_64-unknown-linux-musl/release/imagemagick' - // )! -} - -fn install_() ! { - console.print_header('install imagemagick') - // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED - // mut url := '' - // if core.is_linux_arm()! { - // url = 'https://github.com/imagemagick-dev/imagemagick/releases/download/v${version}/imagemagick_${version}_linux_arm64.tar.gz' - // } else if core.is_linux_intel()! { - // url = 'https://github.com/imagemagick-dev/imagemagick/releases/download/v${version}/imagemagick_${version}_linux_amd64.tar.gz' - // } else if core.is_osx_arm()! { - // url = 'https://github.com/imagemagick-dev/imagemagick/releases/download/v${version}/imagemagick_${version}_darwin_arm64.tar.gz' - // } else if core.is_osx_intel()! { - // url = 'https://github.com/imagemagick-dev/imagemagick/releases/download/v${version}/imagemagick_${version}_darwin_amd64.tar.gz' - // } else { - // return error('unsported platform') - // } - - // mut dest := osal.download( - // url: url - // minsize_kb: 9000 - // expand_dir: '/tmp/imagemagick' - // )! - - // //dest.moveup_single_subdir()! - - // mut binpath := dest.file_get('imagemagick')! - // osal.cmd_add( - // cmdname: 'imagemagick' - // source: binpath.path - // )! -} - -fn build_() ! { - // url := 'https://github.com/threefoldtech/imagemagick' - - // make sure we install base on the node - // if core.platform()!= .ubuntu { - // return error('only support ubuntu for now') - // } - // golang.install()! - - // console.print_header('build imagemagick') - - // gitpath := gittools.get_repo(coderoot: '/tmp/builder', url: url, reset: true, pull: true)! - - // cmd := ' - // cd ${gitpath} - // source ~/.cargo/env - // exit 1 #todo - // ' - // osal.execute_stdout(cmd)! - // - // //now copy to the default bin path - // mut binpath := dest.file_get('...')! - // adds it to path - // osal.cmd_add( - // cmdname: 'griddriver2' - // source: binpath.path - // )! -} - -fn destroy_() ! { - // mut systemdfactory := systemd.new()! - // systemdfactory.destroy("zinit")! - - // osal.process_kill_recursive(name:'zinit')! - // osal.cmd_delete('zinit')! - - // osal.package_remove(' - // podman - // conmon - // buildah - // skopeo - // runc - // ')! - - // //will remove all paths where go/bin is found - // osal.profile_path_add_remove(paths2delete:"go/bin")! - - // osal.rm(" - // podman - // conmon - // buildah - // skopeo - // runc - // /var/lib/containers - // /var/lib/podman - // /var/lib/buildah - // /tmp/podman - // /tmp/conmon - // ")! -} diff --git a/lib/installers/web/imagemagick/imagemagick_factory_.v b/lib/installers/web/imagemagick/imagemagick_factory_.v deleted file mode 100644 index 4889a19e..00000000 --- a/lib/installers/web/imagemagick/imagemagick_factory_.v +++ /dev/null @@ -1,205 +0,0 @@ -module imagemagick - -import incubaid.herolib.core.playbook { PlayBook } -import incubaid.herolib.ui.console -import json -import incubaid.herolib.osal.startupmanager -import time - -__global ( - imagemagick_global map[string]&ImageMagick - imagemagick_default string -) - -/////////FACTORY - -@[params] -pub struct ArgsGet { -pub mut: - name string = 'default' -} - -pub fn new(args ArgsGet) !&ImageMagick { - return &ImageMagick{} -} - -pub fn get(args ArgsGet) !&ImageMagick { - return new(args)! -} - -pub fn play(mut plbook PlayBook) ! { - if !plbook.exists(filter: 'imagemagick.') { - return - } - mut install_actions := plbook.find(filter: 'imagemagick.configure')! - if install_actions.len > 0 { - return error("can't configure imagemagick, because no configuration allowed for this installer.") - } - mut other_actions := plbook.find(filter: 'imagemagick.')! - for mut other_action in other_actions { - if other_action.name in ['destroy', 'install', 'build'] { - mut p := other_action.params - reset := p.get_default_false('reset') - if other_action.name == 'destroy' || reset { - console.print_debug('install action imagemagick.destroy') - destroy()! - } - if other_action.name == 'install' { - console.print_debug('install action imagemagick.install') - install()! - } - } - if other_action.name in ['start', 'stop', 'restart'] { - mut p := other_action.params - name := p.get('name')! - mut imagemagick_obj := get(name: name)! - console.print_debug('action object:\n${imagemagick_obj}') - if other_action.name == 'start' { - console.print_debug('install action imagemagick.${other_action.name}') - imagemagick_obj.start()! - } - - if other_action.name == 'stop' { - console.print_debug('install action imagemagick.${other_action.name}') - imagemagick_obj.stop()! - } - if other_action.name == 'restart' { - console.print_debug('install action imagemagick.${other_action.name}') - imagemagick_obj.restart()! - } - } - other_action.done = true - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////# LIVE CYCLE MANAGEMENT FOR INSTALLERS /////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////// - -fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.StartupManager { - // unknown - // screen - // zinit - // tmux - // systemd - match cat { - .screen { - console.print_debug("installer: imagemagick' startupmanager get screen") - return startupmanager.get(.screen)! - } - .zinit { - console.print_debug("installer: imagemagick' startupmanager get zinit") - return startupmanager.get(.zinit)! - } - .systemd { - console.print_debug("installer: imagemagick' startupmanager get systemd") - return startupmanager.get(.systemd)! - } - else { - console.print_debug("installer: imagemagick' startupmanager get auto") - return startupmanager.get(.auto)! - } - } -} - -pub fn (mut self ImageMagick) start() ! { - if self.running()! { - return - } - - console.print_header('installer: imagemagick start') - - if !installed()! { - install()! - } - - configure()! - - start_pre()! - - for zprocess in startupcmd()! { - mut sm := startupmanager_get(zprocess.startuptype)! - - console.print_debug('installer: imagemagick starting with ${zprocess.startuptype}...') - - sm.new(zprocess)! - - sm.start(zprocess.name)! - } - - start_post()! - - for _ in 0 .. 50 { - if self.running()! { - return - } - time.sleep(100 * time.millisecond) - } - return error('imagemagick did not install properly.') -} - -pub fn (mut self ImageMagick) install_start(args InstallArgs) ! { - switch(self.name) - self.install(args)! - self.start()! -} - -pub fn (mut self ImageMagick) stop() ! { - switch(self.name) - stop_pre()! - for zprocess in startupcmd()! { - mut sm := startupmanager_get(zprocess.startuptype)! - sm.stop(zprocess.name)! - } - stop_post()! -} - -pub fn (mut self ImageMagick) restart() ! { - switch(self.name) - self.stop()! - self.start()! -} - -pub fn (mut self ImageMagick) running() !bool { - switch(self.name) - - // walk over the generic processes, if not running return - for zprocess in startupcmd()! { - if zprocess.startuptype != .screen { - mut sm := startupmanager_get(zprocess.startuptype)! - r := sm.running(zprocess.name)! - if r == false { - return false - } - } - } - return running()! -} - -@[params] -pub struct InstallArgs { -pub mut: - reset bool -} - -pub fn (mut self ImageMagick) install(args InstallArgs) ! { - switch(self.name) - if args.reset || (!installed()!) { - install()! - } -} - -pub fn (mut self ImageMagick) build() ! { - switch(self.name) - build()! -} - -pub fn (mut self ImageMagick) destroy() ! { - switch(self.name) - self.stop() or {} - destroy()! -} - -// switch instance to be used for imagemagick -pub fn switch(name string) { -} diff --git a/lib/installers/web/imagemagick/imagemagick_model.v b/lib/installers/web/imagemagick/imagemagick_model.v deleted file mode 100644 index b4108881..00000000 --- a/lib/installers/web/imagemagick/imagemagick_model.v +++ /dev/null @@ -1,27 +0,0 @@ -module imagemagick - -import incubaid.herolib.data.paramsparser -import os - -pub const version = '0.0.0' -const singleton = true -const default = true - -// THIS THE THE SOURCE OF THE INFORMATION OF THIS FILE, HERE WE HAVE THE CONFIG OBJECT CONFIGURED AND MODELLED -@[heap] -pub struct ImageMagick { -pub mut: - name string = 'default' -} - -fn obj_init(obj_ ImageMagick) !ImageMagick { - // never call get here, only thing we can do here is work on object itself - mut obj := obj_ - panic('implement') - return obj -} - -// called before start if done -fn configure() ! { - // mut installer := get()! -} diff --git a/lib/installers/web/imagemagick/readme.md b/lib/installers/web/imagemagick/readme.md deleted file mode 100644 index 91ebc773..00000000 --- a/lib/installers/web/imagemagick/readme.md +++ /dev/null @@ -1,40 +0,0 @@ -# imagemagick - -To get started - -```v - - -import incubaid.herolib.installers.something.imagemagick as imagemagick_installer - -heroscript:=" -!!imagemagick.configure name:'test' - password: '1234' - port: 7701 - -!!imagemagick.start name:'test' reset:1 -" - -imagemagick_installer.play(heroscript=heroscript)! - -//or we can call the default and do a start with reset -//mut installer:= imagemagick_installer.get()! -//installer.start(reset:true)! - - - - -``` - -## example heroscript - -```hero -!!imagemagick.configure - homedir: '/home/user/imagemagick' - username: 'admin' - password: 'secretpassword' - title: 'Some Title' - host: 'localhost' - port: 8888 - -``` diff --git a/lib/installers/web/lighttpd/.heroscript b/lib/installers/web/lighttpd/.heroscript index a8f26fcd..223a70c8 100644 --- a/lib/installers/web/lighttpd/.heroscript +++ b/lib/installers/web/lighttpd/.heroscript @@ -8,4 +8,5 @@ templates: false build: true startupmanager: true + active: false diff --git a/lib/installers/web/lighttpd/lighttpd_actions.v b/lib/installers/web/lighttpd/lighttpd_actions.v index 116c9143..585cbb91 100644 --- a/lib/installers/web/lighttpd/lighttpd_actions.v +++ b/lib/installers/web/lighttpd/lighttpd_actions.v @@ -27,7 +27,7 @@ fn startupcmd() ![]startupmanager.ZProcessNewArgs { return res } -fn running_() !bool { +fn running() !bool { mut installer := get()! // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // this checks health of lighttpd @@ -64,7 +64,7 @@ fn stop_post() ! { //////////////////// following actions are not specific to instance of the object // checks if a certain version or above is installed -fn installed_() !bool { +fn installed() !bool { // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // res := os.execute('${osal.profile_path_source_and()!} lighttpd version') // if res.exit_code != 0 { @@ -87,14 +87,14 @@ fn ulist_get() !ulist.UList { } // uploads to S3 server if configured -fn upload_() ! { +fn upload() ! { // installers.upload( // cmdname: 'lighttpd' // source: '${gitpath}/target/x86_64-unknown-linux-musl/release/lighttpd' // )! } -fn install_() ! { +fn install() ! { console.print_header('install lighttpd') // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // mut url := '' @@ -125,7 +125,7 @@ fn install_() ! { // )! } -fn build_() ! { +fn build() ! { // url := 'https://github.com/threefoldtech/lighttpd' // make sure we install base on the node @@ -154,7 +154,7 @@ fn build_() ! { // )! } -fn destroy_() ! { +fn destroy() ! { // mut systemdfactory := systemd.new()! // systemdfactory.destroy("zinit")! diff --git a/lib/installers/web/zola/zola_actions.v b/lib/installers/web/zola/zola_actions.v index b0a362d5..b1794189 100644 --- a/lib/installers/web/zola/zola_actions.v +++ b/lib/installers/web/zola/zola_actions.v @@ -12,7 +12,7 @@ import os pub const version = '0.18.0' // checks if a certain version or above is installed -fn installed_() !bool { +fn installed() !bool { res := os.execute('${osal.profile_path_source_and()!} zola -V') myversion := res.output.all_after(' ') if res.exit_code == 0 { @@ -25,7 +25,7 @@ fn installed_() !bool { return false } -fn install_() ! { +fn install() ! { console.print_header('install zola') // make sure we install base on the node @@ -62,8 +62,9 @@ fn install_() ! { } // install zola will return true if it was already installed -fn build_() ! { - rust.install()! +fn build() ! { + mut r := rust.get()! + r.install()! console.print_header('install zola') cmd := ' source ~/.cargo/env @@ -81,5 +82,5 @@ fn build_() ! { console.print_header('zola installed') } -fn destroy_() ! { +fn destroy() ! { } diff --git a/lib/threefold/grid3/deployer/.heroscript b/lib/threefold/grid3/deployer/.heroscript index 32fc8a0c..72de07af 100644 --- a/lib/threefold/grid3/deployer/.heroscript +++ b/lib/threefold/grid3/deployer/.heroscript @@ -5,4 +5,5 @@ singleton:0 default:1 hasconfig:1 - reset:0 \ No newline at end of file + reset:0 + active:false \ No newline at end of file diff --git a/lib/installers/net/yggdrasil/.heroscript b/libwip/installers/yggdrasil/.heroscript similarity index 100% rename from lib/installers/net/yggdrasil/.heroscript rename to libwip/installers/yggdrasil/.heroscript diff --git a/lib/installers/net/yggdrasil/readme.md b/libwip/installers/yggdrasil/readme.md similarity index 100% rename from lib/installers/net/yggdrasil/readme.md rename to libwip/installers/yggdrasil/readme.md diff --git a/lib/installers/net/yggdrasil/ygg.v b/libwip/installers/yggdrasil/ygg.v similarity index 100% rename from lib/installers/net/yggdrasil/ygg.v rename to libwip/installers/yggdrasil/ygg.v diff --git a/lib/installers/net/yggdrasil/yggdrasil_actions.v b/libwip/installers/yggdrasil/yggdrasil_actions.v similarity index 100% rename from lib/installers/net/yggdrasil/yggdrasil_actions.v rename to libwip/installers/yggdrasil/yggdrasil_actions.v diff --git a/lib/installers/net/yggdrasil/yggdrasil_factory_.v b/libwip/installers/yggdrasil/yggdrasil_factory_.v similarity index 100% rename from lib/installers/net/yggdrasil/yggdrasil_factory_.v rename to libwip/installers/yggdrasil/yggdrasil_factory_.v diff --git a/lib/installers/net/yggdrasil/yggdrasil_model.v b/libwip/installers/yggdrasil/yggdrasil_model.v similarity index 100% rename from lib/installers/net/yggdrasil/yggdrasil_model.v rename to libwip/installers/yggdrasil/yggdrasil_model.v diff --git a/lib/installers/db/zerofs/.heroscript b/libwip/installers/zerofs/.heroscript similarity index 100% rename from lib/installers/db/zerofs/.heroscript rename to libwip/installers/zerofs/.heroscript diff --git a/lib/installers/db/zerofs/readme.md b/libwip/installers/zerofs/readme.md similarity index 100% rename from lib/installers/db/zerofs/readme.md rename to libwip/installers/zerofs/readme.md diff --git a/lib/installers/db/zerofs/rfs.v b/libwip/installers/zerofs/rfs.v similarity index 100% rename from lib/installers/db/zerofs/rfs.v rename to libwip/installers/zerofs/rfs.v diff --git a/lib/installers/db/zerofs/zerofs_actions.v b/libwip/installers/zerofs/zerofs_actions.v similarity index 100% rename from lib/installers/db/zerofs/zerofs_actions.v rename to libwip/installers/zerofs/zerofs_actions.v diff --git a/lib/installers/db/zerofs/zerofs_factory_.v b/libwip/installers/zerofs/zerofs_factory_.v similarity index 100% rename from lib/installers/db/zerofs/zerofs_factory_.v rename to libwip/installers/zerofs/zerofs_factory_.v diff --git a/lib/installers/db/zerofs/zerofs_model.v b/libwip/installers/zerofs/zerofs_model.v similarity index 100% rename from lib/installers/db/zerofs/zerofs_model.v rename to libwip/installers/zerofs/zerofs_model.v