Merge branch 'development' of github.com:freeflowuniverse/herolib into development
This commit is contained in:
@@ -134,7 +134,7 @@ Returns the current username.
|
||||
|
||||
## 2. Network Utilities
|
||||
|
||||
### `osal.ping(args: PingArgs) !PingResult`
|
||||
### `osal.ping(args: PingArgs) ! bool`
|
||||
Checks host reachability.
|
||||
* **Parameters**:
|
||||
### `osal.ipaddr_pub_get_check() !string`
|
||||
|
||||
@@ -23,12 +23,12 @@ This document describes the core functionalities of the Operating System Abstrac
|
||||
|
||||
## 2. Network Utilities
|
||||
|
||||
* **`osal.ping(args: PingArgs) !PingResult`**: Check host reachability.
|
||||
* **Key Parameters**: `address` (string).
|
||||
* **Returns**: `PingResult` (`.ok`, `.timeout`, `.unknownhost`).
|
||||
* **`osal.tcp_port_test(args: TcpPortTestArgs) bool`**: Test if a TCP port is open.
|
||||
* **Key Parameters**: `address` (string), `port` (int).
|
||||
* **`osal.ipaddr_pub_get() !string`**: Get public IP address.
|
||||
* **`osal.ping(args: PingArgs) !bool`**: Check host reachability.
|
||||
- address string = "8.8.8.8"
|
||||
- nr_ping u16 = 3 // amount of ping requests we will do
|
||||
- nr_ok u16 = 3 //how many of them need to be ok
|
||||
- retry u8 //how many times fo we retry above sequence, basically we ping ourselves with -c 1
|
||||
**`osal.ipaddr_pub_get() !string`**: Get public IP address.
|
||||
|
||||
## 3. File System Operations
|
||||
|
||||
|
||||
165
aiprompts/herolib_core/v_templates.md
Normal file
165
aiprompts/herolib_core/v_templates.md
Normal file
@@ -0,0 +1,165 @@
|
||||
V allows for easily using text templates, expanded at compile time to
|
||||
V functions, that efficiently produce text output. This is especially
|
||||
useful for templated HTML views, but the mechanism is general enough
|
||||
to be used for other kinds of text output also.
|
||||
|
||||
# Template directives
|
||||
|
||||
Each template directive begins with an `@` sign.
|
||||
Some directives contain a `{}` block, others only have `''` (string) parameters.
|
||||
|
||||
Newlines on the beginning and end are ignored in `{}` blocks,
|
||||
otherwise this (see [if](#if) for this syntax):
|
||||
|
||||
```html
|
||||
@if bool_val {
|
||||
<span>This is shown if bool_val is true</span>
|
||||
}
|
||||
```
|
||||
|
||||
... would output:
|
||||
|
||||
```html
|
||||
|
||||
<span>This is shown if bool_val is true</span>
|
||||
|
||||
```
|
||||
|
||||
... which is less readable.
|
||||
|
||||
## if
|
||||
|
||||
The if directive, consists of three parts, the `@if` tag, the condition (same syntax like in V)
|
||||
and the `{}` block, where you can write html, which will be rendered if the condition is true:
|
||||
|
||||
```
|
||||
@if <condition> {}
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```html
|
||||
@if bool_val {
|
||||
<span>This is shown if bool_val is true</span>
|
||||
}
|
||||
```
|
||||
|
||||
One-liner:
|
||||
|
||||
```html
|
||||
@if bool_val { <span>This is shown if bool_val is true</span> }
|
||||
```
|
||||
|
||||
The first example would result in:
|
||||
|
||||
```html
|
||||
<span>This is shown if bool_val is true</span>
|
||||
```
|
||||
|
||||
... while the one-liner results in:
|
||||
|
||||
```html
|
||||
<span>This is shown if bool_val is true</span>
|
||||
```
|
||||
|
||||
## for
|
||||
|
||||
The for directive consists of three parts, the `@for` tag,
|
||||
the condition (same syntax like in V) and the `{}` block,
|
||||
where you can write text, rendered for each iteration of the loop:
|
||||
|
||||
```
|
||||
@for <condition> {}
|
||||
```
|
||||
|
||||
### Example for @for
|
||||
|
||||
```html
|
||||
@for i, val in my_vals {
|
||||
<span>$i - $val</span>
|
||||
}
|
||||
```
|
||||
|
||||
One-liner:
|
||||
|
||||
```html
|
||||
@for i, val in my_vals { <span>$i - $val</span> }
|
||||
```
|
||||
|
||||
The first example would result in:
|
||||
|
||||
```html
|
||||
<span>0 - "First"</span>
|
||||
<span>1 - "Second"</span>
|
||||
<span>2 - "Third"</span>
|
||||
...
|
||||
```
|
||||
|
||||
... while the one-liner results in:
|
||||
|
||||
```html
|
||||
<span>0 - "First"</span>
|
||||
<span>1 - "Second"</span>
|
||||
<span>2 - "Third"</span>
|
||||
...
|
||||
```
|
||||
|
||||
You can also write (and all other for condition syntaxes that are allowed in V):
|
||||
|
||||
```html
|
||||
@for i = 0; i < 5; i++ {
|
||||
<span>$i</span>
|
||||
}
|
||||
```
|
||||
|
||||
## include
|
||||
|
||||
The include directive is for including other html files (which will be processed as well)
|
||||
and consists of two parts, the `@include` tag and a following `'<path>'` string.
|
||||
The path parameter is relative to the template file being called.
|
||||
|
||||
### Example for the folder structure of a project using templates:
|
||||
|
||||
```
|
||||
Project root
|
||||
/templates
|
||||
- index.html
|
||||
/headers
|
||||
- base.html
|
||||
```
|
||||
|
||||
`index.html`
|
||||
|
||||
```html
|
||||
|
||||
<div>@include 'header/base'</div>
|
||||
```
|
||||
|
||||
> Note that there shouldn't be a file suffix,
|
||||
> it is automatically appended and only allows `html` files.
|
||||
|
||||
|
||||
## js
|
||||
|
||||
The js directive consists of two parts, the `@js` tag and `'<path>'` string,
|
||||
where you can insert your src
|
||||
|
||||
```
|
||||
@js '<url>'
|
||||
```
|
||||
|
||||
### Example for the @js directive:
|
||||
|
||||
```html
|
||||
@js 'myscripts.js'
|
||||
```
|
||||
|
||||
# Variables
|
||||
|
||||
All variables, which are declared before the $tmpl can be used through the `@{my_var}` syntax.
|
||||
It's also possible to use properties of structs here like `@{my_struct.prop}`.
|
||||
|
||||
# Escaping
|
||||
|
||||
The `@` symbol starts a template directive. If you need to use `@` as a regular
|
||||
character within a template, escape it by using a double `@` like this: `@@`.
|
||||
@@ -761,9 +761,7 @@ this document has info about the most core functions, more detailed info can be
|
||||
|
||||
### 2. Network Utilities
|
||||
|
||||
* **`osal.ping(args: PingArgs) !PingResult`**: Check host reachability.
|
||||
* **Key Parameters**: `address` (string).
|
||||
* **Returns**: `PingResult` (`.ok`, `.timeout`, `.unknownhost`).
|
||||
* **`osal.ping(args: PingArgs) !bool`**: Check host reachability.
|
||||
* **`osal.tcp_port_test(args: TcpPortTestArgs) bool`**: Test if a TCP port is open.
|
||||
* **Key Parameters**: `address` (string), `port` (int).
|
||||
* **`osal.ipaddr_pub_get() !string`**: Get public IP address.
|
||||
|
||||
@@ -38,7 +38,7 @@ fn do() ! {
|
||||
|
||||
if os.args.len == 2 {
|
||||
mypath := os.args[1]
|
||||
if mypath.to_lower().ends_with('.hero') {
|
||||
if mypath.to_lower().ends_with('.hero') || mypath.to_lower().ends_with('.heroscript') || mypath.to_lower().ends_with('.hs') {
|
||||
// hero was called from a file
|
||||
playcmds_do(mypath)!
|
||||
return
|
||||
@@ -94,7 +94,7 @@ fn do() ! {
|
||||
|
||||
fn main() {
|
||||
do() or {
|
||||
$dbg;
|
||||
// $dbg;
|
||||
eprintln('Error: ${err}')
|
||||
print_backtrace()
|
||||
exit(1)
|
||||
|
||||
7
examples/builder/heroscript_example.hs
Normal file
7
examples/builder/heroscript_example.hs
Normal file
@@ -0,0 +1,7 @@
|
||||
!!node.new
|
||||
name:'mynode'
|
||||
ipaddr:'127.0.0.1'
|
||||
|
||||
!!cmd.run
|
||||
node:'mynode'
|
||||
cmd:'ls /'
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.clients.zinit
|
||||
import freeflowuniverse.herolib.installers.infra.zinit_installer
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.data.dbfs
|
||||
import time
|
||||
import os
|
||||
|
||||
data_dir := '/tmp/db'
|
||||
os.rmdir_all(data_dir) or {}
|
||||
mut dbcollection := dbfs.get(contextid: 1, dbpath: data_dir, secret: '123456')!
|
||||
|
||||
mut db := dbcollection.db_create(name: 'db_a', encrypted: true, withkeys: true)!
|
||||
|
||||
id := db.set(key: 'a', value: 'bbbb')!
|
||||
assert 'bbbb' == db.get(key: 'a')!
|
||||
|
||||
id2 := db.set(key: 'a', value: 'bbbb2')!
|
||||
assert 'bbbb2' == db.get(key: 'a')!
|
||||
assert id == id2
|
||||
assert id == 1
|
||||
|
||||
id3 := db.set(key: 'b', value: 'bbbb3')!
|
||||
assert 'bbbb3' == db.get(key: 'b')!
|
||||
assert id3 == id2 + 1
|
||||
|
||||
assert db.exists(key: 'a')!
|
||||
assert db.exists(key: 'b')!
|
||||
assert db.exists(id: id2)!
|
||||
assert db.exists(id: id3)!
|
||||
id3_exsts := db.exists(id: id3 + 1)!
|
||||
println(id3 + 1)
|
||||
assert id3_exsts == false
|
||||
|
||||
for i in 3 .. 100 {
|
||||
id4 := db.set(key: 'a${i}', value: 'b${i}')!
|
||||
println('${i} --> ${id4}')
|
||||
assert i == id4
|
||||
}
|
||||
|
||||
db.delete(key: 'a')!
|
||||
assert db.exists(key: 'a')! == false
|
||||
assert db.exists(id: id2)! == false
|
||||
|
||||
db.delete(id: 50)!
|
||||
assert db.exists(key: 'a50')! == false
|
||||
assert db.exists(id: 50)! == false
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.crypt.secrets
|
||||
|
||||
secrets.delete_passwd()!
|
||||
r := secrets.encrypt('aaa')!
|
||||
println(r)
|
||||
assert 'aaa' == secrets.decrypt(r)!
|
||||
5
examples/installers/infra/.gitignore
vendored
Normal file
5
examples/installers/infra/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
zinit_installer
|
||||
dify
|
||||
screen
|
||||
livekit
|
||||
gitea
|
||||
Binary file not shown.
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.installers.infra.livekit as livekit_installer
|
||||
|
||||
mut livekit := livekit_installer.get()!
|
||||
mut livekit := livekit_installer.get(create: true)!
|
||||
livekit.install()!
|
||||
livekit.start()!
|
||||
livekit.destroy()!
|
||||
|
||||
6
examples/installers_remote/hero_compile.hero
Executable file
6
examples/installers_remote/hero_compile.hero
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env hero
|
||||
|
||||
//root@65.21.132.119
|
||||
|
||||
|
||||
!!herolib.compile reset:1
|
||||
@@ -33,7 +33,7 @@ fn main() {
|
||||
// Test 2: Status check
|
||||
console.print_header('Test 2: Status Check')
|
||||
result2 := os.execute('${hero_bin} sshagent status')
|
||||
if result2.exit_code == 0 && result2.output.contains("- SSH Agent Status") {
|
||||
if result2.exit_code == 0 && result2.output.contains('- SSH Agent Status') {
|
||||
console.print_green('✓ Status check successful')
|
||||
println(result2.output)
|
||||
} else {
|
||||
|
||||
58
examples/threefold/incatokens/data/simulation.hero
Normal file
58
examples/threefold/incatokens/data/simulation.hero
Normal file
@@ -0,0 +1,58 @@
|
||||
!!incatokens.simulate
|
||||
name: 'inca_mainnet_simulation'
|
||||
total_supply: 10000000000
|
||||
public_pct: 0.50
|
||||
team_pct: 0.15
|
||||
treasury_pct: 0.15
|
||||
investor_pct: 0.20
|
||||
nrcol: 60
|
||||
currency: 'USD'
|
||||
epoch1_floor_uplift: 1.20
|
||||
epochn_floor_uplift: 1.20
|
||||
amm_liquidity_depth_factor: 2.0
|
||||
team_cliff_months: 12
|
||||
team_vesting_months: 36
|
||||
treasury_cliff_months: 12
|
||||
treasury_vesting_months: 48
|
||||
export_dir: './simulation_output'
|
||||
generate_csv: true
|
||||
generate_charts: true
|
||||
generate_report: true
|
||||
|
||||
!!incatokens.scenario
|
||||
name: 'Conservative'
|
||||
demands: [8000000, 8000000, 0]
|
||||
amm_trades: [0, 0, 0]
|
||||
|
||||
!!incatokens.scenario
|
||||
name: 'Moderate'
|
||||
demands: [25000000, 50000000, 0]
|
||||
amm_trades: [0, 0, 0]
|
||||
|
||||
!!incatokens.scenario
|
||||
name: 'Optimistic'
|
||||
demands: [50000000, 100000000, 0]
|
||||
amm_trades: [5000000, 10000000, 0]
|
||||
|
||||
!!incatokens.investor_round
|
||||
name: 'Seed'
|
||||
allocation_pct: 0.03
|
||||
price: 0.003
|
||||
cliff_months: 6
|
||||
vesting_months: 24
|
||||
|
||||
!!incatokens.investor_round
|
||||
name: 'Series_A'
|
||||
allocation_pct: 0.07
|
||||
price: 0.008
|
||||
cliff_months: 6
|
||||
vesting_months: 24
|
||||
|
||||
!!incatokens.investor_round
|
||||
name: 'Series_B'
|
||||
allocation_pct: 0.10
|
||||
price: 0.012
|
||||
cliff_months: 3
|
||||
vesting_months: 18
|
||||
|
||||
!!incatokens.export path:"/tmp/incatokens_export"
|
||||
14
examples/threefold/incatokens/incatokens_simulate.vsh
Executable file
14
examples/threefold/incatokens/incatokens_simulate.vsh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.incatokens
|
||||
import os
|
||||
import freeflowuniverse.herolib.core.playcmds
|
||||
|
||||
current_dir := os.dir(@FILE)
|
||||
heroscript_path := '${current_dir}/data'
|
||||
|
||||
playcmds.run(
|
||||
heroscript_path: heroscript_path
|
||||
)!
|
||||
|
||||
println('Simulation complete!')
|
||||
44
examples/tmux/tmux_cleanup.heroscript
Normal file
44
examples/tmux/tmux_cleanup.heroscript
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env hero
|
||||
|
||||
// Tmux Cleanup Script - Tears down all tmux sessions, windows, and panes
|
||||
// Run this after tmux_setup.heroscript to clean up everything
|
||||
|
||||
// Kill specific windows first (optional - sessions will kill all windows anyway)
|
||||
!!tmux.window_delete
|
||||
name:"dev|editor"
|
||||
|
||||
!!tmux.window_delete
|
||||
name:"dev|server"
|
||||
|
||||
!!tmux.window_delete
|
||||
name:"dev|logs"
|
||||
|
||||
!!tmux.window_delete
|
||||
name:"dev|services"
|
||||
|
||||
!!tmux.window_delete
|
||||
name:"monitoring|htop"
|
||||
|
||||
!!tmux.window_delete
|
||||
name:"monitoring|network"
|
||||
|
||||
// Delete all sessions (this will kill all windows and panes within them)
|
||||
!!tmux.session_delete
|
||||
name:'dev'
|
||||
|
||||
!!tmux.session_delete
|
||||
name:'monitoring'
|
||||
|
||||
// Optional: Kill any remaining panes explicitly (usually not needed after session delete)
|
||||
!!tmux.pane_kill
|
||||
name:"dev|editor|main"
|
||||
|
||||
!!tmux.pane_kill
|
||||
name:"dev|server|main"
|
||||
|
||||
!!tmux.pane_kill
|
||||
name:"monitoring|htop|main"
|
||||
|
||||
// Stop any remaining ttyd processes system-wide
|
||||
// This will clean up all ttyd processes regardless of which sessions exist
|
||||
!!tmux.ttyd_stop_all
|
||||
107
examples/tmux/tmux_setup.heroscript
Executable file
107
examples/tmux/tmux_setup.heroscript
Executable file
@@ -0,0 +1,107 @@
|
||||
#!/usr/bin/env hero
|
||||
|
||||
// Create development session
|
||||
!!tmux.session_create
|
||||
name:'dev'
|
||||
reset:true
|
||||
|
||||
// Create monitoring session
|
||||
!!tmux.session_create
|
||||
name:'monitoring'
|
||||
reset:true
|
||||
|
||||
// Create development windows (use reset to ensure clean state)
|
||||
!!tmux.window_create
|
||||
name:"dev|editor"
|
||||
cmd:'vim'
|
||||
reset:true
|
||||
|
||||
!!tmux.window_create
|
||||
name:"dev|server"
|
||||
cmd:'python3 -m http.server 8000'
|
||||
env:'PORT=8000,DEBUG=true'
|
||||
reset:true
|
||||
|
||||
!!tmux.window_create
|
||||
name:"dev|logs"
|
||||
cmd:'tail -f /var/log/system.log'
|
||||
reset:true
|
||||
|
||||
// Create monitoring windows
|
||||
!!tmux.window_create
|
||||
name:"monitoring|htop"
|
||||
cmd:'htop'
|
||||
reset:true
|
||||
|
||||
!!tmux.window_create
|
||||
name:"monitoring|network"
|
||||
cmd:'netstat -tuln'
|
||||
reset:true
|
||||
|
||||
// Create a multi-service window with 4 panes
|
||||
!!tmux.window_create
|
||||
name:"dev|services"
|
||||
cmd:'htop'
|
||||
reset:true
|
||||
|
||||
// Split the services window into 4 panes (1 initial + 3 splits = 4 total)
|
||||
!!tmux.pane_split
|
||||
name:"dev|services"
|
||||
cmd:'python3 -m http.server 3000'
|
||||
horizontal:true
|
||||
|
||||
!!tmux.pane_split
|
||||
name:"dev|services"
|
||||
cmd:'watch -n 1 ps aux'
|
||||
horizontal:false
|
||||
|
||||
!!tmux.pane_split
|
||||
name:"dev|services"
|
||||
cmd:'tail -f /var/log/system.log'
|
||||
horizontal:true
|
||||
|
||||
!!tmux.pane_split
|
||||
name:"dev|services"
|
||||
cmd:'echo Fourth pane ready for commands'
|
||||
horizontal:false
|
||||
|
||||
// Execute welcome commands in panes
|
||||
!!tmux.pane_execute
|
||||
name:"dev|editor|main"
|
||||
cmd:'echo Welcome to the editor pane'
|
||||
|
||||
!!tmux.pane_execute
|
||||
name:"dev|server|main"
|
||||
cmd:'echo Starting development server'
|
||||
|
||||
!!tmux.pane_execute
|
||||
name:"monitoring|htop|main"
|
||||
cmd:'echo System monitoring active'
|
||||
|
||||
// Split panes for better workflow
|
||||
!!tmux.pane_split
|
||||
name:"dev|editor"
|
||||
cmd:'echo Split pane for terminal'
|
||||
horizontal:false
|
||||
|
||||
!!tmux.pane_split
|
||||
name:"monitoring|htop"
|
||||
cmd:'watch -n 1 df -h'
|
||||
horizontal:true
|
||||
|
||||
// Expose sessions and windows via web browser using ttyd
|
||||
!!tmux.session_ttyd
|
||||
name:'dev'
|
||||
port:8080
|
||||
editable:true
|
||||
|
||||
!!tmux.window_ttyd
|
||||
name:"monitoring|htop"
|
||||
port:8081
|
||||
editable:false
|
||||
|
||||
// Expose the 4-pane services window via web
|
||||
!!tmux.window_ttyd
|
||||
name:"dev|services"
|
||||
port:7681
|
||||
editable:false
|
||||
1
examples/virt/hetzner/.gitignore
vendored
Normal file
1
examples/virt/hetzner/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
hetzner_example
|
||||
37
examples/virt/hetzner/hetzner_example.hero
Executable file
37
examples/virt/hetzner/hetzner_example.hero
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env hero
|
||||
|
||||
|
||||
// !!hetznermanager.configure
|
||||
// name:"main"
|
||||
// user:"krist"
|
||||
// whitelist:"2111181, 2392178, 2545053, 2542166, 2550508, 2550378,2550253"
|
||||
// password:"wontsethere"
|
||||
// sshkey:"kristof"
|
||||
|
||||
|
||||
// !!hetznermanager.server_rescue
|
||||
// server_name: 'kristof21' // The name of the server to manage (or use `id`)
|
||||
// wait: true // Wait for the operation to complete
|
||||
// hero_install: true // Automatically install Herolib in the rescue system
|
||||
|
||||
|
||||
// # Reset a server
|
||||
// !!hetznermanager.server_reset
|
||||
// instance: 'main'
|
||||
// server_name: 'your-server-name'
|
||||
// wait: true
|
||||
|
||||
// # Add a new SSH key to your Hetzner account
|
||||
// !!hetznermanager.key_create
|
||||
// instance: 'main'
|
||||
// key_name: 'my-laptop-key'
|
||||
// data: 'ssh-rsa AAAA...'
|
||||
|
||||
|
||||
// Install Ubuntu 24.04 on a server
|
||||
!!hetznermanager.ubuntu_install
|
||||
server_name: 'kristof2'
|
||||
wait: true
|
||||
hero_install: true // Install Herolib on the new OS
|
||||
|
||||
|
||||
@@ -1,40 +1,68 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.virt.hetzner
|
||||
import freeflowuniverse.herolib.virt.hetznermanager
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.base
|
||||
import freeflowuniverse.herolib.builder
|
||||
import time
|
||||
import os
|
||||
import freeflowuniverse.herolib.core.playcmds
|
||||
|
||||
console.print_header('Hetzner login.')
|
||||
|
||||
// USE IF YOU WANT TO CONFIGURE THE HETZNER, ONLY DO THIS ONCE
|
||||
// hetzner.configure("test")!
|
||||
|
||||
mut cl := hetzner.get('test')!
|
||||
|
||||
for i in 0 .. 5 {
|
||||
println('test cache, first time slow then fast')
|
||||
cl.servers_list()!
|
||||
user := os.environ()['HETZNER_USER'] or {
|
||||
println('HETZNER_USER not set')
|
||||
exit(1)
|
||||
}
|
||||
passwd := os.environ()['HETZNER_PASSWORD'] or {
|
||||
println('HETZNER_PASSWORD not set')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
println(cl.servers_list()!)
|
||||
hs := '
|
||||
!!hetznermanager.configure
|
||||
user:"${user}"
|
||||
whitelist:"2111181, 2392178, 2545053, 2542166, 2550508, 2550378,2550253"
|
||||
password:"${passwd}"
|
||||
sshkey:"kristof"
|
||||
'
|
||||
|
||||
mut serverinfo := cl.server_info_get(name: 'kristof2')!
|
||||
println(hs)
|
||||
|
||||
println(serverinfo)
|
||||
playcmds.run(heroscript: hs)!
|
||||
|
||||
console.print_header('Hetzner Test.')
|
||||
|
||||
mut cl := hetznermanager.get()!
|
||||
// println(cl)
|
||||
|
||||
// for i in 0 .. 5 {
|
||||
// println('test cache, first time slow then fast')
|
||||
// }
|
||||
|
||||
// println(cl.servers_list()!)
|
||||
|
||||
// mut serverinfo := cl.server_info_get(name: 'kristof2')!
|
||||
|
||||
// println(serverinfo)
|
||||
|
||||
// cl.server_reset(name:"kristof2",wait:true)!
|
||||
|
||||
// cl.server_rescue(name:"kristof2",wait:true)!
|
||||
|
||||
console.print_header('SSH login')
|
||||
mut b := builder.new()!
|
||||
mut n := b.node_new(ipaddr: serverinfo.server_ip)!
|
||||
|
||||
// n.hero_install()!
|
||||
// n.hero_compile_debug()!
|
||||
// don't forget to specify the keyname needed
|
||||
// cl.server_rescue(name:"kristof2",wait:true, hero_install:true,sshkey_name:"kristof")!
|
||||
|
||||
// mut ks:=cl.keys_get()!
|
||||
// println(ks)
|
||||
|
||||
// console.print_header('SSH login')
|
||||
// mut b := builder.new()!
|
||||
// mut n := b.node_new(ipaddr: serverinfo.server_ip)!
|
||||
|
||||
// this will put hero in debug mode on the system
|
||||
// n.hero_install(compile:true)!
|
||||
|
||||
// n.shell("")!
|
||||
|
||||
// cl.ubuntu_install(name: 'kristof2', wait: true, hero_install: true)!
|
||||
// cl.ubuntu_install(name: 'kristof20', wait: true, hero_install: true)!
|
||||
// cl.ubuntu_install(id:2550378, name: 'kristof21', wait: true, hero_install: true)!
|
||||
// cl.ubuntu_install(id:2550508, name: 'kristof22', wait: true, hero_install: true)!
|
||||
cl.ubuntu_install(id: 2550253, name: 'kristof23', wait: true, hero_install: true)!
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.virt.lima
|
||||
// import freeflowuniverse.herolib.virt.lima
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.installers.virt.lima as limainstaller
|
||||
import os
|
||||
|
||||
limainstaller.install()!
|
||||
mut i := limainstaller.get(create: true)!
|
||||
i.install(reset: true)!
|
||||
|
||||
mut virtmanager := lima.new()!
|
||||
// mut virtmanager := lima.new()!
|
||||
|
||||
virtmanager.vm_delete_all()!
|
||||
// virtmanager.vm_delete_all()!
|
||||
|
||||
// virtmanager.vm_new(reset:true,template:.alpine,name:'alpine',install_hero:false)!
|
||||
// // virtmanager.vm_new(reset:true,template:.alpine,name:'alpine',install_hero:false)!
|
||||
|
||||
// virtmanager.vm_new(reset:true,template:.arch,name:'arch',install_hero:true)!
|
||||
// // virtmanager.vm_new(reset:true,template:.arch,name:'arch',install_hero:true)!
|
||||
|
||||
virtmanager.vm_new(reset: true, template: .ubuntucloud, name: 'hero', install_hero: false)!
|
||||
mut vm := virtmanager.vm_get('hero')!
|
||||
// virtmanager.vm_new(reset: true, template: .ubuntucloud, name: 'hero', install_hero: false)!
|
||||
// mut vm := virtmanager.vm_get('hero')!
|
||||
|
||||
println(vm)
|
||||
// println(vm)
|
||||
|
||||
// vm.install_hero()!
|
||||
// // vm.install_hero()!
|
||||
|
||||
// console.print_debug_title("MYVM", vm.str())
|
||||
// // console.print_debug_title("MYVM", vm.str())
|
||||
|
||||
239
examples/virt/podman/podman.vsh
Executable file
239
examples/virt/podman/podman.vsh
Executable file
@@ -0,0 +1,239 @@
|
||||
#!/usr/bin/env -S v -n -w -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.virt.podman
|
||||
import freeflowuniverse.herolib.installers.virt.podman as podman_installer
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
console.print_header('🐳 Comprehensive Podman Module Demo')
|
||||
console.print_stdout('This demo showcases both Simple API and Factory API approaches')
|
||||
console.print_stdout('Note: This demo requires podman to be available or will install it automatically')
|
||||
|
||||
// =============================================================================
|
||||
// SECTION 1: INSTALLATION
|
||||
// =============================================================================
|
||||
|
||||
console.print_header('📦 Section 1: Podman Installation')
|
||||
|
||||
console.print_stdout('Installing podman automatically...')
|
||||
if mut installer := podman_installer.get() {
|
||||
installer.install() or {
|
||||
console.print_stdout('⚠️ Podman installation failed (may already be installed): ${err}')
|
||||
}
|
||||
console.print_stdout('✅ Podman installation step completed')
|
||||
} else {
|
||||
console.print_stdout('⚠️ Failed to get podman installer, continuing with demo...')
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// SECTION 2: SIMPLE API DEMONSTRATION
|
||||
// =============================================================================
|
||||
|
||||
console.print_header('🚀 Section 2: Simple API Functions')
|
||||
|
||||
console.print_stdout('The Simple API provides direct functions for quick operations')
|
||||
|
||||
// Ensure podman machine is available before using Simple API
|
||||
console.print_stdout('Ensuring podman machine is available...')
|
||||
podman.ensure_machine_available() or {
|
||||
console.print_stdout('⚠️ Failed to ensure podman machine: ${err}')
|
||||
console.print_stdout('Continuing with demo - some operations may fail...')
|
||||
}
|
||||
|
||||
// Test 2.1: List existing containers and images
|
||||
console.print_stdout('\n📋 2.1 Listing existing resources...')
|
||||
|
||||
containers := podman.list_containers(true) or {
|
||||
console.print_stdout('⚠️ Failed to list containers: ${err}')
|
||||
[]podman.PodmanContainer{}
|
||||
}
|
||||
console.print_stdout('Found ${containers.len} containers (including stopped)')
|
||||
|
||||
images := podman.list_images() or {
|
||||
console.print_stdout('⚠️ Failed to list images: ${err}')
|
||||
[]podman.PodmanImage{}
|
||||
}
|
||||
console.print_stdout('Found ${images.len} images')
|
||||
|
||||
// Test 2.2: Run a simple container
|
||||
console.print_debug('\n🏃 2.2 Running a container with Simple API...')
|
||||
|
||||
options := podman.RunOptions{
|
||||
name: 'simple-demo-container'
|
||||
detach: true
|
||||
remove: true // Auto-remove when stopped
|
||||
env: {
|
||||
'DEMO_MODE': 'simple_api'
|
||||
'TEST_VAR': 'hello_world'
|
||||
}
|
||||
command: ['echo', 'Hello from Simple API container!']
|
||||
}
|
||||
|
||||
container_id := podman.run_container('alpine:latest', options) or {
|
||||
console.print_debug('⚠️ Failed to run container: ${err}')
|
||||
console.print_debug('This might be due to podman not being available or image not found')
|
||||
''
|
||||
}
|
||||
|
||||
if container_id != '' {
|
||||
console.print_debug('✅ Container started with ID: ${container_id[..12]}...')
|
||||
console.print_debug('Waiting for container to complete...')
|
||||
console.print_debug('✅ Container completed and auto-removed')
|
||||
} else {
|
||||
console.print_debug('❌ Container creation failed - continuing with demo...')
|
||||
}
|
||||
|
||||
// Test 2.3: Error handling demonstration
|
||||
console.print_debug('\n⚠️ 2.3 Error handling demonstration...')
|
||||
|
||||
podman.run_container('nonexistent:image', options) or {
|
||||
match err {
|
||||
podman.ImageError {
|
||||
console.print_debug('✅ Caught image error: ${err.msg()}')
|
||||
}
|
||||
podman.ContainerError {
|
||||
console.print_debug('✅ Caught container error: ${err.msg()}')
|
||||
}
|
||||
else {
|
||||
console.print_debug('✅ Caught other error: ${err.msg()}')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// SECTION 3: FACTORY API DEMONSTRATION
|
||||
// =============================================================================
|
||||
|
||||
console.print_header('🏭 Section 3: Factory API Pattern')
|
||||
|
||||
console.print_debug('The Factory API provides advanced workflows and state management')
|
||||
|
||||
// Test 3.1: Create factory
|
||||
console.print_debug('\n🔧 3.1 Creating PodmanFactory...')
|
||||
|
||||
if mut factory := podman.new(install: false, herocompile: false) {
|
||||
console.print_debug('✅ PodmanFactory created successfully')
|
||||
|
||||
// Test 3.2: Advanced container creation
|
||||
console.print_debug('\n📦 3.2 Creating container with advanced options...')
|
||||
|
||||
if container := factory.container_create(
|
||||
name: 'factory-demo-container'
|
||||
image_repo: 'alpine'
|
||||
image_tag: 'latest'
|
||||
command: 'sh -c "echo Factory API Demo && sleep 2 && echo Container completed"'
|
||||
memory: '128m'
|
||||
cpus: 0.5
|
||||
env: {
|
||||
'DEMO_MODE': 'factory_api'
|
||||
'CONTAINER_TYPE': 'advanced'
|
||||
}
|
||||
detach: true
|
||||
remove_when_done: true
|
||||
interactive: false
|
||||
)
|
||||
{
|
||||
console.print_debug('✅ Advanced container created: ${container.name} (${container.id[..12]}...)')
|
||||
|
||||
// Test 3.3: Container management
|
||||
console.print_debug('\n🎛️ 3.3 Container management operations...')
|
||||
|
||||
// Load current state
|
||||
factory.load() or { console.print_debug('⚠️ Failed to load factory state: ${err}') }
|
||||
|
||||
// List containers through factory
|
||||
factory_containers := factory.containers_get(name: '*demo*') or {
|
||||
console.print_debug('⚠️ No demo containers found: ${err}')
|
||||
[]&podman.Container{}
|
||||
}
|
||||
|
||||
console.print_debug('Found ${factory_containers.len} demo containers through factory')
|
||||
console.print_debug('Waiting for factory container to complete...')
|
||||
} else {
|
||||
console.print_debug('⚠️ Failed to create container: ${err}')
|
||||
}
|
||||
|
||||
// Test 3.4: Builder Integration (if available)
|
||||
console.print_debug('\n🔨 3.4 Builder Integration (Buildah)...')
|
||||
|
||||
if mut builder := factory.builder_new(
|
||||
name: 'demo-app-builder'
|
||||
from: 'alpine:latest'
|
||||
delete: true
|
||||
)
|
||||
{
|
||||
console.print_debug('✅ Builder created: ${builder.containername}')
|
||||
|
||||
// Simple build operations
|
||||
builder.run('apk add --no-cache curl') or {
|
||||
console.print_debug('⚠️ Failed to install packages: ${err}')
|
||||
}
|
||||
|
||||
builder.run('echo "echo Hello from built image" > /usr/local/bin/demo-app') or {
|
||||
console.print_debug('⚠️ Failed to create app: ${err}')
|
||||
}
|
||||
|
||||
builder.run('chmod +x /usr/local/bin/demo-app') or {
|
||||
console.print_debug('⚠️ Failed to make app executable: ${err}')
|
||||
}
|
||||
|
||||
// Configure and commit
|
||||
builder.set_entrypoint('/usr/local/bin/demo-app') or {
|
||||
console.print_debug('⚠️ Failed to set entrypoint: ${err}')
|
||||
}
|
||||
|
||||
builder.commit('demo-app:latest') or {
|
||||
console.print_debug('⚠️ Failed to commit image: ${err}')
|
||||
}
|
||||
|
||||
console.print_debug('✅ Image built and committed: demo-app:latest')
|
||||
|
||||
// Run container from built image
|
||||
if built_container_id := factory.create_from_buildah_image('demo-app:latest',
|
||||
podman.ContainerRuntimeConfig{
|
||||
name: 'demo-app-container'
|
||||
detach: true
|
||||
remove: true
|
||||
})
|
||||
{
|
||||
console.print_debug('✅ Container running from built image: ${built_container_id[..12]}...')
|
||||
} else {
|
||||
console.print_debug('⚠️ Failed to run container from built image: ${err}')
|
||||
}
|
||||
|
||||
// Cleanup builder
|
||||
factory.builder_delete('demo-app-builder') or {
|
||||
console.print_debug('⚠️ Failed to delete builder: ${err}')
|
||||
}
|
||||
} else {
|
||||
console.print_debug('⚠️ Failed to create builder (buildah may not be available): ${err}')
|
||||
}
|
||||
} else {
|
||||
console.print_debug('❌ Failed to create podman factory: ${err}')
|
||||
console.print_debug('This usually means podman is not installed or not accessible')
|
||||
console.print_debug('Skipping factory API demonstrations...')
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// DEMO COMPLETION
|
||||
// =============================================================================
|
||||
|
||||
console.print_header('🎉 Demo Completed Successfully!')
|
||||
|
||||
console.print_debug('This demo demonstrated the independent podman module:')
|
||||
console.print_debug(' ✅ Automatic podman installation')
|
||||
console.print_debug(' ✅ Simple API functions (run_container, list_containers, list_images)')
|
||||
console.print_debug(' ✅ Factory API pattern (advanced container creation)')
|
||||
console.print_debug(' ✅ Buildah integration (builder creation, image building)')
|
||||
console.print_debug(' ✅ Seamless podman-buildah workflows')
|
||||
console.print_debug(' ✅ Comprehensive error handling with module-specific types')
|
||||
console.print_debug(' ✅ Module independence (no shared dependencies)')
|
||||
console.print_debug('')
|
||||
console.print_debug('Key Features:')
|
||||
console.print_debug(' 🔒 Self-contained module with own error types')
|
||||
console.print_debug(' 🎯 Two API approaches: Simple functions & Factory pattern')
|
||||
console.print_debug(' 🔧 Advanced container configuration options')
|
||||
console.print_debug(' 🏗️ Buildah integration for image building')
|
||||
console.print_debug(' 📦 Ready for open source publication')
|
||||
console.print_debug('')
|
||||
console.print_debug('The podman module provides both simple and advanced APIs')
|
||||
console.print_debug('for all your container management needs! 🐳')
|
||||
4
examples/virt/podman_buildah/.gitignore
vendored
4
examples/virt/podman_buildah/.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
buildah_example
|
||||
buildah_run_clean
|
||||
buildah_run_mdbook
|
||||
buildah_run
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.virt.herocontainers
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.base
|
||||
import freeflowuniverse.herolib.osal
|
||||
import freeflowuniverse.herolib.installers.virt.podman as podman_installer
|
||||
|
||||
mut podman_installer0 := podman_installer.get()!
|
||||
// podman_installer0.destroy()!
|
||||
podman_installer0.install()!
|
||||
|
||||
// exit(0)
|
||||
|
||||
// interative means will ask for login/passwd
|
||||
|
||||
mut engine := herocontainers.new(install: true, herocompile: false)!
|
||||
|
||||
// engine.reset_all()!
|
||||
|
||||
// mut builder_gorust := engine.builder_go_rust()!
|
||||
|
||||
// will build nodejs, python build & herolib, hero
|
||||
// mut builder_hero := engine.builder_hero(reset:true)!
|
||||
|
||||
// mut builder_web := engine.builder_heroweb(reset:true)!
|
||||
|
||||
// builder_gorust.shell()!
|
||||
@@ -1,44 +0,0 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.virt.herocontainers
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.base
|
||||
// import freeflowuniverse.herolib.builder
|
||||
import time
|
||||
import os
|
||||
|
||||
// herocompile means we do it for the host system
|
||||
mut pm := herocontainers.new(herocompile: false, install: false)!
|
||||
|
||||
// pm.builder_base(reset:true)!
|
||||
|
||||
mut builder := pm.builder_get('base')!
|
||||
builder.shell()!
|
||||
|
||||
println(builder)
|
||||
|
||||
// builder.install_zinit()!
|
||||
|
||||
// bash & python can be executed directly in build container
|
||||
|
||||
// any of the herocommands can be executed like this
|
||||
// mybuildcontainer.run(cmd: 'installers -n heroweb', runtime: .herocmd)!
|
||||
|
||||
// //following will execute heroscript in the buildcontainer
|
||||
// mybuildcontainer.run(
|
||||
// cmd:"
|
||||
|
||||
// !!play.echo content:'this is just a test'
|
||||
|
||||
// !!play.echo content:'this is another test'
|
||||
|
||||
// ",
|
||||
// runtime:.heroscript)!
|
||||
|
||||
// there are also shortcuts for this
|
||||
|
||||
// mybuildcontainer.hero_copy()!
|
||||
// mybuildcontainer.shell()!
|
||||
|
||||
// mut b2:=pm.builder_get("builderv")!
|
||||
// b2.shell()!
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.virt.herocontainers
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
// import freeflowuniverse.herolib.builder
|
||||
import time
|
||||
import os
|
||||
|
||||
mut pm := herocontainers.new(herocompile: false)!
|
||||
|
||||
mut b := pm.builder_new()!
|
||||
|
||||
println(b)
|
||||
|
||||
// mut mybuildcontainer := pm.builder_get("builderv")!
|
||||
|
||||
// mybuildcontainer.clean()!
|
||||
|
||||
// mybuildcontainer.commit('localhost/buildersmall')!
|
||||
|
||||
b.shell()!
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import os
|
||||
import flag
|
||||
import freeflowuniverse.herolib.virt.herocontainers
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.base
|
||||
// import freeflowuniverse.herolib.builder
|
||||
import time
|
||||
|
||||
mut fp := flag.new_flag_parser(os.args)
|
||||
fp.application('buildah mdbook example')
|
||||
fp.limit_free_args(0, 0)! // comment this, if you expect arbitrary texts after the options
|
||||
fp.skip_executable()
|
||||
url := fp.string_opt('url', `u`, 'mdbook heroscript url')!
|
||||
|
||||
additional_args := fp.finalize() or {
|
||||
eprintln(err)
|
||||
println(fp.usage())
|
||||
return
|
||||
}
|
||||
|
||||
mut pm := herocontainers.new(herocompile: true, install: false)!
|
||||
|
||||
mut mybuildcontainer := pm.builder_get('builder_heroweb')!
|
||||
|
||||
// //bash & python can be executed directly in build container
|
||||
|
||||
// //any of the herocommands can be executed like this
|
||||
mybuildcontainer.run(cmd: 'installers -n heroweb', runtime: .herocmd)!
|
||||
|
||||
mybuildcontainer.run(cmd: 'hero mdbook -u ${url} -o', runtime: .bash)!
|
||||
@@ -10,8 +10,6 @@ import v.embed_file
|
||||
const heropath_ = os.dir(@FILE) + '/../'
|
||||
|
||||
pub struct BootStrapper {
|
||||
pub mut:
|
||||
embedded_files map[string]embed_file.EmbedFileData @[skip; str: skip]
|
||||
}
|
||||
|
||||
@[params]
|
||||
@@ -23,18 +21,9 @@ pub mut:
|
||||
debug bool
|
||||
}
|
||||
|
||||
fn (mut bs BootStrapper) load() {
|
||||
panic('not implemented')
|
||||
|
||||
// TODO: check how to install hero. maybe once we have releases, we could just download the binary
|
||||
// bs.embedded_files['install_base.sh'] = $embed_file('../../scripts/install_base.sh')
|
||||
// bs.embedded_files['install_hero.sh'] = $embed_file('../../scripts/install_hero.sh')
|
||||
}
|
||||
|
||||
// to use do something like: export NODES="195.192.213.3" .
|
||||
pub fn bootstrapper() BootStrapper {
|
||||
mut bs := BootStrapper{}
|
||||
bs.load()
|
||||
return bs
|
||||
}
|
||||
|
||||
@@ -48,51 +37,7 @@ pub fn (mut bs BootStrapper) run(args_ BootstrapperArgs) ! {
|
||||
name := '${args.name}_${counter}'
|
||||
mut n := b.node_new(ipaddr: a, name: name)!
|
||||
n.hero_install()!
|
||||
n.hero_install()!
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (mut node Node) upgrade() ! {
|
||||
mut bs := bootstrapper()
|
||||
install_base_content_ := bs.embedded_files['install_base.sh'] or { panic('bug') }
|
||||
install_base_content := install_base_content_.to_string()
|
||||
cmd := '${install_base_content}\n'
|
||||
node.exec_cmd(
|
||||
cmd: cmd
|
||||
period: 48 * 3600
|
||||
reset: false
|
||||
description: 'upgrade operating system packages'
|
||||
)!
|
||||
}
|
||||
|
||||
pub fn (mut node Node) hero_install() ! {
|
||||
console.print_debug('install hero')
|
||||
mut bs := bootstrapper()
|
||||
install_hero_content_ := bs.embedded_files['install_hero.sh'] or { panic('bug') }
|
||||
install_hero_content := install_hero_content_.to_string()
|
||||
if node.platform == .osx {
|
||||
// we have no choice then to do it interactive
|
||||
myenv := node.environ_get()!
|
||||
homedir := myenv['HOME'] or { return error("can't find HOME in env") }
|
||||
node.exec_silent('mkdir -p ${homedir}/hero/bin')!
|
||||
node.file_write('${homedir}/hero/bin/install.sh', install_hero_content)!
|
||||
node.exec_silent('chmod +x ${homedir}/hero/bin/install.sh')!
|
||||
node.exec_interactive('${homedir}/hero/bin/install.sh')!
|
||||
} else if node.platform == .ubuntu {
|
||||
myenv := node.environ_get()!
|
||||
homedir := myenv['HOME'] or { return error("can't find HOME in env") }
|
||||
node.exec_silent('mkdir -p ${homedir}/hero/bin')!
|
||||
node.file_write('${homedir}/hero/bin/install.sh', install_hero_content)!
|
||||
node.exec_silent('chmod +x ${homedir}/hero/bin/install.sh')!
|
||||
node.exec_interactive('${homedir}/hero/bin/install.sh')!
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (mut node Node) dagu_install() ! {
|
||||
console.print_debug('install dagu')
|
||||
if !osal.cmd_exists('dagu') {
|
||||
_ = bootstrapper()
|
||||
node.exec_silent('curl -L https://raw.githubusercontent.com/yohamta/dagu/main/scripts/downloader.sh | bash')!
|
||||
// n.hero_install()!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,47 +45,32 @@ pub fn (mut node Node) dagu_install() ! {
|
||||
pub struct HeroInstallArgs {
|
||||
pub mut:
|
||||
reset bool
|
||||
compile bool
|
||||
v_analyzer bool
|
||||
debug bool // will go in shell
|
||||
}
|
||||
|
||||
// pub fn (mut node Node) hero_install(args HeroInstallArgs) ! {
|
||||
// mut bs := bootstrapper()
|
||||
// install_base_content_ := bs.embedded_files['install_base.sh'] or { panic('bug') }
|
||||
// install_base_content := install_base_content_.to_string()
|
||||
pub fn (mut node Node) hero_install(args HeroInstallArgs) ! {
|
||||
console.print_debug('install hero')
|
||||
mut bs := bootstrapper()
|
||||
|
||||
// if args.reset {
|
||||
// console.clear()
|
||||
// console.print_debug('')
|
||||
// console.print_stderr('will remove: .vmodules, hero lib code and ~/hero')
|
||||
// console.print_debug('')
|
||||
// mut myui := ui.new()!
|
||||
// toinstall := myui.ask_yesno(
|
||||
// question: 'Ok to reset?'
|
||||
// default: true
|
||||
// )!
|
||||
// if !toinstall {
|
||||
// exit(1)
|
||||
// }
|
||||
// os.rmdir_all('${os.home_dir()}/.vmodules')!
|
||||
// os.rmdir_all('${os.home_dir()}/hero')!
|
||||
// os.rmdir_all('${os.home_dir()}/code/github/freeflowuniverse/herolib')!
|
||||
// os.rmdir_all('${os.home_dir()}/code/github/freeflowuniverse/webcomponents')!
|
||||
// }
|
||||
myenv := node.environ_get()!
|
||||
homedir := myenv['HOME'] or { return error("can't find HOME in env") }
|
||||
|
||||
// cmd := '
|
||||
// ${install_base_content}
|
||||
|
||||
// rm -f /usr/local/bin/hero
|
||||
// freeflow_dev_env_install
|
||||
|
||||
// ~/code/github/freeflowuniverse/herolib/install.sh
|
||||
|
||||
// echo HERO, V, CRYSTAL ALL INSTALL OK
|
||||
// echo WE ARE READY TO HERO...
|
||||
|
||||
// '
|
||||
// console.print_debug('executing cmd ${cmd}')
|
||||
// node.exec_cmd(cmd: cmd)!
|
||||
// }
|
||||
mut todo := []string{}
|
||||
if !args.compile {
|
||||
todo << 'curl https://raw.githubusercontent.com/freeflowuniverse/herolib/refs/heads/development/install_hero.sh > /tmp/install.sh'
|
||||
todo << 'bash /tmp/install.sh'
|
||||
} else {
|
||||
todo << "curl 'https://raw.githubusercontent.com/freeflowuniverse/herolib/refs/heads/development/install_v.sh' > /tmp/install_v.sh"
|
||||
if args.v_analyzer {
|
||||
todo << 'bash /tmp/install_v.sh --analyzer --herolib '
|
||||
} else {
|
||||
todo << 'bash /tmp/install_v.sh --herolib '
|
||||
}
|
||||
}
|
||||
node.exec_interactive(todo.join('\n'))!
|
||||
}
|
||||
|
||||
@[params]
|
||||
pub struct HeroUpdateArgs {
|
||||
|
||||
@@ -7,6 +7,7 @@ import freeflowuniverse.herolib.osal.rsync
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
import freeflowuniverse.herolib.data.ipaddress
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
|
||||
@[heap]
|
||||
pub struct ExecutorSSH {
|
||||
@@ -21,15 +22,6 @@ pub mut:
|
||||
|
||||
fn (mut executor ExecutorSSH) init() ! {
|
||||
if !executor.initialized {
|
||||
// if executor.ipaddr.port == 0 {
|
||||
// return error('port cannot be 0.\n${executor}')
|
||||
// }
|
||||
// TODO: need to call code from SSHAGENT do not reimplement here, not nicely done
|
||||
os.execute('pgrep -x ssh-agent || eval `ssh-agent -s`')
|
||||
|
||||
if executor.sshkey != '' {
|
||||
osal.exec(cmd: 'ssh-add ${executor.sshkey}')!
|
||||
}
|
||||
mut addr := executor.ipaddr.addr
|
||||
if addr == '' {
|
||||
addr = 'localhost'
|
||||
@@ -61,7 +53,16 @@ pub fn (mut executor ExecutorSSH) exec(args_ ExecArgs) !string {
|
||||
if executor.ipaddr.port > 10 {
|
||||
port = '-p ${executor.ipaddr.port}'
|
||||
}
|
||||
args.cmd = 'ssh -o StrictHostKeyChecking=no ${executor.user}@${executor.ipaddr.addr} ${port} "${args.cmd}"'
|
||||
|
||||
if args.cmd.contains('\n') {
|
||||
// need to upload the file first
|
||||
args.cmd = texttools.dedent(args.cmd)
|
||||
executor.file_write('/tmp/toexec.sh', args.cmd)!
|
||||
args.cmd = 'bash /tmp/toexec.sh'
|
||||
}
|
||||
|
||||
args.cmd = 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${executor.user}@${executor.ipaddr.addr} ${port} "${args.cmd}"'
|
||||
|
||||
res := osal.exec(cmd: args.cmd, stdout: args.stdout, debug: executor.debug)!
|
||||
return res.output
|
||||
}
|
||||
@@ -72,7 +73,16 @@ pub fn (mut executor ExecutorSSH) exec_interactive(args_ ExecArgs) ! {
|
||||
if executor.ipaddr.port > 10 {
|
||||
port = '-p ${executor.ipaddr.port}'
|
||||
}
|
||||
args.cmd = 'ssh -tt -o StrictHostKeyChecking=no ${executor.user}@${executor.ipaddr.addr} ${port} "${args.cmd}"'
|
||||
|
||||
if args.cmd.contains('\n') {
|
||||
args.cmd = texttools.dedent(args.cmd)
|
||||
// need to upload the file first
|
||||
executor.file_write('/tmp/toexec.sh', args.cmd)!
|
||||
args.cmd = 'bash /tmp/toexec.sh'
|
||||
}
|
||||
args.cmd = 'ssh -tt -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${executor.user}@${executor.ipaddr.addr} ${port} "${args.cmd}"'
|
||||
|
||||
console.print_debug(args.cmd)
|
||||
osal.execute_interactive(args.cmd)!
|
||||
}
|
||||
|
||||
|
||||
67
lib/builder/heroscript.md
Normal file
67
lib/builder/heroscript.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# Builder Module Heroscript
|
||||
|
||||
The Builder module can be controlled using Heroscript to define and interact with nodes.
|
||||
|
||||
## Defining a Node
|
||||
|
||||
You can define a new node using the `node.new` action.
|
||||
|
||||
```heroscript
|
||||
!!node.new
|
||||
name:'mynode'
|
||||
ipaddr:'127.0.0.1' // for a local node
|
||||
user:'root' // optional, defaults to root
|
||||
debug:false // optional
|
||||
reload:false // optional
|
||||
```
|
||||
|
||||
This will create a new node instance that can be referenced by its name in subsequent actions.
|
||||
|
||||
## Executing Commands
|
||||
|
||||
To execute a command on a previously defined node, use the `cmd.run` action.
|
||||
|
||||
```heroscript
|
||||
!!cmd.run
|
||||
node:'mynode'
|
||||
cmd:'ls -la /tmp'
|
||||
```
|
||||
|
||||
The `node` parameter should match the name of a node defined with `node.new`. The `cmd` parameter contains the command to be executed on that node.
|
||||
|
||||
## Example Playbook
|
||||
|
||||
Here is a full example of a Heroscript playbook for the builder module:
|
||||
|
||||
```heroscript
|
||||
!!node.new
|
||||
name:'local_node'
|
||||
ipaddr:'127.0.0.1'
|
||||
|
||||
!!node.new
|
||||
name:'remote_node'
|
||||
ipaddr:'user@remote.server.com:22'
|
||||
|
||||
!!cmd.run
|
||||
node:'local_node'
|
||||
cmd:'echo "Hello from local node"'
|
||||
|
||||
!!cmd.run
|
||||
node:'remote_node'
|
||||
cmd:'uname -a'
|
||||
|
||||
```
|
||||
|
||||
## Running a Playbook
|
||||
|
||||
To run a playbook, you can use the `play` function in `builder.play`.
|
||||
|
||||
```v
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import freeflowuniverse.herolib.builder
|
||||
|
||||
mut plbook := playbook.new(path: "path/to/your/playbook.hs")!
|
||||
builder.play(mut plbook)!
|
||||
```
|
||||
|
||||
This will parse the Heroscript file and execute the defined actions.
|
||||
@@ -1,9 +0,0 @@
|
||||
module builder
|
||||
|
||||
fn test_nodedb() {
|
||||
// TODO URGENT create tests for nodedb
|
||||
}
|
||||
|
||||
fn test_nodedone() {
|
||||
// TODO URGENT create tests for nodedone
|
||||
}
|
||||
60
lib/builder/play.v
Normal file
60
lib/builder/play.v
Normal file
@@ -0,0 +1,60 @@
|
||||
module builder
|
||||
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
// execute a playbook which can build nodes
|
||||
pub fn play(mut plbook playbook.PlayBook) ! {
|
||||
mut b := new()!
|
||||
|
||||
// Process actions to configure nodes
|
||||
actions := plbook.find(filter: 'node.new')!
|
||||
for action in actions {
|
||||
mut p := action.params
|
||||
mut n := b.node_new(
|
||||
name: p.get_default('name', '')!
|
||||
ipaddr: p.get_default('ipaddr', '')!
|
||||
user: p.get_default('user', 'root')!
|
||||
debug: p.get_default_false('debug')
|
||||
reload: p.get_default_false('reload')
|
||||
)!
|
||||
console.print_header('Created node: ${n.name}')
|
||||
}
|
||||
|
||||
// Process 'cmd.run' actions to execute commands on nodes
|
||||
cmd_actions := plbook.find(filter: 'cmd.run')!
|
||||
for action in cmd_actions {
|
||||
mut p := action.params
|
||||
node_name := p.get('node')!
|
||||
cmd := p.get('cmd')!
|
||||
|
||||
// a bit ugly but we don't have node management in a central place yet
|
||||
// this will get the node created previously
|
||||
// we need a better way to get the nodes, maybe from a global scope
|
||||
mut found_node := &Node{
|
||||
factory: &b
|
||||
}
|
||||
mut found := false
|
||||
nodes_to_find := plbook.find(filter: 'node.new')!
|
||||
for node_action in nodes_to_find {
|
||||
mut node_p := node_action.params
|
||||
if node_p.get_default('name', '')! == node_name {
|
||||
found_node = b.node_new(
|
||||
name: node_p.get_default('name', '')!
|
||||
ipaddr: node_p.get_default('ipaddr', '')!
|
||||
user: node_p.get_default('user', 'root')!
|
||||
)!
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
return error('Could not find node with name ${node_name}')
|
||||
}
|
||||
|
||||
console.print_debug('Executing command on node ${found_node.name}:\n${cmd}')
|
||||
result := found_node.exec_cmd(cmd: cmd)!
|
||||
console.print_debug('Result:\n${result}')
|
||||
}
|
||||
}
|
||||
@@ -131,37 +131,37 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
|
||||
// Handle access token generation
|
||||
mut token_create_actions := plbook.find(filter: 'livekit.token_create')!
|
||||
for mut action in token_create_actions {
|
||||
mut p := action.params
|
||||
// for mut action in token_create_actions {
|
||||
// mut p := action.params
|
||||
|
||||
client_name := texttools.name_fix(p.get_default('client', 'default')!)
|
||||
identity := p.get('identity')!
|
||||
name := p.get_default('name', identity)!
|
||||
room := p.get_default('room', '')!
|
||||
ttl := p.get_int_default('ttl', 21600)!
|
||||
can_publish := p.get_default_false('can_publish')
|
||||
can_subscribe := p.get_default_true('can_subscribe')
|
||||
can_publish_data := p.get_default_false('can_publish_data')
|
||||
// client_name := texttools.name_fix(p.get_default('client', 'default')!)
|
||||
// identity := p.get('identity')!
|
||||
// name := p.get_default('name', identity)!
|
||||
// room := p.get_default('room', '')!
|
||||
// ttl := p.get_int_default('ttl', 21600)!
|
||||
// can_publish := p.get_default_false('can_publish')
|
||||
// can_subscribe := p.get_default_true('can_subscribe')
|
||||
// can_publish_data := p.get_default_false('can_publish_data')
|
||||
|
||||
mut client := get(name: client_name)!
|
||||
// mut client := get(name: client_name)!
|
||||
|
||||
mut token := client.new_access_token(
|
||||
identity: identity
|
||||
name: name
|
||||
ttl: ttl
|
||||
)!
|
||||
// mut token := client.new_access_token(
|
||||
// identity: identity
|
||||
// name: name
|
||||
// ttl: ttl
|
||||
// )!
|
||||
|
||||
token.add_video_grant(VideoGrant{
|
||||
room: room
|
||||
room_join: true
|
||||
can_publish: can_publish
|
||||
can_subscribe: can_subscribe
|
||||
can_publish_data: can_publish_data
|
||||
})
|
||||
// token.add_video_grant(VideoGrant{
|
||||
// room: room
|
||||
// room_join: true
|
||||
// can_publish: can_publish
|
||||
// can_subscribe: can_subscribe
|
||||
// can_publish_data: can_publish_data
|
||||
// })
|
||||
|
||||
jwt := token.to_jwt()!
|
||||
console.print_header('Access token generated for "${identity}"')
|
||||
console.print_debug('Token: ${jwt}')
|
||||
action.done = true
|
||||
}
|
||||
// jwt := token.to_jwt()!
|
||||
// console.print_header('Access token generated for "${identity}"')
|
||||
// console.print_debug('Token: ${jwt}')
|
||||
// action.done = true
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -24,10 +24,8 @@ pub fn check() bool {
|
||||
// }
|
||||
|
||||
// TODO: might be dangerous if that one goes out
|
||||
ping_result := osal.ping(address: '40a:152c:b85b:9646:5b71:d03a:eb27:2462', retry: 2) or {
|
||||
return false
|
||||
}
|
||||
if ping_result == .ok {
|
||||
ping_result := osal.ping(address: '40a:152c:b85b:9646:5b71:d03a:eb27:2462') or { panic(err) }
|
||||
if ping_result {
|
||||
console.print_debug('could reach 40a:152c:b85b:9646:5b71:d03a:eb27:2462')
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -99,10 +99,7 @@ pub fn (mut c ZinitRPC) service_create(name string, config ServiceConfig) !strin
|
||||
name: name
|
||||
content: config
|
||||
}
|
||||
println(params)
|
||||
// $dbg;
|
||||
request := jsonrpc.new_request_generic('service_create', params)
|
||||
// $dbg;
|
||||
return client.send[ServiceCreateParams, string](request)!
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ pub fn get(args ArgsGet) !&${args.classname} {
|
||||
if r.hexists('context:${args.name}', args.name)! {
|
||||
data := r.hget('context:${args.name}', args.name)!
|
||||
if data.len == 0 {
|
||||
print_backtrace()
|
||||
return error('${args.classname} with name: ${args.name} does not exist, prob bug.')
|
||||
}
|
||||
mut obj := json.decode(${args.classname},data)!
|
||||
@@ -62,12 +63,14 @@ pub fn get(args ArgsGet) !&${args.classname} {
|
||||
if args.create {
|
||||
new(args)!
|
||||
}else{
|
||||
print_backtrace()
|
||||
return error("${args.classname} with name '${args.name}' does not exist")
|
||||
}
|
||||
}
|
||||
return get(name: args.name)! //no longer from db nor create
|
||||
}
|
||||
return ${args.name}_global[args.name] or {
|
||||
print_backtrace()
|
||||
return error('could not get config for ${args.name} with name:${args.name}')
|
||||
}
|
||||
}
|
||||
@@ -153,10 +156,11 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
mut install_actions := plbook.find(filter: '${args.name}.configure')!
|
||||
if install_actions.len > 0 {
|
||||
@if args.hasconfig
|
||||
for install_action in install_actions {
|
||||
for mut install_action in install_actions {
|
||||
heroscript := install_action.heroscript()
|
||||
mut obj2 := heroscript_loads(heroscript)!
|
||||
set(obj2)!
|
||||
install_action.done = true
|
||||
}
|
||||
@else
|
||||
return error("can't configure ${args.name}, because no configuration allowed for this installer.")
|
||||
@@ -164,7 +168,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
@if args.cat == .installer
|
||||
mut other_actions := plbook.find(filter: '${args.name}.')!
|
||||
for other_action in other_actions {
|
||||
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")
|
||||
@@ -198,6 +202,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
}
|
||||
@end
|
||||
other_action.done = true
|
||||
}
|
||||
@end
|
||||
}
|
||||
@@ -218,18 +223,18 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat{
|
||||
.screen {
|
||||
console.print_debug("startupmanager: screen")
|
||||
console.print_debug("installer: ${args.name}' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit{
|
||||
console.print_debug("startupmanager: zinit")
|
||||
console.print_debug("installer: ${args.name}' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd{
|
||||
console.print_debug("startupmanager: systemd")
|
||||
console.print_debug("installer: ${args.name}' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}else{
|
||||
console.print_debug("startupmanager: auto")
|
||||
console.print_debug("installer: ${args.name}' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -255,7 +260,7 @@ pub fn (mut self ${args.classname}) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('${args.name} start')
|
||||
console.print_header('installer: ${args.name} start')
|
||||
|
||||
if ! installed()!{
|
||||
install()!
|
||||
@@ -268,7 +273,7 @@ pub fn (mut self ${args.classname}) start() ! {
|
||||
for zprocess in startupcmd()!{
|
||||
mut sm:=startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting ${args.name} with ??{zprocess.startuptype}...')
|
||||
console.print_debug('installer: ${args.name} starting with ??{zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -95,7 +95,6 @@ fn cmd_bootstrap_execute(cmd Command) ! {
|
||||
if develop {
|
||||
// n.crystal_install(reset: reset)!
|
||||
n.hero_install()!
|
||||
n.dagu_install()!
|
||||
} else {
|
||||
panic('implement, need to download here and install')
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ fn cmd_init_execute(cmd Command) ! {
|
||||
}
|
||||
if hero {
|
||||
base.install(reset: reset, develop: true)!
|
||||
herolib.install(reset: reset, git_pull: git_pull, git_reset: git_reset)!
|
||||
herolib.install(reset: reset)!
|
||||
base.redis_install()!
|
||||
herolib.hero_compile(reset: reset)!
|
||||
herolib.compile(reset: reset, git_pull: git_pull, git_reset: git_reset)!
|
||||
r := osal.profile_path_add_hero()!
|
||||
console.print_header(' add path ${r} to profile.')
|
||||
return
|
||||
|
||||
@@ -51,8 +51,13 @@ pub fn (mut h HTTPConnection) send(req_ Request) !Result {
|
||||
mut from_cache := false // used to know if result came from cache
|
||||
mut req := req_
|
||||
|
||||
is_cacheable := h.is_cacheable(req)
|
||||
// console.print_debug("is cacheable: ${is_cacheable}")
|
||||
// println("Sending request: ${req}")
|
||||
|
||||
mut is_cacheable := h.is_cacheable(req)
|
||||
if req.debug {
|
||||
// in debug mode should not cache
|
||||
is_cacheable = false
|
||||
}
|
||||
|
||||
// 1 - Check cache if enabled try to get result from cache
|
||||
if is_cacheable {
|
||||
@@ -71,11 +76,6 @@ pub fn (mut h HTTPConnection) send(req_ Request) !Result {
|
||||
}
|
||||
url := h.url(req)
|
||||
|
||||
// println("----")
|
||||
// println(url)
|
||||
// println(req.data)
|
||||
// println("----")
|
||||
|
||||
mut new_req := http.new_request(req.method, url, req.data)
|
||||
// joining the header from the HTTPConnection with the one from Request
|
||||
new_req.header = h.header()
|
||||
@@ -99,7 +99,10 @@ pub fn (mut h HTTPConnection) send(req_ Request) !Result {
|
||||
if req.debug {
|
||||
console.print_debug('http request:\n${new_req.str()}')
|
||||
}
|
||||
for _ in 0 .. h.retry {
|
||||
for counter in 0 .. h.retry {
|
||||
if req.debug {
|
||||
console.print_debug('request attempt:${counter}')
|
||||
}
|
||||
response = new_req.do() or {
|
||||
err_message = 'Cannot send request:${req}\nerror:${err}'
|
||||
// console.print_debug(err_message)
|
||||
@@ -108,6 +111,7 @@ pub fn (mut h HTTPConnection) send(req_ Request) !Result {
|
||||
break
|
||||
}
|
||||
if req.debug {
|
||||
console.print_debug('request done')
|
||||
console.print_debug(response.str())
|
||||
}
|
||||
if response.status_code == 0 {
|
||||
@@ -186,9 +190,11 @@ pub fn (mut h HTTPConnection) get_json(req Request) !string {
|
||||
// Get Request with json data and return response as string
|
||||
pub fn (mut h HTTPConnection) get(req_ Request) !string {
|
||||
mut req := req_
|
||||
req.debug
|
||||
req.method = .get
|
||||
result := h.send(req)!
|
||||
if !result.is_ok() {
|
||||
return error('Could not get ${req}\result:\n${result}')
|
||||
}
|
||||
return result.data
|
||||
}
|
||||
|
||||
@@ -197,6 +203,9 @@ pub fn (mut h HTTPConnection) delete(req_ Request) !string {
|
||||
mut req := req_
|
||||
req.method = .delete
|
||||
result := h.send(req)!
|
||||
if !result.is_ok() {
|
||||
return error('Could not delete ${req}\result:\n${result}')
|
||||
}
|
||||
return result.data
|
||||
}
|
||||
|
||||
@@ -207,5 +216,6 @@ pub fn (mut h HTTPConnection) post_multi_part(req Request, form http.PostMultipa
|
||||
header.set(http.CommonHeader.content_type, 'multipart/form-data')
|
||||
req_form.header = header
|
||||
url := h.url(req)
|
||||
// TODO: should that not be on line with above? seems to be other codepath.
|
||||
return http.post_multipart_form(url, req_form)!
|
||||
}
|
||||
|
||||
@@ -3,10 +3,16 @@ module playcmds
|
||||
import freeflowuniverse.herolib.core.playbook { PlayBook }
|
||||
import freeflowuniverse.herolib.data.doctree
|
||||
import freeflowuniverse.herolib.biz.bizmodel
|
||||
import freeflowuniverse.herolib.threefold.incatokens
|
||||
import freeflowuniverse.herolib.web.site
|
||||
import freeflowuniverse.herolib.virt.hetznermanager
|
||||
import freeflowuniverse.herolib.web.docusaurus
|
||||
import freeflowuniverse.herolib.clients.openai
|
||||
import freeflowuniverse.herolib.clients.giteaclient
|
||||
import freeflowuniverse.herolib.osal.tmux
|
||||
import freeflowuniverse.herolib.installers.base
|
||||
import freeflowuniverse.herolib.installers.lang.vlang
|
||||
import freeflowuniverse.herolib.installers.lang.herolib
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// run – entry point for all HeroScript play‑commands
|
||||
@@ -39,6 +45,9 @@ pub fn run(args_ PlayArgs) ! {
|
||||
// Git actions
|
||||
play_git(mut plbook)!
|
||||
|
||||
// Tmux actions
|
||||
tmux.play(mut plbook)!
|
||||
|
||||
// Business model (e.g. currency, bizmodel)
|
||||
bizmodel.play(mut plbook)!
|
||||
|
||||
@@ -49,7 +58,15 @@ pub fn run(args_ PlayArgs) ! {
|
||||
site.play(mut plbook)!
|
||||
doctree.play(mut plbook)!
|
||||
|
||||
incatokens.play(mut plbook)!
|
||||
|
||||
docusaurus.play(mut plbook)!
|
||||
hetznermanager.play(mut plbook)!
|
||||
hetznermanager.play2(mut plbook)!
|
||||
|
||||
base.play(mut plbook)!
|
||||
herolib.play(mut plbook)!
|
||||
vlang.play(mut plbook)!
|
||||
|
||||
giteaclient.play(mut plbook)!
|
||||
|
||||
|
||||
279
lib/core/playcmds/play_osal_core.v
Normal file
279
lib/core/playcmds/play_osal_core.v
Normal file
@@ -0,0 +1,279 @@
|
||||
module playcmds
|
||||
|
||||
import freeflowuniverse.herolib.core.playbook { PlayBook }
|
||||
import freeflowuniverse.herolib.osal.core as osal
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
pub fn play_osal_core(mut plbook PlayBook) ! {
|
||||
if !plbook.exists(filter: 'osal.') {
|
||||
return
|
||||
}
|
||||
|
||||
// Process done actions
|
||||
play_done(mut plbook)!
|
||||
|
||||
// Process environment actions
|
||||
play_env(mut plbook)!
|
||||
|
||||
// Process execution actions
|
||||
play_exec(mut plbook)!
|
||||
|
||||
// Process package actions
|
||||
play_package(mut plbook)!
|
||||
}
|
||||
|
||||
fn play_done(mut plbook PlayBook) ! {
|
||||
// done_set actions
|
||||
mut done_set_actions := plbook.find(filter: 'osal.done_set')!
|
||||
for mut action in done_set_actions {
|
||||
mut p := action.params
|
||||
key := p.get('key')!
|
||||
val := p.get('val')!
|
||||
|
||||
console.print_header('Setting done flag: ${key} = ${val}')
|
||||
osal.done_set(key, val)!
|
||||
action.done = true
|
||||
}
|
||||
|
||||
// done_delete actions
|
||||
mut done_delete_actions := plbook.find(filter: 'osal.done_delete')!
|
||||
for mut action in done_delete_actions {
|
||||
mut p := action.params
|
||||
key := p.get('key')!
|
||||
|
||||
console.print_header('Deleting done flag: ${key}')
|
||||
osal.done_delete(key)!
|
||||
action.done = true
|
||||
}
|
||||
|
||||
// done_reset actions
|
||||
mut done_reset_actions := plbook.find(filter: 'osal.done_reset')!
|
||||
for mut action in done_reset_actions {
|
||||
console.print_header('Resetting all done flags')
|
||||
osal.done_reset()!
|
||||
action.done = true
|
||||
}
|
||||
|
||||
// done_print actions
|
||||
mut done_print_actions := plbook.find(filter: 'osal.done_print')!
|
||||
for mut action in done_print_actions {
|
||||
console.print_header('Printing done flags')
|
||||
osal.done_print()!
|
||||
action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
fn play_env(mut plbook PlayBook) ! {
|
||||
// env_set actions
|
||||
mut env_set_actions := plbook.find(filter: 'osal.env_set')!
|
||||
for mut action in env_set_actions {
|
||||
mut p := action.params
|
||||
key := p.get('key')!
|
||||
value := p.get('value')!
|
||||
overwrite := p.get_default_true('overwrite')
|
||||
|
||||
console.print_header('Setting environment variable: ${key}')
|
||||
osal.env_set(
|
||||
key: key
|
||||
value: value
|
||||
overwrite: overwrite
|
||||
)
|
||||
action.done = true
|
||||
}
|
||||
|
||||
// env_unset actions
|
||||
mut env_unset_actions := plbook.find(filter: 'osal.env_unset')!
|
||||
for mut action in env_unset_actions {
|
||||
mut p := action.params
|
||||
key := p.get('key')!
|
||||
|
||||
console.print_header('Unsetting environment variable: ${key}')
|
||||
osal.env_unset(key)
|
||||
action.done = true
|
||||
}
|
||||
|
||||
// env_set_all actions
|
||||
mut env_set_all_actions := plbook.find(filter: 'osal.env_set_all')!
|
||||
for mut action in env_set_all_actions {
|
||||
mut p := action.params
|
||||
|
||||
// Parse environment variables from parameters
|
||||
mut env_vars := map[string]string{}
|
||||
// Get all parameters and filter out the control parameters
|
||||
params_map := p.get_map()
|
||||
for key, value in params_map {
|
||||
if key !in ['clear_before_set', 'overwrite_if_exists'] {
|
||||
env_vars[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
clear_before_set := p.get_default_false('clear_before_set')
|
||||
overwrite_if_exists := p.get_default_true('overwrite_if_exists')
|
||||
|
||||
console.print_header('Setting multiple environment variables')
|
||||
osal.env_set_all(
|
||||
env: env_vars
|
||||
clear_before_set: clear_before_set
|
||||
overwrite_if_exists: overwrite_if_exists
|
||||
)
|
||||
action.done = true
|
||||
}
|
||||
|
||||
// env_load_file actions
|
||||
mut env_load_file_actions := plbook.find(filter: 'osal.env_load_file')!
|
||||
for mut action in env_load_file_actions {
|
||||
mut p := action.params
|
||||
file_path := p.get('file_path')!
|
||||
|
||||
console.print_header('Loading environment from file: ${file_path}')
|
||||
osal.load_env_file(file_path)!
|
||||
action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
fn play_exec(mut plbook PlayBook) ! {
|
||||
// exec actions
|
||||
mut exec_actions := plbook.find(filter: 'osal.exec')!
|
||||
for mut action in exec_actions {
|
||||
mut p := action.params
|
||||
|
||||
cmd := p.get('cmd')!
|
||||
|
||||
mut command := osal.Command{
|
||||
cmd: cmd
|
||||
name: p.get_default('name', '')!
|
||||
description: p.get_default('description', '')!
|
||||
timeout: p.get_int_default('timeout', 3600)!
|
||||
stdout: p.get_default_true('stdout')
|
||||
stdout_log: p.get_default_true('stdout_log')
|
||||
raise_error: p.get_default_true('raise_error')
|
||||
ignore_error: p.get_default_false('ignore_error')
|
||||
work_folder: p.get_default('work_folder', '')!
|
||||
retry: p.get_int_default('retry', 0)!
|
||||
interactive: p.get_default_true('interactive')
|
||||
debug: p.get_default_false('debug')
|
||||
}
|
||||
|
||||
// Parse environment variables if provided
|
||||
if p.exists('environment') {
|
||||
env_str := p.get('environment')!
|
||||
// Parse environment string (format: "KEY1=value1,KEY2=value2")
|
||||
env_pairs := env_str.split(',')
|
||||
mut env_map := map[string]string{}
|
||||
for pair in env_pairs {
|
||||
if pair.contains('=') {
|
||||
key := pair.all_before('=').trim_space()
|
||||
value := pair.all_after('=').trim_space()
|
||||
env_map[key] = value
|
||||
}
|
||||
}
|
||||
command.environment = env_map.clone()
|
||||
}
|
||||
|
||||
// Parse ignore_error_codes if provided
|
||||
if p.exists('ignore_error_codes') {
|
||||
ignore_codes := p.get_list_int('ignore_error_codes')!
|
||||
command.ignore_error_codes = ignore_codes
|
||||
}
|
||||
|
||||
console.print_header('Executing command: ${cmd}')
|
||||
osal.exec(command)!
|
||||
action.done = true
|
||||
}
|
||||
|
||||
// exec_silent actions
|
||||
mut exec_silent_actions := plbook.find(filter: 'osal.exec_silent')!
|
||||
for mut action in exec_silent_actions {
|
||||
mut p := action.params
|
||||
cmd := p.get('cmd')!
|
||||
|
||||
console.print_header('Executing command silently: ${cmd}')
|
||||
osal.execute_silent(cmd)!
|
||||
action.done = true
|
||||
}
|
||||
|
||||
// exec_interactive actions
|
||||
mut exec_interactive_actions := plbook.find(filter: 'osal.exec_interactive')!
|
||||
for mut action in exec_interactive_actions {
|
||||
mut p := action.params
|
||||
cmd := p.get('cmd')!
|
||||
|
||||
console.print_header('Executing command interactively: ${cmd}')
|
||||
osal.execute_interactive(cmd)!
|
||||
action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
fn play_package(mut plbook PlayBook) ! {
|
||||
// package_refresh actions
|
||||
mut package_refresh_actions := plbook.find(filter: 'osal.package_refresh')!
|
||||
for mut action in package_refresh_actions {
|
||||
console.print_header('Refreshing package lists')
|
||||
osal.package_refresh()!
|
||||
action.done = true
|
||||
}
|
||||
|
||||
// package_install actions
|
||||
mut package_install_actions := plbook.find(filter: 'osal.package_install')!
|
||||
for mut action in package_install_actions {
|
||||
mut p := action.params
|
||||
|
||||
// Support both 'name' parameter and arguments
|
||||
mut packages := []string{}
|
||||
|
||||
if p.exists('name') {
|
||||
packages << p.get('name')!
|
||||
}
|
||||
|
||||
// Add any arguments (packages without keys)
|
||||
mut i := 0
|
||||
for {
|
||||
arg := p.get_arg_default(i, '')!
|
||||
if arg == '' {
|
||||
break
|
||||
}
|
||||
packages << arg
|
||||
i++
|
||||
}
|
||||
|
||||
for package in packages {
|
||||
if package != '' {
|
||||
console.print_header('Installing package: ${package}')
|
||||
osal.package_install(package)!
|
||||
}
|
||||
}
|
||||
action.done = true
|
||||
}
|
||||
|
||||
// package_remove actions
|
||||
mut package_remove_actions := plbook.find(filter: 'osal.package_remove')!
|
||||
for mut action in package_remove_actions {
|
||||
mut p := action.params
|
||||
|
||||
// Support both 'name' parameter and arguments
|
||||
mut packages := []string{}
|
||||
|
||||
if p.exists('name') {
|
||||
packages << p.get('name')!
|
||||
}
|
||||
|
||||
// Add any arguments (packages without keys)
|
||||
mut i := 0
|
||||
for {
|
||||
arg := p.get_arg_default(i, '')!
|
||||
if arg == '' {
|
||||
break
|
||||
}
|
||||
packages << arg
|
||||
i++
|
||||
}
|
||||
|
||||
for package in packages {
|
||||
if package != '' {
|
||||
console.print_header('Removing package: ${package}')
|
||||
osal.package_remove(package)!
|
||||
}
|
||||
}
|
||||
action.done = true
|
||||
}
|
||||
}
|
||||
@@ -54,24 +54,30 @@ fn decode_struct[T](_ T, data string) !T {
|
||||
should_skip = true
|
||||
break
|
||||
}
|
||||
if attr.contains('skipdecode') {
|
||||
should_skip = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !should_skip {
|
||||
$if field.is_struct {
|
||||
$if field.typ !is time.Time {
|
||||
if !field.name[0].is_capital() {
|
||||
// skip embedded ones
|
||||
mut data_fmt := data.replace(action_str, '')
|
||||
data_fmt = data.replace('define.${obj_name}', 'define')
|
||||
typ.$(field.name) = decode_struct(typ.$(field.name), data_fmt)!
|
||||
}
|
||||
}
|
||||
// $if field.typ !is time.Time {
|
||||
// if !field.name[0].is_capital() {
|
||||
// // skip embedded ones
|
||||
// mut data_fmt := data.replace(action_str, '')
|
||||
// data_fmt = data.replace('define.${obj_name}', 'define')
|
||||
// typ.$(field.name) = decode_struct(typ.$(field.name), data_fmt)!
|
||||
// }
|
||||
// }
|
||||
} $else $if field.is_array {
|
||||
if is_struct_array(typ.$(field.name))! {
|
||||
mut data_fmt := data.replace(action_str, '')
|
||||
data_fmt = data.replace('define.${obj_name}', 'define')
|
||||
arr := decode_array(typ.$(field.name), data_fmt)!
|
||||
typ.$(field.name) = arr
|
||||
}
|
||||
// arr := decode_array(typ.$(field.name), data_fmt)!
|
||||
// typ.$(field.name) = arr
|
||||
// if is_struct_array(typ.$(field.name))! {
|
||||
// mut data_fmt := data.replace(action_str, '')
|
||||
// data_fmt = data.replace('define.${obj_name}', 'define')
|
||||
// arr := decode_array(typ.$(field.name), data_fmt)!
|
||||
// typ.$(field.name) = arr
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,7 +99,9 @@ pub fn decode_array[T](_ []T, data string) ![]T {
|
||||
// for i in 0 .. val.len {
|
||||
value := T{}
|
||||
$if T is $struct {
|
||||
arr << decode_struct(value, data)!
|
||||
// arr << decode_struct(value, data)!
|
||||
} $else {
|
||||
arr << decode[T](data)!
|
||||
}
|
||||
// }
|
||||
return arr
|
||||
|
||||
@@ -24,8 +24,7 @@ pub mut:
|
||||
|
||||
// is_running checks if the node is operational by pinging its address
|
||||
fn (node &StreamerNode) is_running() bool {
|
||||
ping_result := osal.ping(address: node.address, retry: 2) or { return false }
|
||||
return ping_result == .ok
|
||||
return osal.ping(address: node.address, retry: 2)!
|
||||
}
|
||||
|
||||
// connect_to_master connects the worker node to its master
|
||||
|
||||
@@ -23,7 +23,6 @@ develop-eggs/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
|
||||
49
lib/installers/base/play.v
Normal file
49
lib/installers/base/play.v
Normal file
@@ -0,0 +1,49 @@
|
||||
module base
|
||||
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
pub fn play(mut plbook playbook.PlayBook) ! {
|
||||
if plbook.exists(filter: 'base.install') {
|
||||
console.print_header('play base.install')
|
||||
for mut action in plbook.find(filter: 'base.install')! {
|
||||
mut p := action.params
|
||||
install(
|
||||
reset: p.get_default_false('reset')
|
||||
develop: p.get_default_false('develop')
|
||||
)!
|
||||
action.done = true
|
||||
}
|
||||
}
|
||||
if plbook.exists(filter: 'base.develop') {
|
||||
console.print_header('play base.develop')
|
||||
for mut action in plbook.find(filter: 'base.develop')! {
|
||||
mut p := action.params
|
||||
develop(
|
||||
reset: p.get_default_false('reset')
|
||||
)!
|
||||
action.done = true
|
||||
}
|
||||
}
|
||||
if plbook.exists(filter: 'base.redis_install') {
|
||||
console.print_header('play base.redis_install')
|
||||
for action in plbook.find(filter: 'base.redis_install')! {
|
||||
mut p := action.params
|
||||
redis_install(
|
||||
port: p.get_int_default('port', 6379)!
|
||||
ipaddr: p.get_default('ipaddr', 'localhost')!
|
||||
reset: p.get_default_false('reset')
|
||||
start: p.get_default_true('start')
|
||||
)!
|
||||
}
|
||||
}
|
||||
// if plbook.exists(filter: 'base.sshkeysinstall') {
|
||||
// console.print_header('play base.sshkeysinstall')
|
||||
// for action in plbook.find(filter: 'base.sshkeysinstall')! {
|
||||
// mut p := action.params
|
||||
// sshkeysinstall(
|
||||
// reset: p.get_default_false('reset')
|
||||
// )!
|
||||
// }
|
||||
// }
|
||||
}
|
||||
54
lib/installers/base/readme.md
Normal file
54
lib/installers/base/readme.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# Installer - Base Module
|
||||
|
||||
This module provides heroscript actions to install and configure base system dependencies.
|
||||
|
||||
## Actions
|
||||
|
||||
### `base.install`
|
||||
|
||||
Installs base packages for the detected operating system (OSX, Ubuntu, Alpine, Arch).
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `reset` (bool): If true, reinstalls packages even if they are already present. Default: `false`.
|
||||
- `develop` (bool): If true, installs development packages. Default: `false`.
|
||||
|
||||
**Example:**
|
||||
|
||||
```heroscript
|
||||
!!base.install
|
||||
develop: true
|
||||
```
|
||||
|
||||
### `base.develop`
|
||||
|
||||
Installs development packages for the detected operating system.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `reset` (bool): If true, reinstalls packages. Default: `false`.
|
||||
|
||||
**Example:**
|
||||
|
||||
```heroscript
|
||||
!!base.develop
|
||||
reset: true
|
||||
```
|
||||
|
||||
### `base.redis_install`
|
||||
|
||||
Installs and configures Redis server.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `port` (int): Port for Redis to listen on. Default: `6379`.
|
||||
- `ipaddr` (string): IP address to bind to. Default: `localhost`.
|
||||
- `reset` (bool): If true, reinstalls and reconfigures Redis. Default: `false`.
|
||||
- `start` (bool): If true, starts the Redis server after installation. Default: `true`.
|
||||
|
||||
**Example:**
|
||||
|
||||
```heroscript
|
||||
!!base.redis_install
|
||||
port: 6380
|
||||
```
|
||||
@@ -38,6 +38,7 @@ pub fn get(args ArgsGet) !&CometBFT {
|
||||
if r.hexists('context:cometbft', args.name)! {
|
||||
data := r.hget('context:cometbft', args.name)!
|
||||
if data.len == 0 {
|
||||
print_backtrace()
|
||||
return error('CometBFT with name: cometbft does not exist, prob bug.')
|
||||
}
|
||||
mut obj := json.decode(CometBFT, data)!
|
||||
@@ -46,12 +47,14 @@ pub fn get(args ArgsGet) !&CometBFT {
|
||||
if args.create {
|
||||
new(args)!
|
||||
} else {
|
||||
print_backtrace()
|
||||
return error("CometBFT with name 'cometbft' does not exist")
|
||||
}
|
||||
}
|
||||
return get(name: args.name)! // no longer from db nor create
|
||||
}
|
||||
return cometbft_global[args.name] or {
|
||||
print_backtrace()
|
||||
return error('could not get config for cometbft with name:cometbft')
|
||||
}
|
||||
}
|
||||
@@ -124,14 +127,15 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
mut install_actions := plbook.find(filter: 'cometbft.configure')!
|
||||
if install_actions.len > 0 {
|
||||
for install_action in install_actions {
|
||||
for mut install_action in install_actions {
|
||||
heroscript := install_action.heroscript()
|
||||
mut obj2 := heroscript_loads(heroscript)!
|
||||
set(obj2)!
|
||||
install_action.done = true
|
||||
}
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'cometbft.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -163,6 +167,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
cometbft_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,19 +183,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: cometbft' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: cometbft' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: cometbft' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: cometbft' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -208,7 +213,7 @@ pub fn (mut self CometBFT) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('cometbft start')
|
||||
console.print_header('installer: cometbft start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -221,7 +226,7 @@ pub fn (mut self CometBFT) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting cometbft with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: cometbft starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ pub fn get(args ArgsGet) !&MeilisearchInstaller {
|
||||
if r.hexists('context:meilisearch_installer', args.name)! {
|
||||
data := r.hget('context:meilisearch_installer', args.name)!
|
||||
if data.len == 0 {
|
||||
print_backtrace()
|
||||
return error('MeilisearchInstaller with name: meilisearch_installer does not exist, prob bug.')
|
||||
}
|
||||
mut obj := json.decode(MeilisearchInstaller, data)!
|
||||
@@ -46,12 +47,14 @@ pub fn get(args ArgsGet) !&MeilisearchInstaller {
|
||||
if args.create {
|
||||
new(args)!
|
||||
} else {
|
||||
print_backtrace()
|
||||
return error("MeilisearchInstaller with name 'meilisearch_installer' does not exist")
|
||||
}
|
||||
}
|
||||
return get(name: args.name)! // no longer from db nor create
|
||||
}
|
||||
return meilisearch_installer_global[args.name] or {
|
||||
print_backtrace()
|
||||
return error('could not get config for meilisearch_installer with name:meilisearch_installer')
|
||||
}
|
||||
}
|
||||
@@ -124,14 +127,15 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
mut install_actions := plbook.find(filter: 'meilisearch_installer.configure')!
|
||||
if install_actions.len > 0 {
|
||||
for install_action in install_actions {
|
||||
for mut install_action in install_actions {
|
||||
heroscript := install_action.heroscript()
|
||||
mut obj2 := heroscript_loads(heroscript)!
|
||||
set(obj2)!
|
||||
install_action.done = true
|
||||
}
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'meilisearch_installer.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -163,6 +167,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
meilisearch_installer_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,19 +183,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: meilisearch_installer' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: meilisearch_installer' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: meilisearch_installer' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: meilisearch_installer' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -208,7 +213,7 @@ pub fn (mut self MeilisearchInstaller) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('meilisearch_installer start')
|
||||
console.print_header('installer: meilisearch_installer start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -221,7 +226,7 @@ pub fn (mut self MeilisearchInstaller) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting meilisearch_installer with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: meilisearch_installer starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ pub fn get(args ArgsGet) !&Postgresql {
|
||||
if r.hexists('context:postgresql', args.name)! {
|
||||
data := r.hget('context:postgresql', args.name)!
|
||||
if data.len == 0 {
|
||||
print_backtrace()
|
||||
return error('Postgresql with name: postgresql does not exist, prob bug.')
|
||||
}
|
||||
mut obj := json.decode(Postgresql, data)!
|
||||
@@ -46,12 +47,14 @@ pub fn get(args ArgsGet) !&Postgresql {
|
||||
if args.create {
|
||||
new(args)!
|
||||
} else {
|
||||
print_backtrace()
|
||||
return error("Postgresql with name 'postgresql' does not exist")
|
||||
}
|
||||
}
|
||||
return get(name: args.name)! // no longer from db nor create
|
||||
}
|
||||
return postgresql_global[args.name] or {
|
||||
print_backtrace()
|
||||
return error('could not get config for postgresql with name:postgresql')
|
||||
}
|
||||
}
|
||||
@@ -124,14 +127,15 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
mut install_actions := plbook.find(filter: 'postgresql.configure')!
|
||||
if install_actions.len > 0 {
|
||||
for install_action in install_actions {
|
||||
for mut install_action in install_actions {
|
||||
heroscript := install_action.heroscript()
|
||||
mut obj2 := heroscript_loads(heroscript)!
|
||||
set(obj2)!
|
||||
install_action.done = true
|
||||
}
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'postgresql.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -163,6 +167,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
postgresql_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,19 +183,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: postgresql' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: postgresql' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: postgresql' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: postgresql' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -206,7 +211,7 @@ pub fn (mut self Postgresql) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('postgresql start')
|
||||
console.print_header('installer: postgresql start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -219,7 +224,7 @@ pub fn (mut self Postgresql) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting postgresql with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: postgresql starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ pub fn get(args ArgsGet) !&QDrant {
|
||||
if r.hexists('context:qdrant_installer', args.name)! {
|
||||
data := r.hget('context:qdrant_installer', args.name)!
|
||||
if data.len == 0 {
|
||||
print_backtrace()
|
||||
return error('QDrant with name: qdrant_installer does not exist, prob bug.')
|
||||
}
|
||||
mut obj := json.decode(QDrant, data)!
|
||||
@@ -46,12 +47,14 @@ pub fn get(args ArgsGet) !&QDrant {
|
||||
if args.create {
|
||||
new(args)!
|
||||
} else {
|
||||
print_backtrace()
|
||||
return error("QDrant with name 'qdrant_installer' does not exist")
|
||||
}
|
||||
}
|
||||
return get(name: args.name)! // no longer from db nor create
|
||||
}
|
||||
return qdrant_installer_global[args.name] or {
|
||||
print_backtrace()
|
||||
return error('could not get config for qdrant_installer with name:qdrant_installer')
|
||||
}
|
||||
}
|
||||
@@ -124,14 +127,15 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
mut install_actions := plbook.find(filter: 'qdrant_installer.configure')!
|
||||
if install_actions.len > 0 {
|
||||
for install_action in install_actions {
|
||||
for mut install_action in install_actions {
|
||||
heroscript := install_action.heroscript()
|
||||
mut obj2 := heroscript_loads(heroscript)!
|
||||
set(obj2)!
|
||||
install_action.done = true
|
||||
}
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'qdrant_installer.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -163,6 +167,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
qdrant_installer_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,19 +183,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: qdrant_installer' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: qdrant_installer' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: qdrant_installer' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: qdrant_installer' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -208,7 +213,7 @@ pub fn (mut self QDrant) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('qdrant_installer start')
|
||||
console.print_header('installer: qdrant_installer start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -221,7 +226,7 @@ pub fn (mut self QDrant) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting qdrant_installer with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: qdrant_installer starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ pub fn get(args ArgsGet) !&ZeroDB {
|
||||
if r.hexists('context:zerodb', args.name)! {
|
||||
data := r.hget('context:zerodb', args.name)!
|
||||
if data.len == 0 {
|
||||
print_backtrace()
|
||||
return error('ZeroDB with name: zerodb does not exist, prob bug.')
|
||||
}
|
||||
mut obj := json.decode(ZeroDB, data)!
|
||||
@@ -46,12 +47,14 @@ pub fn get(args ArgsGet) !&ZeroDB {
|
||||
if args.create {
|
||||
new(args)!
|
||||
} else {
|
||||
print_backtrace()
|
||||
return error("ZeroDB with name 'zerodb' does not exist")
|
||||
}
|
||||
}
|
||||
return get(name: args.name)! // no longer from db nor create
|
||||
}
|
||||
return zerodb_global[args.name] or {
|
||||
print_backtrace()
|
||||
return error('could not get config for zerodb with name:zerodb')
|
||||
}
|
||||
}
|
||||
@@ -124,14 +127,15 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
mut install_actions := plbook.find(filter: 'zerodb.configure')!
|
||||
if install_actions.len > 0 {
|
||||
for install_action in install_actions {
|
||||
for mut install_action in install_actions {
|
||||
heroscript := install_action.heroscript()
|
||||
mut obj2 := heroscript_loads(heroscript)!
|
||||
set(obj2)!
|
||||
install_action.done = true
|
||||
}
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'zerodb.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -163,6 +167,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
zerodb_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,19 +183,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: zerodb' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: zerodb' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: zerodb' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: zerodb' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -206,7 +211,7 @@ pub fn (mut self ZeroDB) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('zerodb start')
|
||||
console.print_header('installer: zerodb start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -219,7 +224,7 @@ pub fn (mut self ZeroDB) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting zerodb with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: zerodb starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure zerofs, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'zerofs.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -68,6 +68,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
zerofs_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,19 +84,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: zerofs' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: zerofs' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: zerofs' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: zerofs' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -106,7 +107,7 @@ pub fn (mut self ZeroFS) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('zerofs start')
|
||||
console.print_header('installer: zerofs start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -119,7 +120,7 @@ pub fn (mut self ZeroFS) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting zerofs with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: zerofs starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ pub fn get(args ArgsGet) !&CoreDNS {
|
||||
if r.hexists('context:coredns', args.name)! {
|
||||
data := r.hget('context:coredns', args.name)!
|
||||
if data.len == 0 {
|
||||
print_backtrace()
|
||||
return error('CoreDNS with name: coredns does not exist, prob bug.')
|
||||
}
|
||||
mut obj := json.decode(CoreDNS, data)!
|
||||
@@ -46,12 +47,14 @@ pub fn get(args ArgsGet) !&CoreDNS {
|
||||
if args.create {
|
||||
new(args)!
|
||||
} else {
|
||||
print_backtrace()
|
||||
return error("CoreDNS with name 'coredns' does not exist")
|
||||
}
|
||||
}
|
||||
return get(name: args.name)! // no longer from db nor create
|
||||
}
|
||||
return coredns_global[args.name] or {
|
||||
print_backtrace()
|
||||
return error('could not get config for coredns with name:coredns')
|
||||
}
|
||||
}
|
||||
@@ -124,14 +127,15 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
mut install_actions := plbook.find(filter: 'coredns.configure')!
|
||||
if install_actions.len > 0 {
|
||||
for install_action in install_actions {
|
||||
for mut install_action in install_actions {
|
||||
heroscript := install_action.heroscript()
|
||||
mut obj2 := heroscript_loads(heroscript)!
|
||||
set(obj2)!
|
||||
install_action.done = true
|
||||
}
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'coredns.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -163,6 +167,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
coredns_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,19 +183,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: coredns' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: coredns' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: coredns' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: coredns' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -206,7 +211,7 @@ pub fn (mut self CoreDNS) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('coredns start')
|
||||
console.print_header('installer: coredns start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -219,7 +224,7 @@ pub fn (mut self CoreDNS) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting coredns with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: coredns starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -1,43 +1,19 @@
|
||||
# coredns
|
||||
# Installer - CoreDNS Module
|
||||
|
||||
coredns
|
||||
This module provides heroscript actions for installing and managing CoreDNS.
|
||||
|
||||
To get started
|
||||
## Actions
|
||||
|
||||
```v
|
||||
### `coredns.install`
|
||||
|
||||
Installs the CoreDNS server.
|
||||
|
||||
import freeflowuniverse.herolib.installers.infra.coredns as coredns_installer
|
||||
**Parameters:**
|
||||
|
||||
heroscript:="
|
||||
!!coredns.configure name:'test'
|
||||
config_path: '/etc/coredns/Corefile'
|
||||
dnszones_path: '/etc/coredns/zones'
|
||||
plugins: 'forward,cache'
|
||||
example: true
|
||||
- `reset` (bool): If true, force a reinstall even if CoreDNS is already detected. Default: `false`.
|
||||
|
||||
!!coredns.start name:'test' reset:1
|
||||
"
|
||||
**Example:**
|
||||
|
||||
coredns_installer.play(heroscript=heroscript)!
|
||||
|
||||
//or we can call the default and do a start with reset
|
||||
//mut installer:= coredns_installer.get()!
|
||||
//installer.start(reset:true)!
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
## example heroscript
|
||||
|
||||
```hero
|
||||
!!coredns.configure
|
||||
name: 'custom'
|
||||
config_path: '/etc/coredns/Corefile'
|
||||
config_url: 'https://github.com/example/coredns-config'
|
||||
dnszones_path: '/etc/coredns/zones'
|
||||
dnszones_url: 'https://github.com/example/dns-zones'
|
||||
plugins: 'forward,cache'
|
||||
example: false
|
||||
```
|
||||
```heroscript
|
||||
!!coredns.install
|
||||
reset: true
|
||||
@@ -38,6 +38,7 @@ pub fn get(args ArgsGet) !&GiteaServer {
|
||||
if r.hexists('context:gitea', args.name)! {
|
||||
data := r.hget('context:gitea', args.name)!
|
||||
if data.len == 0 {
|
||||
print_backtrace()
|
||||
return error('GiteaServer with name: gitea does not exist, prob bug.')
|
||||
}
|
||||
mut obj := json.decode(GiteaServer, data)!
|
||||
@@ -46,12 +47,14 @@ pub fn get(args ArgsGet) !&GiteaServer {
|
||||
if args.create {
|
||||
new(args)!
|
||||
} else {
|
||||
print_backtrace()
|
||||
return error("GiteaServer with name 'gitea' does not exist")
|
||||
}
|
||||
}
|
||||
return get(name: args.name)! // no longer from db nor create
|
||||
}
|
||||
return gitea_global[args.name] or {
|
||||
print_backtrace()
|
||||
return error('could not get config for gitea with name:gitea')
|
||||
}
|
||||
}
|
||||
@@ -124,14 +127,15 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
mut install_actions := plbook.find(filter: 'gitea.configure')!
|
||||
if install_actions.len > 0 {
|
||||
for install_action in install_actions {
|
||||
for mut install_action in install_actions {
|
||||
heroscript := install_action.heroscript()
|
||||
mut obj2 := heroscript_loads(heroscript)!
|
||||
set(obj2)!
|
||||
install_action.done = true
|
||||
}
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'gitea.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -163,6 +167,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
gitea_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,19 +183,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: gitea' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: gitea' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: gitea' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: gitea' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -206,7 +211,7 @@ pub fn (mut self GiteaServer) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('gitea start')
|
||||
console.print_header('installer: gitea start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -219,7 +224,7 @@ pub fn (mut self GiteaServer) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting gitea with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: gitea starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
23
lib/installers/infra/gitea/play.v
Normal file
23
lib/installers/infra/gitea/play.v
Normal file
@@ -0,0 +1,23 @@
|
||||
module gitea
|
||||
|
||||
import freeflowuniverse.herolib.core.playbook { PlayBook }
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.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
|
||||
}
|
||||
@@ -1,29 +1,19 @@
|
||||
# gitea
|
||||
# Installer - Gitea Module
|
||||
|
||||
This module provides heroscript actions for installing and managing Gitea.
|
||||
|
||||
## Actions
|
||||
|
||||
To get started
|
||||
### `gitea.install`
|
||||
|
||||
```v
|
||||
Installs the Gitea Git service.
|
||||
|
||||
import freeflowuniverse.herolib.installers.infra.gitea as gitea_installer
|
||||
**Parameters:**
|
||||
|
||||
- `reset` (bool): If true, force a reinstall even if Gitea is already detected. Default: `false`.
|
||||
|
||||
//if you want to configure using heroscript
|
||||
gitea_installer.play(heroscript:'
|
||||
!!gitea.configure name:test
|
||||
passwd:'something'
|
||||
domain: 'docs.info.com'
|
||||
')!
|
||||
**Example:**
|
||||
|
||||
mut installer:= gitea_installer.get(name:'test')!
|
||||
installer.start()!
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
this will look for a configured mail & postgresql client both on instance name: "default", change in heroscript if needed
|
||||
|
||||
- postgresql_client_name = "default"
|
||||
- mail_client_name = "default"
|
||||
```heroscript
|
||||
!!gitea.install
|
||||
reset: true
|
||||
@@ -135,19 +135,13 @@ fn install() ! {
|
||||
|
||||
fn destroy() ! {
|
||||
console.print_header('removing livekit')
|
||||
osal.process_kill_recursive(name: 'livekit') or {
|
||||
return error('Could not kill livekit due to: ${err}')
|
||||
}
|
||||
res := os.execute('sudo rm -rf /usr/local/bin/livekit-server')
|
||||
if res.exit_code != 0 {
|
||||
return error('Failed to remove LiveKit server')
|
||||
}
|
||||
|
||||
mut zinit_factory := zinit.new()!
|
||||
if zinit_factory.exists('livekit') {
|
||||
zinit_factory.stop('livekit') or {
|
||||
return error('Could not stop livekit service due to: ${err}')
|
||||
}
|
||||
zinit_factory.delete('livekit') or {
|
||||
return error('Could not delete livekit service due to: ${err}')
|
||||
}
|
||||
}
|
||||
console.print_header('livekit removed')
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ pub fn get(args ArgsGet) !&LivekitServer {
|
||||
if r.hexists('context:livekit', args.name)! {
|
||||
data := r.hget('context:livekit', args.name)!
|
||||
if data.len == 0 {
|
||||
print_backtrace()
|
||||
return error('LivekitServer with name: livekit does not exist, prob bug.')
|
||||
}
|
||||
mut obj := json.decode(LivekitServer, data)!
|
||||
@@ -46,12 +47,14 @@ pub fn get(args ArgsGet) !&LivekitServer {
|
||||
if args.create {
|
||||
new(args)!
|
||||
} else {
|
||||
print_backtrace()
|
||||
return error("LivekitServer with name 'livekit' does not exist")
|
||||
}
|
||||
}
|
||||
return get(name: args.name)! // no longer from db nor create
|
||||
}
|
||||
return livekit_global[args.name] or {
|
||||
print_backtrace()
|
||||
return error('could not get config for livekit with name:livekit')
|
||||
}
|
||||
}
|
||||
@@ -124,14 +127,15 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
mut install_actions := plbook.find(filter: 'livekit.configure')!
|
||||
if install_actions.len > 0 {
|
||||
for install_action in install_actions {
|
||||
for mut install_action in install_actions {
|
||||
heroscript := install_action.heroscript()
|
||||
mut obj2 := heroscript_loads(heroscript)!
|
||||
set(obj2)!
|
||||
install_action.done = true
|
||||
}
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'livekit.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -163,6 +167,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
livekit_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,19 +183,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: livekit' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: livekit' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: livekit' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: livekit' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -208,7 +213,7 @@ pub fn (mut self LivekitServer) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('livekit start')
|
||||
console.print_header('installer: livekit start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -221,7 +226,7 @@ pub fn (mut self LivekitServer) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting livekit with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: livekit starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import freeflowuniverse.herolib.core.pathlib
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import os
|
||||
|
||||
pub const version = '1.7.2'
|
||||
pub const version = '1.9.0'
|
||||
const singleton = false
|
||||
const default = true
|
||||
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
# livekit
|
||||
# Installer - Livekit Module
|
||||
|
||||
This module provides heroscript actions for installing and managing Livekit.
|
||||
|
||||
## Actions
|
||||
|
||||
To get started
|
||||
### `livekit.install`
|
||||
|
||||
```v
|
||||
Installs the Livekit server.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `reset` (bool): If true, force a reinstall even if Livekit is already detected. Default: `false`.
|
||||
|
||||
import freeflowuniverse.herolib.installers.something. livekit
|
||||
**Example:**
|
||||
|
||||
mut installer:= livekit.get()!
|
||||
|
||||
installer.start()!
|
||||
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
livekit once installed will have generated the secret keys
|
||||
```heroscript
|
||||
!!livekit.install
|
||||
reset: true
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
!!hero_code.generate_installer
|
||||
name:'screen'
|
||||
classname:'Screen'
|
||||
singleton:0
|
||||
templates:0
|
||||
default:1
|
||||
title:''
|
||||
supported_platforms:''
|
||||
reset:0
|
||||
startupmanager:0
|
||||
hasconfig:0
|
||||
build:0
|
||||
@@ -1,44 +0,0 @@
|
||||
# screen
|
||||
|
||||
|
||||
|
||||
To get started
|
||||
|
||||
```v
|
||||
|
||||
|
||||
import freeflowuniverse.herolib.installers.something.screen as screen_installer
|
||||
|
||||
heroscript:="
|
||||
!!screen.configure name:'test'
|
||||
password: '1234'
|
||||
port: 7701
|
||||
|
||||
!!screen.start name:'test' reset:1
|
||||
"
|
||||
|
||||
screen_installer.play(heroscript=heroscript)!
|
||||
|
||||
//or we can call the default and do a start with reset
|
||||
//mut installer:= screen_installer.get()!
|
||||
//installer.start(reset:true)!
|
||||
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
## example heroscript
|
||||
|
||||
```hero
|
||||
!!screen.configure
|
||||
homedir: '/home/user/screen'
|
||||
username: 'admin'
|
||||
password: 'secretpassword'
|
||||
title: 'Some Title'
|
||||
host: 'localhost'
|
||||
port: 8888
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
module screen
|
||||
|
||||
import freeflowuniverse.herolib.core
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.installers.ulist
|
||||
import os
|
||||
|
||||
// checks if a certain version or above is installed
|
||||
fn installed() !bool {
|
||||
res := os.execute('screen --version')
|
||||
if res.exit_code != 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// 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() ! {}
|
||||
|
||||
fn install() ! {
|
||||
console.print_header('install screen')
|
||||
|
||||
if core.is_ubuntu()! {
|
||||
res := os.execute('sudo apt install screen -y')
|
||||
if res.exit_code != 0 {
|
||||
return error('failed to install screen: ${res.output}')
|
||||
}
|
||||
} else if core.is_osx()! {
|
||||
res := os.execute('sudo brew install screen')
|
||||
if res.exit_code != 0 {
|
||||
return error('failed to install screen: ${res.output}')
|
||||
}
|
||||
} else {
|
||||
return error('unsupported platform: ${core.platform()!}')
|
||||
}
|
||||
}
|
||||
|
||||
fn destroy() ! {
|
||||
console.print_header('uninstall screen')
|
||||
if core.is_ubuntu()! {
|
||||
res := os.execute('sudo apt remove screen -y')
|
||||
if res.exit_code != 0 {
|
||||
return error('failed to uninstall screen: ${res.output}')
|
||||
}
|
||||
} else if core.is_osx()! {
|
||||
res := os.execute('sudo brew uninstall screen')
|
||||
if res.exit_code != 0 {
|
||||
return error('failed to uninstall screen: ${res.output}')
|
||||
}
|
||||
} else {
|
||||
return error('unsupported platform: ${core.platform()!}')
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
module screen
|
||||
|
||||
import freeflowuniverse.herolib.core.playbook { PlayBook }
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import json
|
||||
import freeflowuniverse.herolib.osal.startupmanager
|
||||
|
||||
__global (
|
||||
screen_global map[string]&Screen
|
||||
screen_default string
|
||||
)
|
||||
|
||||
/////////FACTORY
|
||||
|
||||
@[params]
|
||||
pub struct ArgsGet {
|
||||
pub mut:
|
||||
name string = 'default'
|
||||
}
|
||||
|
||||
pub fn new(args ArgsGet) !&Screen {
|
||||
return &Screen{}
|
||||
}
|
||||
|
||||
pub fn get(args ArgsGet) !&Screen {
|
||||
return new(args)!
|
||||
}
|
||||
|
||||
pub fn play(mut plbook PlayBook) ! {
|
||||
if !plbook.exists(filter: 'screen.') {
|
||||
return
|
||||
}
|
||||
mut install_actions := plbook.find(filter: 'screen.configure')!
|
||||
if install_actions.len > 0 {
|
||||
return error("can't configure screen, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'screen.')!
|
||||
for 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 screen.destroy')
|
||||
destroy()!
|
||||
}
|
||||
if other_action.name == 'install' {
|
||||
console.print_debug('install action screen.install')
|
||||
install()!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////# LIVE CYCLE MANAGEMENT FOR INSTALLERS ///////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@[params]
|
||||
pub struct InstallArgs {
|
||||
pub mut:
|
||||
reset bool
|
||||
}
|
||||
|
||||
pub fn (mut self Screen) install(args InstallArgs) ! {
|
||||
switch(self.name)
|
||||
if args.reset || (!installed()!) {
|
||||
install()!
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (mut self Screen) destroy() ! {
|
||||
switch(self.name)
|
||||
destroy()!
|
||||
}
|
||||
|
||||
// switch instance to be used for screen
|
||||
pub fn switch(name string) {
|
||||
screen_default = name
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
module screen
|
||||
|
||||
import freeflowuniverse.herolib.data.encoderhero
|
||||
|
||||
const singleton = false
|
||||
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 Screen {
|
||||
pub mut:
|
||||
name string = 'default'
|
||||
}
|
||||
|
||||
// your checking & initialization code if needed
|
||||
fn obj_init(obj_ Screen) !Screen {
|
||||
// never call get here, only thing we can do here is work on object itself
|
||||
mut obj := obj_
|
||||
return obj
|
||||
}
|
||||
|
||||
// called before start if done
|
||||
fn configure() ! {
|
||||
// mut installer := get()!
|
||||
}
|
||||
|
||||
/////////////NORMALLY NO NEED TO TOUCH
|
||||
|
||||
pub fn heroscript_dumps(obj Screen) !string {
|
||||
return encoderhero.encode[Screen](obj)!
|
||||
}
|
||||
|
||||
pub fn heroscript_loads(heroscript string) !Screen {
|
||||
mut obj := encoderhero.decode[Screen](heroscript)!
|
||||
return obj
|
||||
}
|
||||
@@ -1,34 +1,19 @@
|
||||
# zinit
|
||||
# Installer - Zinit Installer Module
|
||||
|
||||
This module provides heroscript actions for installing and managing Zinit.
|
||||
|
||||
## Actions
|
||||
|
||||
To get started
|
||||
### `zinit_installer.install`
|
||||
|
||||
```v
|
||||
Installs the Zinit process manager.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
import freeflowuniverse.herolib.installers.something. zinit
|
||||
|
||||
mut installer:= zinit.get()!
|
||||
|
||||
installer.start()!
|
||||
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
## example heroscript
|
||||
|
||||
```hero
|
||||
!!zinit.install
|
||||
homedir: '/home/user/zinit'
|
||||
username: 'admin'
|
||||
password: 'secretpassword'
|
||||
title: 'Some Title'
|
||||
host: 'localhost'
|
||||
port: 8888
|
||||
|
||||
```
|
||||
- `reset` (bool): If true, force a reinstall even if Zinit is already detected. Default: `false`.
|
||||
|
||||
**Example:**
|
||||
|
||||
```heroscript
|
||||
!!zinit_installer.install
|
||||
reset: true
|
||||
@@ -16,7 +16,7 @@ fn startupcmd() ![]startupmanager.ZProcessNewArgs {
|
||||
if core.is_linux()! {
|
||||
res << startupmanager.ZProcessNewArgs{
|
||||
name: 'zinit'
|
||||
cmd: '/usr/local/bin/zinit init ~/hero/cfg/zinit'
|
||||
cmd: '/usr/local/bin/zinit init -c ${os.home_dir()}/hero/cfg/zinit'
|
||||
startuptype: .systemd
|
||||
start: true
|
||||
restart: true
|
||||
@@ -24,11 +24,12 @@ fn startupcmd() ![]startupmanager.ZProcessNewArgs {
|
||||
} else {
|
||||
res << startupmanager.ZProcessNewArgs{
|
||||
name: 'zinit'
|
||||
cmd: '~/hero/bin/zinit init --config ~/hero/cfg/zinit'
|
||||
cmd: '${os.home_dir()}/hero/bin/zinit init -c ${os.home_dir()}/hero/cfg/zinit'
|
||||
startuptype: .screen
|
||||
start: true
|
||||
}
|
||||
}
|
||||
osal.dir_ensure(os.home_dir() + '/hero/cfg/zinit')!
|
||||
return res
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure zinit_installer, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'zinit_installer.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -68,6 +68,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
zinit_installer_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,19 +84,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: zinit_installer' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: zinit_installer' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: zinit_installer' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: zinit_installer' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -106,7 +107,7 @@ pub fn (mut self ZinitInstaller) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('zinit_installer start')
|
||||
console.print_header('installer: zinit_installer start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -119,7 +120,7 @@ pub fn (mut self ZinitInstaller) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting zinit_installer with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: zinit_installer starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ module zinit_installer
|
||||
|
||||
import freeflowuniverse.herolib.data.encoderhero
|
||||
|
||||
pub const version = '0.2.25'
|
||||
pub const version = '0.2.27'
|
||||
const singleton = true
|
||||
const default = true
|
||||
|
||||
|
||||
@@ -105,8 +105,6 @@ pub fn install_multi(args_ InstallArgs) ! {
|
||||
'hero' {
|
||||
herolib.install(
|
||||
reset: args.reset
|
||||
git_pull: args.gitpull
|
||||
git_reset: args.gitreset
|
||||
)!
|
||||
}
|
||||
// 'hero' {
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure golang, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'golang.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -48,6 +48,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
install()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import freeflowuniverse.herolib.osal.core as osal
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.installers.base
|
||||
import freeflowuniverse.herolib.installers.lang.vlang
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
import freeflowuniverse.herolib.develop.gittools
|
||||
import os
|
||||
@@ -18,16 +17,16 @@ pub mut:
|
||||
reset bool // means reinstall
|
||||
}
|
||||
|
||||
pub fn install(args InstallArgs) ! {
|
||||
fn install_(args InstallArgs) ! {
|
||||
// install herolib if it was already done will return true
|
||||
console.print_header('install herolib (reset: ${args.reset})')
|
||||
// osal.package_refresh()!
|
||||
if args.reset {
|
||||
osal.done_reset()!
|
||||
}
|
||||
base.install(develop: true)!
|
||||
base.develop()!
|
||||
vlang.install(reset: args.reset)!
|
||||
vlang.v_analyzer_install(reset: args.reset)!
|
||||
// vlang.v_analyzer_install(reset: args.reset)!
|
||||
|
||||
mut gs := gittools.new()!
|
||||
gs.config()!.light = true // means we clone depth 1
|
||||
@@ -58,14 +57,6 @@ pub fn install(args InstallArgs) ! {
|
||||
return
|
||||
}
|
||||
|
||||
// check if herolib installed and hero, if not do so
|
||||
pub fn check() ! {
|
||||
if osal.done_exists('install_herolib') {
|
||||
return
|
||||
}
|
||||
install()!
|
||||
}
|
||||
|
||||
// remove hero, crystal, ...
|
||||
pub fn uninstall() ! {
|
||||
console.print_debug('uninstall hero & herolib')
|
||||
@@ -81,7 +72,7 @@ pub fn uninstall() ! {
|
||||
osal.execute_stdout(cmd) or { return error('Cannot uninstall herolib/hero.\n${err}') }
|
||||
}
|
||||
|
||||
pub fn hero_install(args InstallArgs) ! {
|
||||
pub fn install(args InstallArgs) ! {
|
||||
if args.reset == false && osal.done_exists('install_hero') {
|
||||
console.print_debug('hero already installed')
|
||||
return
|
||||
@@ -89,30 +80,32 @@ pub fn hero_install(args InstallArgs) ! {
|
||||
console.print_header('install hero')
|
||||
base.install()!
|
||||
|
||||
cmd := "
|
||||
cmd := '
|
||||
cd /tmp
|
||||
export TERM=xterm
|
||||
curl 'https://raw.githubusercontent.com/freeflowuniverse/herolib/refs/heads/main/install_v.sh' > /tmp/install_v.sh
|
||||
bash /tmp/install_v.sh --analyzer --herolib
|
||||
"
|
||||
curl https://raw.githubusercontent.com/freeflowuniverse/herolib/refs/heads/development/install_hero.sh | bash
|
||||
'
|
||||
osal.execute_stdout(cmd) or { return error('Cannot install hero.\n${err}') }
|
||||
osal.done_set('install_hero', 'OK')!
|
||||
return
|
||||
}
|
||||
|
||||
pub fn hero_compile(args InstallArgs) ! {
|
||||
pub fn compile(args InstallArgs) ! {
|
||||
if args.reset == false && osal.done_exists('compile_hero') {
|
||||
console.print_debug('hero already compiled')
|
||||
return
|
||||
}
|
||||
console.print_header('compile hero')
|
||||
install_(args)!
|
||||
|
||||
home_dir := os.home_dir()
|
||||
cmd_hero := texttools.template_replace($tmpl('templates/hero.sh'))
|
||||
osal.exec(cmd: cmd_hero, stdout: false)!
|
||||
|
||||
osal.execute_stdout(cmd_hero) or { return error('Cannot compile hero.\n${err}') }
|
||||
osal.done_set('compile_hero', 'OK')!
|
||||
cmd := "
|
||||
cd /tmp
|
||||
export TERM=xterm
|
||||
curl 'https://raw.githubusercontent.com/freeflowuniverse/herolib/refs/heads/development/install_v.sh' > /tmp/install_v.sh
|
||||
bash /tmp/install_v.sh --herolib
|
||||
"
|
||||
osal.execute_stdout(cmd) or { return error('Cannot install hero.\n${err}') }
|
||||
osal.done_set('install_hero', 'OK')!
|
||||
return
|
||||
}
|
||||
|
||||
42
lib/installers/lang/herolib/play.v
Normal file
42
lib/installers/lang/herolib/play.v
Normal file
@@ -0,0 +1,42 @@
|
||||
module herolib
|
||||
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
pub fn play(mut plbook playbook.PlayBook) ! {
|
||||
if !plbook.exists(filter: 'herolib.') {
|
||||
return
|
||||
}
|
||||
if plbook.exists(filter: 'herolib.uninstall') {
|
||||
console.print_header('play herolib.uninstall')
|
||||
for mut action in plbook.find(filter: 'herolib.uninstall')! {
|
||||
uninstall()!
|
||||
action.done = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if plbook.exists(filter: 'herolib.install') {
|
||||
console.print_header('play herolib.install')
|
||||
for mut action in plbook.find(filter: 'herolib.install')! {
|
||||
mut p := action.params
|
||||
install(
|
||||
reset: p.get_default_false('reset')
|
||||
)!
|
||||
action.done = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if plbook.exists(filter: 'herolib.compile') {
|
||||
console.print_header('play herolib.compile')
|
||||
for mut action in plbook.find(filter: 'herolib.compile')! {
|
||||
mut p := action.params
|
||||
compile(
|
||||
reset: p.get_default_false('reset')
|
||||
git_pull: p.get_default_false('git_pull')
|
||||
git_reset: p.get_default_false('git_reset')
|
||||
)!
|
||||
action.done = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
27
lib/installers/lang/herolib/readme.md
Normal file
27
lib/installers/lang/herolib/readme.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# Installer - Herolib Module
|
||||
|
||||
### `herolib.install`
|
||||
|
||||
Installs the `hero` command-line tool.
|
||||
|
||||
**Example:**
|
||||
|
||||
```heroscript
|
||||
!!herolib.install reset: true
|
||||
```
|
||||
|
||||
### `herolib.compile`
|
||||
|
||||
- `git_pull` (bool): Pull the latest changes from the git repository. Default: `true`.
|
||||
- `git_reset` (bool): Reset the git repository. Default: `false`.
|
||||
- `reset` (bool): If true, reinstall. Default: `false`.
|
||||
|
||||
```heroscript
|
||||
!!herolib.hero_compile git_reset:1 reset:1
|
||||
```
|
||||
|
||||
### `herolib.uninstall`
|
||||
|
||||
```heroscript
|
||||
!!herolib.uninstall
|
||||
```
|
||||
@@ -1,21 +0,0 @@
|
||||
export PATH=${home_dir}/hero/bin:??PATH
|
||||
export TERM=xterm
|
||||
|
||||
cd ${home_dir}/code/github/freeflowuniverse/herolib/cli/hero
|
||||
|
||||
PRF="${home_dir}/.profile"
|
||||
[ -f "??PRF" ] && source "??PRF"
|
||||
|
||||
if [[ "??OSTYPE" == "linux-gnu"* ]]; then
|
||||
#v -enable-globals -w -cflags -static -cc gcc hero.v
|
||||
v -enable-globals -w -n hero.v
|
||||
export HEROPATH='/usr/local/bin/hero'
|
||||
elif [[ "??OSTYPE" == "darwin"* ]]; then
|
||||
v -enable-globals -w -n hero.v
|
||||
export HEROPATH=${home_dir}/hero/bin/hero
|
||||
fi
|
||||
|
||||
chmod +x hero
|
||||
|
||||
cp hero ??HEROPATH
|
||||
rm hero
|
||||
@@ -35,7 +35,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure nodejs, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'nodejs.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -48,6 +48,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
install()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure python, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'python.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -48,6 +48,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
install()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure rust, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'rust.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -48,6 +48,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
install()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
27
lib/installers/lang/vlang/play.v
Normal file
27
lib/installers/lang/vlang/play.v
Normal file
@@ -0,0 +1,27 @@
|
||||
module vlang
|
||||
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
pub fn play(mut plbook playbook.PlayBook) ! {
|
||||
if plbook.exists(filter: 'vlang.install') {
|
||||
console.print_header('play vlang.install')
|
||||
for mut action in plbook.find(filter: 'vlang.install')! {
|
||||
mut p := action.params
|
||||
install(
|
||||
reset: p.get_default_false('reset')
|
||||
)!
|
||||
action.done = true
|
||||
}
|
||||
}
|
||||
if plbook.exists(filter: 'vlang.v_analyzer_install') {
|
||||
console.print_header('play vlang.v_analyzer_install')
|
||||
for mut action in plbook.find(filter: 'vlang.v_analyzer_install')! {
|
||||
mut p := action.params
|
||||
v_analyzer_install(
|
||||
reset: p.get_default_false('reset')
|
||||
)!
|
||||
action.done = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +1,33 @@
|
||||
https://github.com/v-analyzer/v-analyzer
|
||||
# Installer - Vlang Module
|
||||
|
||||
This module provides heroscript actions for installing and managing the V programming language and its tools.
|
||||
|
||||
## Actions
|
||||
|
||||
### `vlang.install`
|
||||
|
||||
Installs the V language compiler.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `reset` (bool): If true, force a reinstall even if V is already detected. Default: `false`.
|
||||
|
||||
**Example:**
|
||||
|
||||
```heroscript
|
||||
!!vlang.install
|
||||
reset: true
|
||||
```
|
||||
|
||||
### `vlang.v_analyzer_install`
|
||||
|
||||
Installs the `v-analyzer` language server for V.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `reset` (bool): If true, force a reinstall. Default: `false`.
|
||||
|
||||
**Example:**
|
||||
|
||||
```heroscript
|
||||
!!vlang.v_analyzer_install
|
||||
@@ -10,7 +10,7 @@ import os
|
||||
pub fn v_analyzer_install(args_ InstallArgs) ! {
|
||||
mut args := args_
|
||||
console.print_header('install v-analyzer (reset: ${args.reset})')
|
||||
version := '0.0.4'
|
||||
version := '0.0.6'
|
||||
_ := core.platform()!
|
||||
res := os.execute('${osal.profile_path_source_and()!} v-analyzer version')
|
||||
if res.exit_code == 0 {
|
||||
|
||||
@@ -11,7 +11,7 @@ import freeflowuniverse.herolib.develop.gittools
|
||||
|
||||
pub fn install(args_ InstallArgs) ! {
|
||||
mut args := args_
|
||||
version := '0.4.8'
|
||||
version := '0.4.11'
|
||||
console.print_header('install vlang (reset: ${args.reset})')
|
||||
res := os.execute('${osal.profile_path_source_and()!} v --version')
|
||||
if res.exit_code == 0 {
|
||||
@@ -38,28 +38,38 @@ pub fn install(args_ InstallArgs) ! {
|
||||
|
||||
base.develop()!
|
||||
|
||||
mut gs := gittools.new(coderoot: '${os.home_dir()}/_code')!
|
||||
mut repo := gs.get_repo(
|
||||
pull: true
|
||||
reset: true
|
||||
url: 'https://github.com/vlang/v/tree/master'
|
||||
osal.exec(
|
||||
cmd: '
|
||||
V_DIR="${os.home_dir()}/_code/v"
|
||||
|
||||
mkdir -p "${os.home_dir()}/_code"
|
||||
|
||||
cd ${os.home_dir()}/_code
|
||||
|
||||
if [ ! -d "\${V_DIR}" ]; then
|
||||
echo "Cloning V..."
|
||||
git clone --depth=1 https://github.com/vlang/v "\${V_DIR}"
|
||||
|
||||
else
|
||||
echo "V already exists, cleaning and updating..."
|
||||
cd "\${V_DIR}"
|
||||
git fetch origin
|
||||
git reset --hard origin/master
|
||||
git pull --rebase
|
||||
fi
|
||||
cd "\${V_DIR}"
|
||||
make
|
||||
'
|
||||
)!
|
||||
|
||||
mut path1 := repo.path()
|
||||
|
||||
mut extra := ''
|
||||
mut extra := 'cd ${os.home_dir()}/_code/v'
|
||||
if core.is_linux()! {
|
||||
extra = './v symlink'
|
||||
extra = '${extra}\n./v symlink'
|
||||
} else {
|
||||
extra = 'cp v ${os.home_dir()}/bin/'
|
||||
extra = '${extra}\ncp v ${os.home_dir()}/hero/bin/'
|
||||
}
|
||||
cmd := '
|
||||
cd ${path1}
|
||||
make
|
||||
${extra}
|
||||
'
|
||||
console.print_header('compile')
|
||||
osal.exec(cmd: cmd, stdout: true)!
|
||||
osal.exec(cmd: extra, stdout: true)!
|
||||
|
||||
console.print_header('compile done')
|
||||
|
||||
osal.done_set('install_vlang', 'OK')!
|
||||
|
||||
@@ -38,6 +38,7 @@ pub fn get(args ArgsGet) !&MyceliumInstaller {
|
||||
if r.hexists('context:mycelium_installer', args.name)! {
|
||||
data := r.hget('context:mycelium_installer', args.name)!
|
||||
if data.len == 0 {
|
||||
print_backtrace()
|
||||
return error('MyceliumInstaller with name: mycelium_installer does not exist, prob bug.')
|
||||
}
|
||||
mut obj := json.decode(MyceliumInstaller, data)!
|
||||
@@ -46,12 +47,14 @@ pub fn get(args ArgsGet) !&MyceliumInstaller {
|
||||
if args.create {
|
||||
new(args)!
|
||||
} else {
|
||||
print_backtrace()
|
||||
return error("MyceliumInstaller with name 'mycelium_installer' does not exist")
|
||||
}
|
||||
}
|
||||
return get(name: args.name)! // no longer from db nor create
|
||||
}
|
||||
return mycelium_installer_global[args.name] or {
|
||||
print_backtrace()
|
||||
return error('could not get config for mycelium_installer with name:mycelium_installer')
|
||||
}
|
||||
}
|
||||
@@ -124,14 +127,15 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
mut install_actions := plbook.find(filter: 'mycelium_installer.configure')!
|
||||
if install_actions.len > 0 {
|
||||
for install_action in install_actions {
|
||||
for mut install_action in install_actions {
|
||||
heroscript := install_action.heroscript()
|
||||
mut obj2 := heroscript_loads(heroscript)!
|
||||
set(obj2)!
|
||||
install_action.done = true
|
||||
}
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'mycelium_installer.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -163,6 +167,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
mycelium_installer_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,19 +183,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: screen')
|
||||
console.print_debug("installer: mycelium_installer' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: mycelium_installer' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: mycelium_installer' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: mycelium_installer' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -208,7 +213,7 @@ pub fn (mut self MyceliumInstaller) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('mycelium_installer start')
|
||||
console.print_header('installer: mycelium_installer start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -221,7 +226,7 @@ pub fn (mut self MyceliumInstaller) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting mycelium_installer with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: mycelium_installer starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure wireguard_installer, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'wireguard_installer.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -48,6 +48,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
install()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure yggdrasil, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'yggdrasil.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -68,6 +68,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
yggdrasil_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,19 +84,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: yggdrasil' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: yggdrasil' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: yggdrasil' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: yggdrasil' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -106,7 +107,7 @@ pub fn (mut self YggdrasilInstaller) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('yggdrasil start')
|
||||
console.print_header('installer: yggdrasil start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -119,7 +120,7 @@ pub fn (mut self YggdrasilInstaller) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting yggdrasil with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: yggdrasil starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure actrunner, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'actrunner.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -68,6 +68,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
actrunner_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,19 +84,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: actrunner' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: actrunner' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: actrunner' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: actrunner' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -106,7 +107,7 @@ pub fn (mut self ActRunner) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('actrunner start')
|
||||
console.print_header('installer: actrunner start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -119,7 +120,7 @@ pub fn (mut self ActRunner) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting actrunner with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: actrunner starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure b2, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'b2.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -48,6 +48,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
install()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure fungistor, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'fungistor.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -68,6 +68,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
fungistor_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,19 +84,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: fungistor' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: fungistor' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: fungistor' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: fungistor' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -106,7 +107,7 @@ pub fn (mut self FungiStor) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('fungistor start')
|
||||
console.print_header('installer: fungistor start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -119,7 +120,7 @@ pub fn (mut self FungiStor) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting fungistor with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: fungistor starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ pub fn get(args ArgsGet) !&GarageS3 {
|
||||
if r.hexists('context:garage_s3', args.name)! {
|
||||
data := r.hget('context:garage_s3', args.name)!
|
||||
if data.len == 0 {
|
||||
print_backtrace()
|
||||
return error('GarageS3 with name: garage_s3 does not exist, prob bug.')
|
||||
}
|
||||
mut obj := json.decode(GarageS3, data)!
|
||||
@@ -46,12 +47,14 @@ pub fn get(args ArgsGet) !&GarageS3 {
|
||||
if args.create {
|
||||
new(args)!
|
||||
} else {
|
||||
print_backtrace()
|
||||
return error("GarageS3 with name 'garage_s3' does not exist")
|
||||
}
|
||||
}
|
||||
return get(name: args.name)! // no longer from db nor create
|
||||
}
|
||||
return garage_s3_global[args.name] or {
|
||||
print_backtrace()
|
||||
return error('could not get config for garage_s3 with name:garage_s3')
|
||||
}
|
||||
}
|
||||
@@ -124,14 +127,15 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
mut install_actions := plbook.find(filter: 'garage_s3.configure')!
|
||||
if install_actions.len > 0 {
|
||||
for install_action in install_actions {
|
||||
for mut install_action in install_actions {
|
||||
heroscript := install_action.heroscript()
|
||||
mut obj2 := heroscript_loads(heroscript)!
|
||||
set(obj2)!
|
||||
install_action.done = true
|
||||
}
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'garage_s3.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -163,6 +167,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
garage_s3_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,19 +183,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: garage_s3' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: garage_s3' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: garage_s3' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: garage_s3' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -208,7 +213,7 @@ pub fn (mut self GarageS3) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('garage_s3 start')
|
||||
console.print_header('installer: garage_s3 start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -221,7 +226,7 @@ pub fn (mut self GarageS3) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting garage_s3 with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: garage_s3 starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure grafana, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'grafana.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -68,6 +68,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
grafana_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,19 +84,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: grafana' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: grafana' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: grafana' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: grafana' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -106,7 +107,7 @@ pub fn (mut self Grafana) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('grafana start')
|
||||
console.print_header('installer: grafana start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -119,7 +120,7 @@ pub fn (mut self Grafana) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting grafana with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: grafana starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure prometheus, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'prometheus.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -68,6 +68,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
prometheus_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,19 +84,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: prometheus' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: prometheus' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: prometheus' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: prometheus' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -106,7 +107,7 @@ pub fn (mut self Prometheus) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('prometheus start')
|
||||
console.print_header('installer: prometheus start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -119,7 +120,7 @@ pub fn (mut self Prometheus) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting prometheus with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: prometheus starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ pub fn get(args ArgsGet) !&RClone {
|
||||
if r.hexists('context:rclone', args.name)! {
|
||||
data := r.hget('context:rclone', args.name)!
|
||||
if data.len == 0 {
|
||||
print_backtrace()
|
||||
return error('RClone with name: rclone does not exist, prob bug.')
|
||||
}
|
||||
mut obj := json.decode(RClone, data)!
|
||||
@@ -45,12 +46,14 @@ pub fn get(args ArgsGet) !&RClone {
|
||||
if args.create {
|
||||
new(args)!
|
||||
} else {
|
||||
print_backtrace()
|
||||
return error("RClone with name 'rclone' does not exist")
|
||||
}
|
||||
}
|
||||
return get(name: args.name)! // no longer from db nor create
|
||||
}
|
||||
return rclone_global[args.name] or {
|
||||
print_backtrace()
|
||||
return error('could not get config for rclone with name:rclone')
|
||||
}
|
||||
}
|
||||
@@ -123,14 +126,15 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
mut install_actions := plbook.find(filter: 'rclone.configure')!
|
||||
if install_actions.len > 0 {
|
||||
for install_action in install_actions {
|
||||
for mut install_action in install_actions {
|
||||
heroscript := install_action.heroscript()
|
||||
mut obj2 := heroscript_loads(heroscript)!
|
||||
set(obj2)!
|
||||
install_action.done = true
|
||||
}
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'rclone.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -143,6 +147,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
install()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure restic, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'restic.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -68,6 +68,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
restic_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,19 +84,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: restic' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: restic' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: restic' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: restic' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -106,7 +107,7 @@ pub fn (mut self Restic) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('restic start')
|
||||
console.print_header('installer: restic start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -119,7 +120,7 @@ pub fn (mut self Restic) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting restic with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: restic starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure s3, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 's3.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -68,6 +68,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
s3_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,19 +84,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: s3' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: s3' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: s3' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: s3' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -106,7 +107,7 @@ pub fn (mut self S3Installer) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('s3 start')
|
||||
console.print_header('installer: s3 start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -119,7 +120,7 @@ pub fn (mut self S3Installer) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting s3 with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: s3 starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure griddriver, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'griddriver.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -48,6 +48,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
install()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure cloudhypervisor, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'cloudhypervisor.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -48,6 +48,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
install()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
return error("can't configure docker, because no configuration allowed for this installer.")
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'docker.')!
|
||||
for other_action in other_actions {
|
||||
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')
|
||||
@@ -68,6 +68,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
docker_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,19 +84,19 @@ fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.Sta
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: docker' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
console.print_debug("installer: docker' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
console.print_debug("installer: docker' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
console.print_debug("installer: docker' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
@@ -107,7 +108,7 @@ pub fn (mut self DockerInstaller) start() ! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('docker start')
|
||||
console.print_header('installer: docker start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
@@ -120,7 +121,7 @@ pub fn (mut self DockerInstaller) start() ! {
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('starting docker with ${zprocess.startuptype}...')
|
||||
console.print_debug('installer: docker starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user