chore: add current provisioning state before migration
This commit is contained in:
parent
a9703b4748
commit
50745b0f22
660 changed files with 88126 additions and 0 deletions
55
core/nulib/models/no_plugins_defs.nu
Normal file
55
core/nulib/models/no_plugins_defs.nu
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
use std
|
||||
use ../lib_provisioning/utils *
|
||||
|
||||
export def clip_copy [
|
||||
msg: string
|
||||
show: bool
|
||||
]: nothing -> nothing {
|
||||
if (not $show) { _print $msg }
|
||||
}
|
||||
|
||||
export def notify_msg [
|
||||
title: string
|
||||
body: string
|
||||
icon: string
|
||||
time_body: string
|
||||
timeout: duration
|
||||
task?: closure
|
||||
]: nothing -> nothing {
|
||||
if $task != null {
|
||||
_print (
|
||||
$"(_ansi blue)($title)(_ansi reset)\n(ansi blue_bold)($time_body)(_ansi reset)"
|
||||
)
|
||||
} else {
|
||||
_print (
|
||||
$"(_ansi blue)($title)(_ansi reset)\n(ansi blue_bold)($body)(_ansi reset)"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export def show_qr [
|
||||
url: string
|
||||
]: nothing -> nothing {
|
||||
let qr_path = ($env.PROVISIONING_RESOURCES | path join "qrs" | path join ($env.PROVISIONING |
|
||||
($url | path basename)
|
||||
))
|
||||
if ($qr_path | path exists) {
|
||||
_print (open -r $qr_path)
|
||||
} else {
|
||||
_print $"(_ansi purple)($url)(_ansi reset)"
|
||||
}
|
||||
}
|
||||
|
||||
export def port_scan [
|
||||
ip: string
|
||||
port: int
|
||||
sec_timeout: int
|
||||
]: nothing -> bool {
|
||||
# # control moved to core/bin/install_nu.sh
|
||||
# if (^bash -c "type -P nc" | is-empty) {
|
||||
# (throw-error $"🛑 port scan ($ip) ($port)" $"(_ansi green)nc(_ansi reset) command not found"
|
||||
# "port_scan")
|
||||
# exit 1
|
||||
# }
|
||||
(^nc -zv -w $sec_timeout ($ip | str trim) $port err> (if $nu.os-info.name == "windows" { "NUL" } else { "/dev/null" })| complete).exit_code == 0
|
||||
}
|
||||
71
core/nulib/models/plugins_defs.nu
Normal file
71
core/nulib/models/plugins_defs.nu
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
use ../lib_provisioning/utils *
|
||||
|
||||
export def clip_copy [
|
||||
msg: string
|
||||
show: bool
|
||||
]: nothing -> nothing {
|
||||
if ( (version).installed_plugins | str contains "clipboard" ) {
|
||||
$msg | clipboard copy
|
||||
print $"(_ansi default_dimmed)copied into clipboard now (_ansi reset)"
|
||||
} else {
|
||||
if (not $show) { _print $msg }
|
||||
}
|
||||
}
|
||||
|
||||
export def notify_msg [
|
||||
title: string
|
||||
body: string
|
||||
icon: string
|
||||
time_body: string
|
||||
timeout: duration
|
||||
task?: closure
|
||||
]: nothing -> nothing {
|
||||
if ( (version).installed_plugins | str contains "desktop_notifications" ) {
|
||||
if $task != null {
|
||||
( notify -s $title -t $time_body --timeout $timeout -i $icon)
|
||||
} else {
|
||||
( notify -s $title -t $body --timeout $timeout -i $icon)
|
||||
}
|
||||
} else {
|
||||
if $task != null {
|
||||
_print (
|
||||
$"(_ansi blue)($title)(_ansi reset)\n(ansi blue_bold)($time_body)(_ansi reset)"
|
||||
)
|
||||
} else {
|
||||
_print (
|
||||
$"(_ansi blue)($title)(_ansi reset)\n(ansi blue_bold)($body)(_ansi reset)"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export def show_qr [
|
||||
url: string
|
||||
]: nothing -> nothing {
|
||||
if ( (version).installed_plugins | str contains "qr_maker" ) {
|
||||
print $"(_ansi blue_reverse)( $url | to qr )(_ansi reset)"
|
||||
} else {
|
||||
let qr_path = ($env.PROVISIONING_RESOURCES | path join "qrs" | path join ($env.PROVISIONING |
|
||||
($url | path basename)
|
||||
))
|
||||
if ($qr_path | path exists) {
|
||||
_print (open -r $qr_path)
|
||||
} else {
|
||||
_print $"(_ansi blue_reverse)( $url)(_ansi reset)"
|
||||
_print $"(_ansi purple)($url)(_ansi reset)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export def port_scan [
|
||||
ip: string
|
||||
port: int
|
||||
sec_timeout: int
|
||||
]: nothing -> bool {
|
||||
let wait_duration = ($"($sec_timeout)sec"| into duration)
|
||||
if ( (version).installed_plugins | str contains "port_scan" ) {
|
||||
(port scan $ip $port -t $wait_duration).is_open
|
||||
} else {
|
||||
(^nc -zv -w $sec_timeout ($ip | str trim) $port err> (if $nu.os-info.name == "windows" { "NUL" } else { "/dev/null" })| complete).exit_code == 0
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue