Compare commits
3 Commits
rs
...
5b033bf5ab
Author | SHA1 | Date | |
---|---|---|---|
5b033bf5ab | |||
57064a39b6 | |||
7c85855281 |
@ -1,5 +1,4 @@
|
||||
Dockerfile
|
||||
modd.*
|
||||
tmp/**/*
|
||||
dist/*
|
||||
go.work
|
||||
|
460
Cargo.lock
generated
460
Cargo.lock
generated
@ -1,21 +1,21 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.24.2"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
|
||||
checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.1"
|
||||
name = "adler"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
@ -28,9 +28,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.19"
|
||||
version = "0.6.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933"
|
||||
checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
@ -43,95 +43,88 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.11"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
|
||||
checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.7"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
|
||||
checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.3"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9"
|
||||
checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.9"
|
||||
version = "3.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882"
|
||||
checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell_polyfill",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.75"
|
||||
name = "anyhow"
|
||||
version = "1.0.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002"
|
||||
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.9.1"
|
||||
name = "bytes"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
|
||||
checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.10.1"
|
||||
name = "cc"
|
||||
version = "1.0.101"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
|
||||
checksum = "ac367972e516d45567c7eafc73d24e1c193dcf200a8d94e9db7b3d38b349572d"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.1"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
|
||||
|
||||
[[package]]
|
||||
name = "cfg_aliases"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.4"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
||||
checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422"
|
||||
|
||||
[[package]]
|
||||
name = "env_filter"
|
||||
version = "0.1.3"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0"
|
||||
checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea"
|
||||
dependencies = [
|
||||
"log",
|
||||
"regex",
|
||||
@ -139,56 +132,46 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.11.8"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f"
|
||||
checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"env_filter",
|
||||
"jiff",
|
||||
"humantime",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||
|
||||
[[package]]
|
||||
name = "eyre"
|
||||
version = "0.6.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec"
|
||||
dependencies = [
|
||||
"indenter",
|
||||
"once_cell",
|
||||
]
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.31.1"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.4"
|
||||
version = "0.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
|
||||
[[package]]
|
||||
name = "indenter"
|
||||
version = "0.3.3"
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.9.0"
|
||||
version = "2.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
|
||||
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
@ -196,181 +179,105 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "init"
|
||||
version = "2.1.0"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"env_logger",
|
||||
"eyre",
|
||||
"itertools",
|
||||
"log",
|
||||
"nix",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"shell-escape",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
version = "1.70.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800"
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.15"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
|
||||
[[package]]
|
||||
name = "jiff"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a194df1107f33c79f4f93d02c80798520551949d59dfad22b6157048a88cca93"
|
||||
dependencies = [
|
||||
"jiff-static",
|
||||
"log",
|
||||
"portable-atomic",
|
||||
"portable-atomic-util",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jiff-static"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c6e1db7ed32c6c71b759497fae34bf7933636f75a251b9e736555da426f6442"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.172"
|
||||
version = "0.2.155"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
|
||||
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.27"
|
||||
version = "0.4.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.5"
|
||||
version = "2.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
|
||||
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.9"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
||||
checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
"adler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.0.4"
|
||||
version = "0.8.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
|
||||
checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.30.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.36.7"
|
||||
version = "0.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
|
||||
checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.16"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic-util"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507"
|
||||
dependencies = [
|
||||
"portable-atomic",
|
||||
]
|
||||
checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.95"
|
||||
version = "1.0.81"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
|
||||
checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.40"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.1"
|
||||
version = "1.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
||||
checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@ -380,9 +287,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.9"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
||||
checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@ -391,36 +298,36 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.5"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.25"
|
||||
version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
|
||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.20"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||
checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.219"
|
||||
version = "1.0.199"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
||||
checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.219"
|
||||
version = "1.0.199"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
||||
checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -429,12 +336,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.140"
|
||||
version = "1.0.116"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
||||
checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
@ -452,36 +358,20 @@ dependencies = [
|
||||
"unsafe-libyaml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shell-escape"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.5"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410"
|
||||
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.103"
|
||||
version = "2.0.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4307e30089d6fd6aff212f2da3a1f9e32f3223b1f010fb09b7c95f90f3ca1e8"
|
||||
checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -490,9 +380,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.45.1"
|
||||
version = "1.38.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779"
|
||||
checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
@ -500,16 +390,15 @@ dependencies = [
|
||||
"mio",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.5.0"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
|
||||
checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -518,9 +407,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.18"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "unsafe-libyaml"
|
||||
@ -530,15 +419,24 @@ checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.1+wasi-snapshot-preview1"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
dependencies = [
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
@ -546,78 +444,126 @@ version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
"windows-targets 0.52.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_aarch64_gnullvm 0.48.5",
|
||||
"windows_aarch64_msvc 0.48.5",
|
||||
"windows_i686_gnu 0.48.5",
|
||||
"windows_i686_msvc 0.48.5",
|
||||
"windows_x86_64_gnu 0.48.5",
|
||||
"windows_x86_64_gnullvm 0.48.5",
|
||||
"windows_x86_64_msvc 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm 0.52.5",
|
||||
"windows_aarch64_msvc 0.52.5",
|
||||
"windows_i686_gnu 0.52.5",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
"windows_i686_msvc 0.52.5",
|
||||
"windows_x86_64_gnu 0.52.5",
|
||||
"windows_x86_64_gnullvm 0.52.5",
|
||||
"windows_x86_64_msvc 0.52.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
||||
|
18
Cargo.toml
18
Cargo.toml
@ -1,23 +1,15 @@
|
||||
[package]
|
||||
name = "init"
|
||||
version = "2.1.0"
|
||||
edition = "2024"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[profile.release]
|
||||
strip = true
|
||||
panic = "abort"
|
||||
opt-level = "z"
|
||||
lto = true
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.86"
|
||||
env_logger = "0.11.3"
|
||||
eyre = "0.6.12"
|
||||
itertools = "0.14.0"
|
||||
log = "0.4.21"
|
||||
nix = { version = "0.30.1", features = ["feature", "reboot"] }
|
||||
regex = "1.11.1"
|
||||
serde = { version = "1.0.198", features = ["derive"] }
|
||||
serde_json = "1.0.116"
|
||||
serde_yaml = "0.9.34"
|
||||
shell-escape = "0.1.5"
|
||||
tokio = { version = "1.38.0", features = ["rt", "signal", "process", "net", "macros"] }
|
||||
tokio = { version = "1.38.0", features = ["rt", "signal", "process", "macros"] }
|
||||
|
42
Dockerfile
42
Dockerfile
@ -1,37 +1,49 @@
|
||||
from rust:1.87.0-alpine as rust
|
||||
# ------------------------------------------------------------------------
|
||||
from rust:1.79.0-alpine3.20 as rust
|
||||
|
||||
run apk add --no-cache git musl-dev libudev-zero-dev # pkgconfig cryptsetup-dev lvm2-dev clang-dev clang-static
|
||||
run apk add --no-cache musl-dev # pkgconfig cryptsetup-dev lvm2-dev clang-dev clang-static
|
||||
|
||||
workdir /src
|
||||
copy . .
|
||||
copy Cargo.* .
|
||||
copy src src
|
||||
run --mount=type=cache,id=novit-rs,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,id=novit-rs-target,sharing=private,target=/src/target \
|
||||
cargo build --release && cp target/release/init /
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
from alpine:3.22.0 as initrd
|
||||
from golang:1.22.4-alpine3.20 as build
|
||||
|
||||
workdir /src
|
||||
|
||||
copy . .
|
||||
|
||||
run \
|
||||
--mount=type=cache,id=gomod,target=/go/pkg/mod \
|
||||
--mount=type=cache,id=gobuild,target=/root/.cache/go-build \
|
||||
go test ./... \
|
||||
&& go build -o /go/bin/init -trimpath .
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
from alpine:3.20.0 as initrd
|
||||
|
||||
run apk add --no-cache xz
|
||||
|
||||
workdir /layer
|
||||
|
||||
run . /etc/os-release \
|
||||
&& wget -O- https://dl-cdn.alpinelinux.org/alpine/v${VERSION_ID%.*}/releases/x86_64/alpine-minirootfs-${VERSION_ID}-x86_64.tar.gz |tar zxv
|
||||
|
||||
run apk add --no-cache --update -p . musl coreutils \
|
||||
lvm2 lvm2-extra lvm2-dmeventd udev cryptsetup \
|
||||
e2fsprogs lsblk openssh-server \
|
||||
&& rm -rf usr/share/apk var/cache/apk etc/motd
|
||||
run apk add --no-cache -p . musl lvm2 lvm2-extra lvm2-dmeventd udev cryptsetup e2fsprogs btrfs-progs lsblk
|
||||
run rm -rf usr/share/apk var/cache/apk
|
||||
|
||||
copy etc/sshd_config etc/ssh/sshd_config
|
||||
|
||||
copy --from=rust /init init
|
||||
run cd bin && for cmd in init-version connect-boot bootstrap; do ln -s ../init $cmd; done
|
||||
#copy --from=build /go/bin/init .
|
||||
copy --from=rust /init .
|
||||
|
||||
# check viability
|
||||
run chroot . init-version
|
||||
run chroot . /init hello
|
||||
|
||||
run find |cpio -H newc -o >/initrd
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
from alpine:3.22.0
|
||||
from alpine:3.20.0
|
||||
copy --from=initrd /initrd /
|
||||
entrypoint ["base64","/initrd"]
|
||||
|
@ -59,6 +59,12 @@ func bootV2() {
|
||||
}
|
||||
}
|
||||
|
||||
// load basic modules
|
||||
for _, module := range []string{"unix"} {
|
||||
log.Info().Str("module", module).Msg("loading module")
|
||||
run("modprobe", module)
|
||||
}
|
||||
|
||||
// devices init
|
||||
log.Info().Msg("starting udevd")
|
||||
err := exec.Command("udevd").Start()
|
||||
|
14
bootstrap.go
14
bootstrap.go
@ -8,7 +8,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
@ -46,18 +45,9 @@ func bootstrap(cfg *config.Config) {
|
||||
bootstrapFile := filepath.Join(baseDir, "bootstrap.tar")
|
||||
|
||||
err = func() (err error) {
|
||||
var resp *http.Response
|
||||
|
||||
start := time.Now()
|
||||
for time.Since(start) <= time.Minute {
|
||||
resp, err = http.Get(seed)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
resp, err := http.Get(seed)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to fetch bootstrap")
|
||||
return
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
|
9
build.rs
9
build.rs
@ -1,9 +0,0 @@
|
||||
use std::process::Command;
|
||||
fn main() {
|
||||
let output = Command::new("git")
|
||||
.args(&["rev-parse", "HEAD"])
|
||||
.output()
|
||||
.unwrap();
|
||||
let git_commit = String::from_utf8(output.stdout).unwrap();
|
||||
println!("cargo:rustc-env=GIT_COMMIT={}", git_commit);
|
||||
}
|
@ -1 +0,0 @@
|
||||
../target/debug/init
|
@ -1 +0,0 @@
|
||||
../target/debug/init
|
@ -1 +0,0 @@
|
||||
../target/debug/init
|
@ -1 +0,0 @@
|
||||
../target/debug/init
|
@ -1,8 +0,0 @@
|
||||
KbdInteractiveAuthentication no
|
||||
PasswordAuthentication no
|
||||
UsePAM no
|
||||
|
||||
PubkeyAuthentication yes
|
||||
|
||||
PermitRootLogin yes
|
||||
AllowUsers root
|
32
go.mod
32
go.mod
@ -1,35 +1,31 @@
|
||||
module novit.tech/direktil/initrd
|
||||
|
||||
require (
|
||||
github.com/creack/pty v1.1.24
|
||||
github.com/creack/pty v1.1.21
|
||||
github.com/freddierice/go-losetup/v2 v2.0.1
|
||||
github.com/jochenvg/go-udev v0.0.0-20240801134859-b65ed646224b
|
||||
github.com/pkg/term v1.1.0
|
||||
github.com/rs/zerolog v1.34.0
|
||||
golang.org/x/crypto v0.38.0
|
||||
golang.org/x/sys v0.33.0
|
||||
golang.org/x/term v0.32.0
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10
|
||||
github.com/rs/zerolog v1.31.0
|
||||
golang.org/x/crypto v0.18.0
|
||||
golang.org/x/sys v0.16.0
|
||||
golang.org/x/term v0.16.0
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
novit.tech/direktil/pkg v0.0.0-20240415130406-0d2e181a4ed6
|
||||
novit.tech/direktil/pkg v0.0.0-20240120172717-8498a102796f
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cavaliergopher/cpio v1.0.1 // indirect
|
||||
github.com/google/go-cmp v0.7.0 // indirect
|
||||
github.com/jkeiser/iter v0.0.0-20200628201005-c8aa0ae784d1 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/josharian/native v1.1.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mdlayher/genetlink v1.3.2 // indirect
|
||||
github.com/mdlayher/netlink v1.7.2 // indirect
|
||||
github.com/mdlayher/socket v0.5.1 // indirect
|
||||
golang.org/x/net v0.40.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.zx2c4.com/wireguard v0.0.0-20250521234502-f333402bd9cb // indirect
|
||||
github.com/mdlayher/socket v0.5.0 // indirect
|
||||
golang.org/x/net v0.20.0 // indirect
|
||||
golang.org/x/sync v0.6.0 // indirect
|
||||
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 // indirect
|
||||
)
|
||||
|
||||
go 1.23.1
|
||||
|
||||
toolchain go1.24.3
|
||||
go 1.21
|
||||
|
52
go.sum
52
go.sum
@ -1,22 +1,17 @@
|
||||
github.com/cavaliergopher/cpio v1.0.1 h1:KQFSeKmZhv0cr+kawA3a0xTQCU4QxXF1vhU7P7av2KM=
|
||||
github.com/cavaliergopher/cpio v1.0.1/go.mod h1:pBdaqQjnvXxdS/6CvNDwIANIFSP0xRKI16PX4xejRQc=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
|
||||
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
|
||||
github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
|
||||
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
|
||||
github.com/freddierice/go-losetup/v2 v2.0.1 h1:wPDx/Elu9nDV8y/CvIbEDz5Xi5Zo80y4h7MKbi3XaAI=
|
||||
github.com/freddierice/go-losetup/v2 v2.0.1/go.mod h1:TEyBrvlOelsPEhfWD5rutNXDmUszBXuFnwT1kIQF4J8=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/jkeiser/iter v0.0.0-20200628201005-c8aa0ae784d1 h1:smvLGU3obGU5kny71BtE/ibR0wIXRUiRFDmSn0Nxz1E=
|
||||
github.com/jkeiser/iter v0.0.0-20200628201005-c8aa0ae784d1/go.mod h1:fP/NdyhRVOv09PLRbVXrSqHhrfQypdZwgE2L4h2U5C8=
|
||||
github.com/jochenvg/go-udev v0.0.0-20240801134859-b65ed646224b h1:Pzf7tldbCVqwl3NnOnTamEWdh/rL41fsoYCn2HdHgRA=
|
||||
github.com/jochenvg/go-udev v0.0.0-20240801134859-b65ed646224b/go.mod h1:IBDUGq30U56w969YNPomhMbRje1GrhUsCh7tHdwgLXA=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
|
||||
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
@ -25,25 +20,22 @@ github.com/mdlayher/genetlink v1.3.2 h1:KdrNKe+CTu+IbZnm/GVUMXSqBBLqcGpRDa0xkQy5
|
||||
github.com/mdlayher/genetlink v1.3.2/go.mod h1:tcC3pkCrPUGIKKsCsp0B3AdaaKuHtaxoJRz3cc+528o=
|
||||
github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/g=
|
||||
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
|
||||
github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos=
|
||||
github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ=
|
||||
github.com/mdlayher/socket v0.5.0 h1:ilICZmJcQz70vrWVes1MFera4jGiWNocSkykwwoy3XI=
|
||||
github.com/mdlayher/socket v0.5.0/go.mod h1:WkcBFfvyG8QENs5+hfQPl1X6Jpd2yeLIYgrGFmJiJxI=
|
||||
github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721 h1:RlZweED6sbSArvlE924+mUcZuXKLBHA35U7LN621Bws=
|
||||
github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721/go.mod h1:Ickgr2WtCLZ2MDGd4Gr0geeCH5HybhRJbonOgQpvSxc=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/term v1.1.0 h1:xIAAdCMh3QIAy+5FrE8Ad8XoDhEU4ufwbaSozViP9kk=
|
||||
github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
|
||||
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
|
||||
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
|
||||
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
|
||||
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
|
||||
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
||||
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
|
||||
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
@ -51,13 +43,13 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
|
||||
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
|
||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
|
||||
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@ -69,16 +61,14 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
|
||||
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
|
||||
golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg=
|
||||
golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
@ -90,15 +80,15 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.zx2c4.com/wireguard v0.0.0-20250521234502-f333402bd9cb h1:whnFRlWMcXI9d+ZbWg+4sHnLp52d5yiIPUxMBSt4X9A=
|
||||
golang.zx2c4.com/wireguard v0.0.0-20250521234502-f333402bd9cb/go.mod h1:rpwXGsirqLqN2L0JDJQlwOboGHmptD5ZD6T2VmcqhTw=
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10 h1:3GDAcqdIg1ozBNLgPy4SLT84nfcBjr6rhGtXYtrkWLU=
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10/go.mod h1:T97yPqesLiNrOYxkwmhMI0ZIlJDm+p0PMR8eRVeR5tQ=
|
||||
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uIfPMv78iAJGcPKDeqAFnaLBropIC4=
|
||||
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA=
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 h1:CawjfCvYQH2OU3/TnxLx97WDSUDRABfT18pCOYwc2GE=
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6/go.mod h1:3rxYc4HtVcSG9gVaTs2GEBdehh+sYPOwKtyUWEOTb80=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
novit.tech/direktil/pkg v0.0.0-20240415130406-0d2e181a4ed6 h1:D0TN5GyZ4d88ILpgVZgcZ62027lW8/LLnQSpQyN2yOw=
|
||||
novit.tech/direktil/pkg v0.0.0-20240415130406-0d2e181a4ed6/go.mod h1:zjezU6tELE880oYHs/WAauGBupKIEQQ7KqWTB69RW10=
|
||||
novit.tech/direktil/pkg v0.0.0-20240120172717-8498a102796f h1:7y11nLhChrrsLQwRaW7wn/9x+Xn2gEVtzj75VkOpJ+o=
|
||||
novit.tech/direktil/pkg v0.0.0-20240120172717-8498a102796f/go.mod h1:zjezU6tELE880oYHs/WAauGBupKIEQQ7KqWTB69RW10=
|
||||
|
54
lvm.go
54
lvm.go
@ -8,9 +8,7 @@ import (
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
udev "github.com/jochenvg/go-udev"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
config "novit.tech/direktil/pkg/bootstrapconfig"
|
||||
@ -92,47 +90,25 @@ func setupVG(vg config.LvmVG) {
|
||||
log.Info().Msg("LVM VG does not exists, creating")
|
||||
}
|
||||
|
||||
devNames := make([]NameAliases, 0)
|
||||
{
|
||||
devRefs := map[uint64]*NameAliases{}
|
||||
|
||||
enum := new(udev.Udev).NewEnumerate()
|
||||
enum.AddMatchSubsystem("block")
|
||||
|
||||
devs, err := enum.Devices()
|
||||
if err != nil {
|
||||
fatal("udev enumeration failed")
|
||||
devNames := make([]string, 0)
|
||||
err = filepath.Walk("/dev", func(n string, fi fs.FileInfo, err error) error {
|
||||
if fi.Mode().Type() == os.ModeDevice {
|
||||
devNames = append(devNames, n)
|
||||
}
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
fatalf("failed to walk /dev: %v", err)
|
||||
}
|
||||
|
||||
for _, dev := range devs {
|
||||
num := dev.Devnum()
|
||||
|
||||
n := dev.PropertyValue("DEVNAME")
|
||||
idx := len(devNames)
|
||||
devNames = append(devNames, nameAlias(n))
|
||||
|
||||
ref := uint64(num.Major())<<8 | uint64(num.Minor())
|
||||
devRefs[ref] = &devNames[idx]
|
||||
}
|
||||
|
||||
err = filepath.Walk("/dev", func(n string, fi fs.FileInfo, err error) error {
|
||||
if fi.Mode().Type() == os.ModeDevice {
|
||||
stat := fi.Sys().(*syscall.Stat_t)
|
||||
ref := stat.Rdev
|
||||
if na := devRefs[ref]; na != nil {
|
||||
na.AddAlias(n)
|
||||
}
|
||||
devNames = filter(devNames, func(v string) bool {
|
||||
for _, pv := range pvs.PVs() {
|
||||
if v == pv.Name {
|
||||
return false
|
||||
}
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
fatalf("failed to walk /dev: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
for _, dev := range devNames {
|
||||
log.Info().Str("name", dev.Name).Any("aliases", dev.Aliases).Msg("found block device")
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
m := regexpSelectN(vg.PVs.N, vg.PVs.Regexps, devNames)
|
||||
if len(m) == 0 {
|
||||
|
21
modd.conf
21
modd.conf
@ -1,14 +1,21 @@
|
||||
modd.conf {}
|
||||
|
||||
go.??? **/*.go {
|
||||
prep: go test ./...
|
||||
prep: mkdir -p dist
|
||||
prep: go build -o dist/init .
|
||||
prep: go build -o dist/ ./tools/...
|
||||
}
|
||||
|
||||
**/*.rs Cargo.* {
|
||||
prep: cargo test
|
||||
prep: cargo build
|
||||
prep: debug/init-version
|
||||
}
|
||||
|
||||
target/debug/init Dockerfile {
|
||||
#prep: cargo build
|
||||
prep: docker build --network host -t novit-initrd-gen .
|
||||
prep: docker run --net=host --rm novit-initrd-gen |base64 -d >dist/initrd.new
|
||||
prep: mv dist/initrd.new dist/initrd
|
||||
prep: ls -sh dist/initrd
|
||||
}
|
||||
|
||||
#dist/init Dockerfile {
|
||||
# prep: docker build --network host -t novit-initrd-gen .
|
||||
# prep: docker run --net=host --rm novit-initrd-gen |base64 -d >dist/initrd.new
|
||||
# prep: mv dist/initrd.new dist/initrd
|
||||
#}
|
||||
|
47
network.go
47
network.go
@ -1,10 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
udev "github.com/jochenvg/go-udev"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
config "novit.tech/direktil/pkg/bootstrapconfig"
|
||||
@ -16,31 +16,14 @@ func setupNetworks(cfg *config.Config) {
|
||||
return
|
||||
}
|
||||
|
||||
type Iface struct {
|
||||
Name string
|
||||
AliasOf string
|
||||
}
|
||||
|
||||
ifaces := make([]NameAliases, 0)
|
||||
ifNames := make([]string, 0)
|
||||
{
|
||||
enum := new(udev.Udev).NewEnumerate()
|
||||
enum.AddMatchSubsystem("net")
|
||||
|
||||
devs, err := enum.Devices()
|
||||
ifaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
fatal("udev enumeration failed")
|
||||
fatal("failed")
|
||||
}
|
||||
|
||||
for _, dev := range devs {
|
||||
iface := nameAliases(dev.Sysname(),
|
||||
dev.PropertyValue("INTERFACE"),
|
||||
dev.PropertyValue("ID_NET_NAME"),
|
||||
dev.PropertyValue("ID_NET_NAME_PATH"),
|
||||
dev.PropertyValue("ID_NET_NAME_MAC"),
|
||||
dev.PropertyValue("ID_NET_NAME_SLOT"),
|
||||
)
|
||||
log.Info().Str("name", iface.Name).Any("aliases", iface.Aliases).Msg("found network device")
|
||||
ifaces = append(ifaces, iface)
|
||||
for _, iface := range ifaces {
|
||||
ifNames = append(ifNames, iface.Name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,9 +33,17 @@ func setupNetworks(cfg *config.Config) {
|
||||
log := log.With().Str("network", network.Name).Logger()
|
||||
log.Info().Msg("setting up network")
|
||||
|
||||
unassigned := filter(ifaces, func(iface NameAliases) bool {
|
||||
return !assigned[iface.Name]
|
||||
})
|
||||
// compute available names
|
||||
if len(assigned) != 0 {
|
||||
newNames := make([]string, 0, len(ifNames))
|
||||
for _, n := range ifNames {
|
||||
if assigned[n] {
|
||||
continue
|
||||
}
|
||||
newNames = append(newNames, n)
|
||||
}
|
||||
ifNames = newNames
|
||||
}
|
||||
|
||||
// assign envvars
|
||||
envvars := make([]string, 0, 1+len(network.Interfaces))
|
||||
@ -62,13 +53,13 @@ func setupNetworks(cfg *config.Config) {
|
||||
envvar := new(strings.Builder)
|
||||
envvar.WriteString(match.Var)
|
||||
envvar.WriteByte('=')
|
||||
for i, m := range regexpSelectN(match.N, match.Regexps, unassigned) {
|
||||
assigned[m] = true
|
||||
|
||||
for i, m := range regexpSelectN(match.N, match.Regexps, ifNames) {
|
||||
if i != 0 {
|
||||
envvar.WriteByte(' ')
|
||||
}
|
||||
envvar.WriteString(m)
|
||||
assigned[m] = true
|
||||
}
|
||||
|
||||
envvars = append(envvars, envvar.String())
|
||||
|
45
regexp.go
45
regexp.go
@ -6,36 +6,13 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type NameAliases struct {
|
||||
Name string
|
||||
Aliases []string
|
||||
}
|
||||
|
||||
func nameAlias(name string) NameAliases {
|
||||
return NameAliases{Name: name, Aliases: []string{name}}
|
||||
}
|
||||
func nameAliases(name string, aliases ...string) NameAliases {
|
||||
na := NameAliases{Name: name, Aliases: make([]string, 0, len(aliases)+1)}
|
||||
na.Aliases = append(na.Aliases, name)
|
||||
for _, alias := range aliases {
|
||||
na.AddAlias(alias)
|
||||
func regexpSelectN(n int, regexps []string, names []string) (matches []string) {
|
||||
if n <= 0 {
|
||||
matches = make([]string, 0)
|
||||
} else {
|
||||
matches = make([]string, 0, n)
|
||||
}
|
||||
|
||||
return na
|
||||
}
|
||||
func (na *NameAliases) AddAlias(alias string) {
|
||||
if alias == "" {
|
||||
return
|
||||
}
|
||||
if contains(na.Aliases, func(s string) bool { return s == alias }) {
|
||||
return
|
||||
}
|
||||
na.Aliases = append(na.Aliases, alias)
|
||||
}
|
||||
|
||||
func regexpSelectN(n int, regexps []string, nameAliases []NameAliases) (matches []string) {
|
||||
matches = make([]string, 0)
|
||||
|
||||
res := make([]*regexp.Regexp, 0, len(regexps))
|
||||
for _, reStr := range regexps {
|
||||
re, err := regexp.Compile(reStr)
|
||||
@ -46,17 +23,15 @@ func regexpSelectN(n int, regexps []string, nameAliases []NameAliases) (matches
|
||||
res = append(res, re)
|
||||
}
|
||||
|
||||
nameAliasesLoop:
|
||||
for _, item := range nameAliases {
|
||||
namesLoop:
|
||||
for _, name := range names {
|
||||
if len(matches) == n {
|
||||
break
|
||||
}
|
||||
for _, re := range res {
|
||||
for _, alias := range item.Aliases {
|
||||
if re.MatchString(alias) {
|
||||
matches = append(matches, item.Name)
|
||||
continue nameAliasesLoop
|
||||
}
|
||||
if re.MatchString(name) {
|
||||
matches = append(matches, name)
|
||||
continue namesLoop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,7 @@ if ! [ -e $disk2 ]; then
|
||||
qemu-img create -f qcow2 $disk2 10G
|
||||
fi
|
||||
|
||||
exec qemu-system-x86_64 -pidfile qemu.pid \
|
||||
-kernel test-kernel -initrd test-initrd.cpio \
|
||||
exec qemu-system-x86_64 -pidfile qemu.pid -kernel test-kernel -initrd test-initrd.cpio \
|
||||
-smp 2 -m 2048 \
|
||||
-netdev bridge,br=novit,id=eth0 -device virtio-net-pci,netdev=eth0 \
|
||||
-drive file=$disk1,if=virtio \
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func Example_output() {
|
||||
func ExampleOutput() {
|
||||
done := false
|
||||
defer func() { done = true }()
|
||||
go func() {
|
||||
|
@ -1,53 +1,53 @@
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct Config {
|
||||
pub anti_phishing_code: String,
|
||||
anti_phishing_code: String,
|
||||
|
||||
pub keymap: Option<String>,
|
||||
pub modules: Option<String>,
|
||||
keymap: Option<String>,
|
||||
modules: String,
|
||||
|
||||
pub auths: Vec<Auth>,
|
||||
auths: Vec<Auth>,
|
||||
|
||||
pub networks: Vec<Network>,
|
||||
networks: Vec<Network>,
|
||||
|
||||
#[serde(default)]
|
||||
pub ssh: SSHServer,
|
||||
ssh: SSHServer,
|
||||
|
||||
#[serde(default)]
|
||||
pub pre_lvm_crypt: Vec<CryptDev>,
|
||||
pre_lvm_crypt: Vec<CryptDev>,
|
||||
#[serde(default)]
|
||||
pub lvm: Vec<LvmVG>,
|
||||
lvm: Vec<LvmVG>,
|
||||
#[serde(default)]
|
||||
pub crypt: Vec<CryptDev>,
|
||||
crypt: Vec<CryptDev>,
|
||||
|
||||
pub bootstrap: Bootstrap,
|
||||
bootstrap: Bootstrap,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct Auth {
|
||||
pub name: String,
|
||||
name: String,
|
||||
#[serde(rename = "sshKey")]
|
||||
pub ssh_key: String,
|
||||
pub password: String,
|
||||
ssh_key: String,
|
||||
password: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct Network {
|
||||
pub name: String,
|
||||
pub interfaces: Vec<NetworkInterface>,
|
||||
pub script: String,
|
||||
name: String,
|
||||
interfaces: Vec<NetworkInterface>,
|
||||
script: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct NetworkInterface {
|
||||
pub var: String,
|
||||
pub n: usize,
|
||||
pub n: i16,
|
||||
pub regexps: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct SSHServer {
|
||||
pub listen: String,
|
||||
pub keys: SSHKeys,
|
||||
listen: String,
|
||||
keys: SSHKeys,
|
||||
}
|
||||
impl Default for SSHServer {
|
||||
fn default() -> Self {
|
||||
@ -60,31 +60,18 @@ impl Default for SSHServer {
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct SSHKeys {
|
||||
dsa: Option<String>,
|
||||
rsa: Option<String>,
|
||||
ecdsa: Option<String>,
|
||||
ed25519: Option<String>,
|
||||
}
|
||||
impl SSHKeys {
|
||||
pub fn iter(&self) -> impl Iterator<Item = &str> {
|
||||
[
|
||||
self.dsa.iter(),
|
||||
self.rsa.iter(),
|
||||
self.ecdsa.iter(),
|
||||
self.ed25519.iter(),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(String::as_str)
|
||||
}
|
||||
dsa: String,
|
||||
rsa: String,
|
||||
ecdsa: String,
|
||||
ed25519: String,
|
||||
}
|
||||
impl Default for SSHKeys {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
dsa: Some("id_dsa".to_string()),
|
||||
rsa: Some("id_rsa".to_string()),
|
||||
ecdsa: Some("id_ecdsa".to_string()),
|
||||
ed25519: Some("id_ed25519".to_string()),
|
||||
dsa: "id_dsa".to_string(),
|
||||
rsa: "id_rsa".to_string(),
|
||||
ecdsa: "id_ecdsa".to_string(),
|
||||
ed25519: "id_ed25519".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
pub mod bootstrap;
|
||||
pub mod connect_boot;
|
||||
pub mod init;
|
||||
pub mod version;
|
213
src/cmd/init.rs
213
src/cmd/init.rs
@ -1,213 +0,0 @@
|
||||
use eyre::{format_err, Result};
|
||||
use log::{error, info, warn};
|
||||
use std::os::unix::fs::symlink;
|
||||
use std::{fs, io, process::Command};
|
||||
|
||||
use crate::{bootstrap::config::Config, cmd::version::version_string};
|
||||
|
||||
mod networks;
|
||||
mod sshd;
|
||||
|
||||
pub fn run() -> Result<()> {
|
||||
if std::process::id() != 1 {
|
||||
return Err(format_err!(
|
||||
"init must run as PID 1, not {}",
|
||||
std::process::id()
|
||||
));
|
||||
}
|
||||
|
||||
info!("Welcome to {}", version_string());
|
||||
|
||||
let uname = nix::sys::utsname::uname()?;
|
||||
let kernel_version = uname.release().to_string_lossy();
|
||||
info!("Linux version {kernel_version}");
|
||||
|
||||
let cfg: Config = retry(|| {
|
||||
let cfg = fs::read("config.yaml").map_err(|e| format_err!("failed to read config: {e}"))?;
|
||||
serde_yaml::from_slice(cfg.as_slice())
|
||||
.map_err(|e| format_err!("failed to parse config: {e}"))
|
||||
});
|
||||
|
||||
info!("config loaded");
|
||||
info!("anti-phishing-code: {}", cfg.anti_phishing_code);
|
||||
|
||||
// mount basic filesystems
|
||||
mount("none", "/proc", "proc", None);
|
||||
mount("none", "/sys", "sysfs", None);
|
||||
mount("none", "/dev", "devtmpfs", None);
|
||||
mount("none", "/dev/pts", "devpts", Some("gid=5,mode=620"));
|
||||
|
||||
// mount modules
|
||||
if let Some(ref modules) = cfg.modules {
|
||||
mount(modules, "/modules", "squashfs", None);
|
||||
|
||||
fs::create_dir_all("/lib/modules")?;
|
||||
let modules_path = &format!("/modules/lib/modules/{kernel_version}");
|
||||
|
||||
if !fs::exists(modules_path)? {
|
||||
let e = format_err!("invalid modules package: {modules_path} should exist");
|
||||
error!("{e}");
|
||||
return Err(e);
|
||||
}
|
||||
|
||||
symlink(modules_path, format!("/lib/modules/{kernel_version}"))?;
|
||||
} else {
|
||||
warn!("modules NOT mounted (not configured)");
|
||||
}
|
||||
|
||||
// init devices
|
||||
info!("initializing devices");
|
||||
start_daemon("udevd", &[]);
|
||||
|
||||
exec("udevadm", &["trigger", "-c", "add", "-t", "devices"]);
|
||||
exec("udevadm", &["trigger", "-c", "add", "-t", "subsystems"]);
|
||||
exec("udevadm", &["settle"]);
|
||||
|
||||
// networks
|
||||
networks::setup(&cfg)?;
|
||||
|
||||
// Wireguard VPN
|
||||
// TODO startVPN()
|
||||
|
||||
// SSH service
|
||||
sshd::start(&cfg);
|
||||
|
||||
// dmcrypt blockdevs
|
||||
// TODO setupCrypt(cfg.PreLVMCrypt, map[string]string{});
|
||||
|
||||
// LVM
|
||||
// TODO setupLVM(cfg);
|
||||
|
||||
// bootstrap the system
|
||||
// TODO bootstrap(cfg);
|
||||
|
||||
// finalize
|
||||
// TODO finalizeBoot();
|
||||
|
||||
exec_shell();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn mount(src: &str, dst: &str, fstype: &str, opts: Option<&str>) {
|
||||
if let Err(e) = fs::create_dir_all(dst) {
|
||||
error!("failed to create dir {dst}: {e}");
|
||||
}
|
||||
|
||||
let mut args = vec![src, dst, "-t", fstype];
|
||||
if let Some(opts) = opts {
|
||||
args.extend(["-o", opts]);
|
||||
}
|
||||
exec("mount", &args);
|
||||
}
|
||||
|
||||
fn start_daemon(prog: &str, args: &[&str]) {
|
||||
let cmd_str = sh_str(prog, args);
|
||||
retry_or_ignore(|| {
|
||||
info!("starting as daemon: {cmd_str}");
|
||||
let mut cmd = Command::new(prog);
|
||||
cmd.args(args);
|
||||
cmd.spawn()?;
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
fn exec(prog: &str, args: &[&str]) {
|
||||
let cmd_str = sh_str(prog, args);
|
||||
retry_or_ignore(|| {
|
||||
info!("# {cmd_str}");
|
||||
let mut cmd = Command::new(prog);
|
||||
cmd.args(args);
|
||||
let s = cmd.status()?;
|
||||
if s.success() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format_err!("command failed: {s}"))
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn retry_or_ignore(mut action: impl FnMut() -> Result<()>) {
|
||||
loop {
|
||||
match action() {
|
||||
Ok(_) => return,
|
||||
Err(e) => {
|
||||
error!("{e}");
|
||||
|
||||
loop {
|
||||
eprint!("[r]etry, [i]gnore, or [s]hell? ");
|
||||
|
||||
let mut line = String::new();
|
||||
io::stdin().read_line(&mut line).unwrap();
|
||||
|
||||
match line.trim() {
|
||||
"r" => break,
|
||||
"i" => return,
|
||||
"s" => {
|
||||
exec_shell();
|
||||
break;
|
||||
}
|
||||
v => {
|
||||
eprintln!("invalid choice: {v:?}");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn retry<T>(mut action: impl FnMut() -> Result<T>) -> T {
|
||||
loop {
|
||||
match action() {
|
||||
Ok(v) => return v,
|
||||
Err(e) => {
|
||||
error!("{e}");
|
||||
|
||||
loop {
|
||||
eprint!("[r]etry, or [s]hell? ");
|
||||
|
||||
let mut line = String::new();
|
||||
io::stdin().read_line(&mut line).unwrap();
|
||||
|
||||
match line.trim() {
|
||||
"r" => break,
|
||||
"s" => {
|
||||
exec_shell();
|
||||
break;
|
||||
}
|
||||
v => {
|
||||
eprintln!("invalid choice: {v:?}");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn exec_shell() {
|
||||
let mut child = match Command::new("ash").spawn() {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
error!("failed to exec shell: {e}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let _ = child.wait();
|
||||
}
|
||||
|
||||
fn sh_str(prog: &str, args: &[&str]) -> String {
|
||||
use std::borrow::Cow;
|
||||
|
||||
let mut buf = String::new();
|
||||
|
||||
buf.push_str(&shell_escape::escape(Cow::Borrowed(prog)));
|
||||
|
||||
for &arg in args {
|
||||
buf.push(' ');
|
||||
buf.push_str(&shell_escape::escape(Cow::Borrowed(arg)));
|
||||
}
|
||||
|
||||
buf
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
use itertools::Itertools;
|
||||
use log::{info, warn};
|
||||
use std::collections::BTreeSet as Set;
|
||||
use std::process::Command;
|
||||
|
||||
use super::{format_err, retry_or_ignore, Config, Result};
|
||||
use crate::{
|
||||
udev,
|
||||
utils::{select_n_by_regex, NameAliases},
|
||||
};
|
||||
|
||||
pub fn setup(cfg: &Config) -> Result<()> {
|
||||
if cfg.networks.is_empty() {
|
||||
warn!("no networks configured");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let mut assigned: Set<String> = Set::new();
|
||||
|
||||
for net in &cfg.networks {
|
||||
retry_or_ignore(|| {
|
||||
info!("setting up network {}", net.name);
|
||||
|
||||
let netdevs = get_interfaces()?
|
||||
.filter(|dev| !assigned.contains(dev.name()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
for dev in &netdevs {
|
||||
info!(
|
||||
"- available network device: {}, aliases [{}]",
|
||||
dev.name(),
|
||||
dev.aliases().join(", ")
|
||||
);
|
||||
}
|
||||
|
||||
let mut cmd = Command::new("ash");
|
||||
cmd.arg("-c");
|
||||
cmd.arg(&net.script);
|
||||
|
||||
let mut selected = Vec::new();
|
||||
|
||||
for iface in &net.interfaces {
|
||||
let var = &iface.var;
|
||||
|
||||
let netdevs = netdevs.iter().filter(|na| !assigned.contains(na.name()));
|
||||
let if_names = select_n_by_regex(iface.n, &iface.regexps, netdevs);
|
||||
|
||||
if if_names.is_empty() {
|
||||
return Err(format_err!("- no interface match for {var:?}"));
|
||||
}
|
||||
|
||||
let value = if_names.join(" ");
|
||||
info!("- {var}={value}");
|
||||
cmd.env(var, value);
|
||||
|
||||
selected.extend(if_names);
|
||||
}
|
||||
|
||||
info!("- running script");
|
||||
let status = cmd.status()?;
|
||||
if !status.success() {
|
||||
return Err(format_err!("setup script failed: {status}"));
|
||||
}
|
||||
|
||||
assigned.extend(selected);
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_interfaces() -> Result<impl Iterator<Item = NameAliases>> {
|
||||
Ok(udev::get_devices("net")?.into_iter().map(|dev| {
|
||||
let mut na = NameAliases::new(dev.sysname().to_string());
|
||||
|
||||
for (property, value) in dev.properties() {
|
||||
if [
|
||||
"INTERFACE",
|
||||
"ID_NET_NAME",
|
||||
"ID_NET_NAME_PATH",
|
||||
"ID_NET_NAME_MAC",
|
||||
"ID_NET_NAME_SLOT",
|
||||
]
|
||||
.contains(&property)
|
||||
{
|
||||
na.push(value.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
na
|
||||
}))
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
use log::{info, warn};
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::net;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::thread;
|
||||
|
||||
use super::{retry_or_ignore, Config};
|
||||
|
||||
pub fn start(cfg: &Config) {
|
||||
retry_or_ignore(|| {
|
||||
info!("ssh: writing authorized keys");
|
||||
|
||||
let ssh_dir = "/root/.ssh";
|
||||
let authorized_keys = format!("{ssh_dir}/authorized_keys");
|
||||
|
||||
fs::create_dir_all(ssh_dir)?;
|
||||
fs::set_permissions(ssh_dir, fs::Permissions::from_mode(0o700))?;
|
||||
|
||||
let mut ak = Vec::new();
|
||||
|
||||
for auth in &cfg.auths {
|
||||
writeln!(ak, "{} {}", auth.ssh_key, auth.name)?;
|
||||
}
|
||||
|
||||
fs::write(authorized_keys, ak)?;
|
||||
Ok(())
|
||||
});
|
||||
|
||||
retry_or_ignore(|| {
|
||||
let mut sshd_args = Vec::new();
|
||||
|
||||
sshd_args.extend(["-i", "-E", "/var/log/sshd.log"]);
|
||||
|
||||
for key_path in cfg.ssh.keys.iter() {
|
||||
if !fs::exists(key_path).is_ok_and(|b| b) {
|
||||
info!("ssh: host key not found (ignored): {key_path}");
|
||||
continue;
|
||||
}
|
||||
sshd_args.extend(["-h", key_path]);
|
||||
}
|
||||
|
||||
let sshd_args = sshd_args.into_iter().map(String::from).collect();
|
||||
|
||||
// don't pre-start sshd as it should rarely be useful at this stage, use inetd-style.
|
||||
let listen_addr = cfg.ssh.listen.clone();
|
||||
info!("ssh: starting listener on {listen_addr}");
|
||||
|
||||
let listener = net::TcpListener::bind(listen_addr)?;
|
||||
|
||||
thread::spawn(move || handle_ssh_connections(listener, sshd_args));
|
||||
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
fn handle_ssh_connections(listener: net::TcpListener, sshd_args: Vec<String>) {
|
||||
loop {
|
||||
let Ok((stream, remote)) = listener.accept() else {
|
||||
warn!("ssh: listener stopped");
|
||||
break;
|
||||
};
|
||||
|
||||
info!("ssh: new connection from {remote}");
|
||||
|
||||
use std::os::unix::io::{AsRawFd, FromRawFd};
|
||||
let fd = stream.as_raw_fd();
|
||||
|
||||
let mut cmd = Command::new("/usr/sbin/sshd");
|
||||
cmd.args(&sshd_args);
|
||||
|
||||
cmd.stdin(unsafe { Stdio::from_raw_fd(fd) });
|
||||
cmd.stdout(unsafe { Stdio::from_raw_fd(fd) });
|
||||
cmd.stderr(Stdio::null());
|
||||
|
||||
if let Err(e) = cmd.spawn() {
|
||||
warn!("ssh: failed to start server: {e}");
|
||||
};
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
pub fn run() {
|
||||
println!("{}", version_string());
|
||||
}
|
||||
|
||||
pub fn version_string() -> String {
|
||||
format!(
|
||||
"Direktil {} v{} (git commit {})",
|
||||
env!("CARGO_PKG_NAME"),
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
env!("GIT_COMMIT")
|
||||
)
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
pub mod bootstrap;
|
||||
pub mod cmd;
|
||||
pub mod lsblk;
|
||||
pub mod lvm;
|
||||
pub mod udev;
|
||||
pub mod utils;
|
64
src/main.rs
64
src/main.rs
@ -1,33 +1,51 @@
|
||||
use eyre::Result;
|
||||
mod bootstrap;
|
||||
mod lsblk;
|
||||
mod lvm;
|
||||
|
||||
use anyhow::format_err;
|
||||
use log::error;
|
||||
use std::env;
|
||||
use std::io::{self, Read, Write};
|
||||
use std::process::exit;
|
||||
use std::{env, fs};
|
||||
|
||||
use init::cmd;
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
if let None = env::var_os("RUST_LOG") {
|
||||
env::set_var("RUST_LOG", "info");
|
||||
}
|
||||
env_logger::init();
|
||||
|
||||
fn main() -> Result<()> {
|
||||
env_logger::builder()
|
||||
.format_timestamp_millis()
|
||||
.format_target(false)
|
||||
.filter_level(log::LevelFilter::Info)
|
||||
.write_style(env_logger::WriteStyle::Always)
|
||||
.init();
|
||||
|
||||
unsafe {
|
||||
env::set_var("PATH", "/bin:/sbin:/usr/bin:/usr/sbin");
|
||||
if let Some(arg) = env::args().into_iter().nth(1) {
|
||||
match arg.as_str() {
|
||||
"hello" => println!("hello"),
|
||||
_ => {
|
||||
error!("invalid arg: {arg}");
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
exit(0);
|
||||
}
|
||||
|
||||
let call_name = env::args().next().unwrap_or("init".into());
|
||||
let call_name = (call_name.rsplit_once('/').map(|(_, n)| n)).unwrap_or(call_name.as_str());
|
||||
let cfg = fs::read("config.yaml").map_err(|e| format_err!("failed to read config: {e}"))?;
|
||||
|
||||
match call_name {
|
||||
"init" => cmd::init::run()?,
|
||||
"init-version" => cmd::version::run(),
|
||||
_ => {
|
||||
error!("invalid call name: {call_name:?}");
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
let cfg: bootstrap::config::Config = serde_yaml::from_slice(cfg.as_slice())
|
||||
.map_err(|e| format_err!("failed to parse config: {e}"))?;
|
||||
|
||||
serde_yaml::to_writer(io::stdout(), &cfg)?;
|
||||
|
||||
for pv in lvm::pvs().unwrap() {
|
||||
println!("pv: {pv:?}");
|
||||
}
|
||||
for vg in lvm::vgs().unwrap() {
|
||||
println!("vg: {vg:?}");
|
||||
}
|
||||
for lv in lvm::lvs().unwrap() {
|
||||
println!("lv: {lv:?}");
|
||||
}
|
||||
|
||||
println!("lsblk: {:?}", lsblk::report());
|
||||
|
||||
// TODO
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
65
src/udev.rs
65
src/udev.rs
@ -1,65 +0,0 @@
|
||||
use eyre::Result;
|
||||
use log::error;
|
||||
|
||||
pub struct Device {
|
||||
sysname: String,
|
||||
output: String,
|
||||
}
|
||||
|
||||
impl Device {
|
||||
pub fn sysname(&self) -> &str {
|
||||
self.sysname.as_str()
|
||||
}
|
||||
|
||||
pub fn properties(&self) -> impl Iterator<Item = (&str, &str)> {
|
||||
self.output
|
||||
.lines()
|
||||
.filter_map(|line| line.strip_prefix("E: ")?.split_once('='))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_devices(class: &str) -> Result<Vec<Device>> {
|
||||
let mut devices = Vec::new();
|
||||
|
||||
// none of libudev and udev crates were able to list network devices.
|
||||
// falling back to manual sysfs scanning :(
|
||||
//
|
||||
// Even when given a syspath,
|
||||
// - udev crate failed to see all properties;
|
||||
// - libudev crate segfaulted on the second property (SYSNUM ok, then segfault).
|
||||
// falling back to parsing udevadm output :(
|
||||
//
|
||||
// The best fix would be to check what's wrong with udev crate.
|
||||
|
||||
let entries = std::fs::read_dir(format!("/sys/class/{class}"))?;
|
||||
for entry in entries {
|
||||
let Ok(entry) = entry else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let path = entry.path();
|
||||
let path = path.to_string_lossy();
|
||||
|
||||
let output = std::process::Command::new("udevadm")
|
||||
.args(&["info", &format!("--path={path}")])
|
||||
.stderr(std::process::Stdio::piped())
|
||||
.output()?;
|
||||
|
||||
if !output.status.success() {
|
||||
error!("udevadm fail for {path}");
|
||||
continue;
|
||||
}
|
||||
|
||||
let output = String::from_utf8_lossy(&output.stdout);
|
||||
|
||||
let name = entry.file_name();
|
||||
let dev = Device {
|
||||
sysname: name.to_string_lossy().to_string(),
|
||||
output: output.into_owned(),
|
||||
};
|
||||
|
||||
devices.push(dev);
|
||||
}
|
||||
|
||||
Ok(devices)
|
||||
}
|
61
src/utils.rs
61
src/utils.rs
@ -1,61 +0,0 @@
|
||||
use log::error;
|
||||
use std::collections::BTreeSet as Set;
|
||||
|
||||
pub struct NameAliases {
|
||||
name: String,
|
||||
aliases: Set<String>,
|
||||
}
|
||||
|
||||
impl NameAliases {
|
||||
pub fn new(name: String) -> Self {
|
||||
Self {
|
||||
name,
|
||||
aliases: Set::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &str {
|
||||
self.name.as_str()
|
||||
}
|
||||
pub fn aliases(&self) -> impl Iterator<Item = &str> {
|
||||
self.aliases.iter().map(|s| s.as_str())
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> impl Iterator<Item = &str> {
|
||||
std::iter::once(self.name()).chain(self.aliases())
|
||||
}
|
||||
|
||||
pub fn push(&mut self, alias: String) {
|
||||
if self.name == alias {
|
||||
return;
|
||||
}
|
||||
self.aliases.insert(alias);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn select_n_by_regex<'t>(
|
||||
n: usize,
|
||||
regexs: &Vec<String>,
|
||||
nas: impl Iterator<Item = &'t NameAliases>,
|
||||
) -> Vec<String> {
|
||||
// compile regexs
|
||||
let regexs: Vec<_> = (regexs.iter())
|
||||
.filter_map(|re| {
|
||||
regex::Regex::new(re)
|
||||
.inspect_err(|e| error!("invalid regex ignored: {re:?}: {e}"))
|
||||
.ok()
|
||||
})
|
||||
.collect();
|
||||
|
||||
let matching = |name| regexs.iter().any(|re| re.is_match(name));
|
||||
|
||||
let nas = nas
|
||||
.filter(|na| na.iter().any(matching))
|
||||
.map(|na| na.name().to_string());
|
||||
|
||||
if n <= 0 {
|
||||
nas.collect()
|
||||
} else {
|
||||
nas.take(n).collect()
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAaAAAABNlY2RzYS
|
||||
1zaGEyLW5pc3RwMjU2AAAACG5pc3RwMjU2AAAAQQSlevO48OA0/yB8zTP1naijVU3wsB0c
|
||||
4s6Jc/8y7YwNq51/SlieeGeRFcCSke5Z67rNX2JFiv+tsGQB6TczZm/6AAAAqDU5b2c1OW
|
||||
9nAAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKV687jw4DT/IHzN
|
||||
M/WdqKNVTfCwHRzizolz/zLtjA2rnX9KWJ54Z5EVwJKR7lnrus1fYkWK/62wZAHpNzNmb/
|
||||
oAAAAhANenGXlP1ZPgcyb/+O57MbpGDOZS4e7UNiyvkD8I3hNnAAAACW53cmtAbndyawEC
|
||||
AwQFBg==
|
||||
-----END OPENSSH PRIVATE KEY-----
|
@ -1,7 +0,0 @@
|
||||
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||
QyNTUxOQAAACCCMX0zm3Fi7vXWevHuJvzU30l5F06NAC2qloUewVSoDQAAAJDnq/y456v8
|
||||
uAAAAAtzc2gtZWQyNTUxOQAAACCCMX0zm3Fi7vXWevHuJvzU30l5F06NAC2qloUewVSoDQ
|
||||
AAAEDXYq507MsjSN34Qw87guf3d5D4Dt2IrF788CeBcYSNe4IxfTObcWLu9dZ68e4m/NTf
|
||||
SXkXTo0ALaqWhR7BVKgNAAAACW53cmtAbndyawECAwQ=
|
||||
-----END OPENSSH PRIVATE KEY-----
|
1
test-initrd/id_rsa.pub
Normal file
1
test-initrd/id_rsa.pub
Normal file
@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDLo+mv+0GJViwFiK14bAw8j4HYFIGf4I/fpmIqzHohf70TT+cYqAKSHBYV+uYjNLYQib6Ii/thPexeypw73pq7Z7CHvubnFQUiuqJ7lzXeV4146f5eHL76/TvTmKthS4FVFta6SlCOE6unR6q8HM52VSijavtoX3musxugCwhaHmBNOdUJcNIRCIey8QaOztPK05dDrOZhMQJgSST/BRaNrtY0/xRmJo+5TbQeyjyDuQdK2EoS51QMWzsT/LH6drQBgKd8RRHqjEhscfaV2CmdfuVO/liEdW82epMgFCGYtMetP/rs3bPkC90ULxPZSytaz7d5ux1dvSgrPHzX4306k/GP3d6EvOedy4IKAB53J7lebvrRI5pTVPZvd/RsSGGxUIwjf2Y8TF5nbC2d2D5Oauqfevn29veIRh8mq+AsJMnkvUFwVRN+6WDsZ+F82+AGaCKJFNQLYbRKtXW0zzi+wTsnLJNwlpevRf61SCxehSqeVfnc4TDsAGyRa9nSbR8= test@novit.io
|
1
test-initrd/init
Symbolic link
1
test-initrd/init
Symbolic link
@ -0,0 +1 @@
|
||||
../dist/init
|
Binary file not shown.
BIN
test-kernel
BIN
test-kernel
Binary file not shown.
Reference in New Issue
Block a user