Compare commits
3 Commits
354bdce5ab
...
f8a8344049
Author | SHA1 | Date | |
---|---|---|---|
|
f8a8344049 | ||
|
bad1cf3c23 | ||
|
1a84bb4286 |
@ -1,32 +0,0 @@
|
||||
image: golang:1.10.3
|
||||
|
||||
variables:
|
||||
REPO_NAME: novit.nc/direktil/inits
|
||||
|
||||
before_script:
|
||||
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
|
||||
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
|
||||
- cd $GOPATH/src/$REPO_NAME
|
||||
|
||||
stages:
|
||||
- test
|
||||
- build
|
||||
|
||||
format:
|
||||
stage: test
|
||||
script:
|
||||
- go fmt ./...
|
||||
- go vet ./...
|
||||
- go test -race ./...
|
||||
|
||||
compile:
|
||||
stage: build
|
||||
script:
|
||||
- go build ./cmd/dkl-apply-config
|
||||
- go build ./cmd/dkl-system-init
|
||||
- CGO_ENABLED=0 go build ./cmd/dkl-initrd-init
|
||||
artifacts:
|
||||
paths:
|
||||
- dkl-apply-config
|
||||
- dkl-system-init
|
||||
- dkl-initrd-init
|
@ -5,15 +5,17 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"novit.nc/direktil/inits/pkg/cmd/applyconfig"
|
||||
cmddynlay "novit.nc/direktil/inits/pkg/cmd/dynlay"
|
||||
cmdinit "novit.nc/direktil/inits/pkg/cmd/init"
|
||||
"novit.tech/direktil/inits/pkg/cmd/applyconfig"
|
||||
cmddynlay "novit.tech/direktil/inits/pkg/cmd/dynlay"
|
||||
cmdinit "novit.tech/direktil/inits/pkg/cmd/init"
|
||||
cmdlogger "novit.tech/direktil/inits/pkg/cmd/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
root := &cobra.Command{}
|
||||
|
||||
root.AddCommand(cmdinit.Command())
|
||||
root.AddCommand(cmdlogger.Command())
|
||||
root.AddCommand(cmddynlay.Command())
|
||||
root.AddCommand(applyconfig.Command())
|
||||
|
||||
|
23
go.mod
23
go.mod
@ -1,22 +1,27 @@
|
||||
module novit.nc/direktil/inits
|
||||
module novit.tech/direktil/inits
|
||||
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/antage/mntent v0.0.0-20141129103236-834970000c6c
|
||||
github.com/fsnotify/fsnotify v1.6.0
|
||||
github.com/fsnotify/fsnotify v1.7.0
|
||||
github.com/go-ping/ping v1.1.0
|
||||
github.com/spf13/cobra v1.6.1
|
||||
novit.nc/direktil/pkg v0.0.0-20220221171542-fd3ce3a1491b
|
||||
github.com/rs/zerolog v1.31.0
|
||||
github.com/spf13/cobra v1.8.0
|
||||
novit.tech/direktil/pkg v0.0.0-20240120131645-39b9b401ba38
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/google/uuid v1.5.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/ulikunitz/xz v0.5.10 // indirect
|
||||
golang.org/x/net v0.4.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.3.0 // indirect
|
||||
github.com/ulikunitz/xz v0.5.11 // indirect
|
||||
golang.org/x/net v0.20.0 // indirect
|
||||
golang.org/x/sync v0.6.0 // indirect
|
||||
golang.org/x/sys v0.16.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
|
85
go.sum
85
go.sum
@ -1,14 +1,16 @@
|
||||
github.com/antage/mntent v0.0.0-20141129103236-834970000c6c h1:6g5LfUYqDR1rEL54hKdK7edwAp2R4baYmtDpJgm6+5Q=
|
||||
github.com/antage/mntent v0.0.0-20141129103236-834970000c6c/go.mod h1:AsQhRqephGS4znB7Z793C63GgcW2I6xUsInepL9EOdE=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
|
||||
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
|
||||
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/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/go-ping/ping v1.1.0 h1:3MCGhVX4fyEUuhsfwPrsEdQw6xspHkv5zHsiSoDFZYw=
|
||||
github.com/go-ping/ping v1.1.0/go.mod h1:xIFjORFzTxqIV/tDVGO4eDy/bLuSyawEeojSm3GfRGk=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
|
||||
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
@ -16,34 +18,77 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
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-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=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
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/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
|
||||
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
|
||||
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
|
||||
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
|
||||
github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8=
|
||||
github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
|
||||
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/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
||||
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=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
||||
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
|
||||
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
||||
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.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-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
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.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-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
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/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/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
|
||||
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=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
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=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
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/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
novit.nc/direktil/pkg v0.0.0-20220221171542-fd3ce3a1491b h1:4KIhYb83Qwe6I0BLr0bnRuFvWto7hfuBEGsnQ6HVG3U=
|
||||
novit.nc/direktil/pkg v0.0.0-20220221171542-fd3ce3a1491b/go.mod h1:zwTVO6U0tXFEaga73megQIBK7yVIKZJVePaIh/UtdfU=
|
||||
novit.tech/direktil/pkg v0.0.0-20240120131645-39b9b401ba38 h1:1Q1X91BwE1g1NFqeA9sJh7G9OS4D75QTWHNnzXZgY70=
|
||||
novit.tech/direktil/pkg v0.0.0-20240120131645-39b9b401ba38/go.mod h1:zjezU6tELE880oYHs/WAauGBupKIEQQ7KqWTB69RW10=
|
||||
|
@ -1,6 +1,6 @@
|
||||
modd.conf {}
|
||||
|
||||
**/*.go layer/**/* test-vm update-test-data {
|
||||
**/*.go go.mod go.sum layer/**/* test-vm update-test-data {
|
||||
prep: go test ./...
|
||||
prep: mkdir -p dist
|
||||
prep: CGO_ENABLED=0 go build -o dist/ -trimpath ./...
|
||||
|
@ -1,94 +0,0 @@
|
||||
package apply
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"novit.nc/direktil/inits/pkg/vars"
|
||||
"novit.nc/direktil/pkg/config"
|
||||
)
|
||||
|
||||
const (
|
||||
authorizedKeysPath = "/root/.ssh/authorized_keys"
|
||||
)
|
||||
|
||||
// Files writes the files from the given config
|
||||
func Files(cfg *config.Config, filters ...string) (err error) {
|
||||
accept := func(n string) bool { return true }
|
||||
|
||||
if len(filters) > 0 {
|
||||
accept = func(n string) bool {
|
||||
for _, filter := range filters {
|
||||
if matched, err := filepath.Match(filter, n); err != nil {
|
||||
log.Printf("ERROR: bad filter ignored: %q: %v", filter, err)
|
||||
} else if matched {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if cfg.RootUser.AuthorizedKeys != nil && accept(authorizedKeysPath) {
|
||||
err = writeFile(
|
||||
authorizedKeysPath,
|
||||
[]byte(strings.Join(cfg.RootUser.AuthorizedKeys, "\n")),
|
||||
0600, 0700, cfg,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for _, file := range cfg.Files {
|
||||
if !accept(file.Path) {
|
||||
continue
|
||||
}
|
||||
|
||||
mode := file.Mode
|
||||
if mode == 0 {
|
||||
mode = 0644
|
||||
}
|
||||
|
||||
content := []byte(file.Content)
|
||||
|
||||
err = writeFile(
|
||||
file.Path,
|
||||
content,
|
||||
mode,
|
||||
0755,
|
||||
cfg,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
log.Print("failed to write file ", file.Path, ": ", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func writeFile(path string, content []byte, fileMode, dirMode os.FileMode, cfg *config.Config) (err error) {
|
||||
if err = os.MkdirAll(filepath.Dir(path), dirMode); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
content = vars.Substitute(content, cfg)
|
||||
|
||||
log.Printf("writing %q, mode %04o, %d bytes", path, fileMode, len(content))
|
||||
if err = ioutil.WriteFile(path, content, fileMode); err != nil {
|
||||
err = fmt.Errorf("failed to write %s: %v", path, err)
|
||||
}
|
||||
|
||||
if chmodErr := os.Chmod(path, fileMode); chmodErr != nil {
|
||||
log.Print("- failed chmod: ", chmodErr)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
@ -3,16 +3,17 @@ package applyconfig
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"novit.nc/direktil/inits/pkg/apply"
|
||||
"novit.nc/direktil/pkg/config"
|
||||
|
||||
dlog "novit.nc/direktil/pkg/log"
|
||||
"novit.tech/direktil/pkg/config"
|
||||
"novit.tech/direktil/pkg/config/apply"
|
||||
)
|
||||
|
||||
var (
|
||||
filters []string
|
||||
log = dlog.Get("dkl")
|
||||
filters []string
|
||||
pathPrefix string
|
||||
)
|
||||
|
||||
func Command() (c *cobra.Command) {
|
||||
@ -26,11 +27,14 @@ func Command() (c *cobra.Command) {
|
||||
|
||||
flag := c.Flags()
|
||||
flag.StringArrayVarP(&filters, "filter", "F", []string{}, "glob filter to select files to apply")
|
||||
flag.StringVarP(&pathPrefix, "prefix", "P", "", "path prefix")
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func run(_ *cobra.Command, args []string) {
|
||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
|
||||
|
||||
configPath := args[0]
|
||||
|
||||
var (
|
||||
@ -39,20 +43,19 @@ func run(_ *cobra.Command, args []string) {
|
||||
)
|
||||
|
||||
if configPath == "-" {
|
||||
log.Print("loading config from stdin")
|
||||
log.Info().Str("from", "stdin").Msg("loading config")
|
||||
cfg, err = config.Read(os.Stdin)
|
||||
|
||||
} else {
|
||||
log.Print("loading config from ", configPath)
|
||||
log.Info().Str("from", configPath).Msg("loading config")
|
||||
cfg, err = config.Load(configPath)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Print("failed to load config: ", err)
|
||||
log.Fatal().Err(err).Msg("failed to load config")
|
||||
}
|
||||
|
||||
if err = apply.Files(cfg /*log,*/, filters...); err != nil {
|
||||
log.Taint(dlog.Fatal, "failed to apply files: ", err)
|
||||
os.Exit(1)
|
||||
if err = apply.Files(cfg, pathPrefix, filters...); err != nil {
|
||||
log.Fatal().Err(err).Msg("failed to apply files")
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var urlPrefix = "https://dkl.novit.nc/dist/layers"
|
||||
var urlPrefix = "https://dkl.novit.io/dist/layers"
|
||||
|
||||
func Command() (c *cobra.Command) {
|
||||
c = &cobra.Command{
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
pconfig "novit.nc/direktil/pkg/config"
|
||||
pconfig "novit.tech/direktil/pkg/config"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
pconfig "novit.nc/direktil/pkg/config"
|
||||
pconfig "novit.tech/direktil/pkg/config"
|
||||
)
|
||||
|
||||
func listCommand() (cmd *cobra.Command) {
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"novit.nc/direktil/inits/pkg/sys"
|
||||
"novit.tech/direktil/inits/pkg/sys"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -5,8 +5,9 @@ import (
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"novit.nc/direktil/inits/pkg/apply"
|
||||
"novit.nc/direktil/inits/pkg/sys"
|
||||
"novit.tech/direktil/pkg/config/apply"
|
||||
|
||||
"novit.tech/direktil/inits/pkg/sys"
|
||||
)
|
||||
|
||||
func setupFiles() {
|
||||
@ -54,7 +55,7 @@ func setupFiles() {
|
||||
}
|
||||
|
||||
// - files
|
||||
if err := apply.Files(cfg); err != nil {
|
||||
if err := apply.Files(cfg, ""); err != nil {
|
||||
log.Fatal("FATAL: ", err)
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"novit.nc/direktil/pkg/config"
|
||||
"novit.tech/direktil/pkg/config"
|
||||
|
||||
"novit.nc/direktil/inits/pkg/sys"
|
||||
"novit.nc/direktil/inits/pkg/vars"
|
||||
"novit.tech/direktil/inits/pkg/sys"
|
||||
"novit.tech/direktil/inits/pkg/vars"
|
||||
)
|
||||
|
||||
func setupLVM() {
|
||||
|
@ -11,10 +11,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-ping/ping"
|
||||
"novit.nc/direktil/pkg/config"
|
||||
"novit.tech/direktil/pkg/config"
|
||||
|
||||
"novit.nc/direktil/inits/pkg/sys"
|
||||
"novit.nc/direktil/inits/pkg/vars"
|
||||
"novit.tech/direktil/inits/pkg/sys"
|
||||
"novit.tech/direktil/inits/pkg/vars"
|
||||
)
|
||||
|
||||
var networkStarted = map[string]bool{}
|
||||
|
@ -6,9 +6,9 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
initboot "novit.nc/direktil/inits/pkg/cmd/init/boot"
|
||||
initdefault "novit.nc/direktil/inits/pkg/cmd/init/default"
|
||||
initservice "novit.nc/direktil/inits/pkg/cmd/init/service"
|
||||
initboot "novit.tech/direktil/inits/pkg/cmd/init/boot"
|
||||
initdefault "novit.tech/direktil/inits/pkg/cmd/init/default"
|
||||
initservice "novit.tech/direktil/inits/pkg/cmd/init/service"
|
||||
)
|
||||
|
||||
func Command() (c *cobra.Command) {
|
||||
|
@ -3,12 +3,13 @@ package initservices
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
plog "novit.nc/direktil/pkg/log"
|
||||
plog "novit.tech/direktil/pkg/log"
|
||||
|
||||
cmdlogger "novit.tech/direktil/inits/pkg/cmd/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -58,18 +59,13 @@ func run(c *cobra.Command, args []string) {
|
||||
|
||||
func runService(svcPath string) {
|
||||
svc := filepath.Base(svcPath)
|
||||
|
||||
logger := plog.Get(svc)
|
||||
plog.EnableFiles()
|
||||
|
||||
n := 0
|
||||
for {
|
||||
lastStart := time.Now()
|
||||
|
||||
cmd := exec.Command(svcPath)
|
||||
cmd.Stdout = logger
|
||||
cmd.Stderr = logger
|
||||
err := cmd.Run()
|
||||
err := cmdlogger.Run("", svcPath)
|
||||
|
||||
if time.Since(lastStart) > crashForgiveDelay {
|
||||
n = 0
|
||||
|
49
pkg/cmd/logger/logger.go
Normal file
49
pkg/cmd/logger/logger.go
Normal file
@ -0,0 +1,49 @@
|
||||
package cmdlogger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
plog "novit.tech/direktil/pkg/log"
|
||||
)
|
||||
|
||||
func Command() (c *cobra.Command) {
|
||||
c = &cobra.Command{
|
||||
Use: "logger [--] <command> [args]",
|
||||
Short: "run a command through the dkl logger",
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
Run: run,
|
||||
}
|
||||
c.Flags().StringP("name", "n", "", "log name")
|
||||
return
|
||||
}
|
||||
|
||||
func run(c *cobra.Command, args []string) {
|
||||
logName, _ := c.Flags().GetString("name")
|
||||
err := Run(logName, args[0], args[1:]...)
|
||||
if err == nil {
|
||||
os.Exit(0)
|
||||
} else if exitErr, ok := err.(*exec.ExitError); ok {
|
||||
os.Exit(exitErr.ExitCode())
|
||||
} else {
|
||||
fmt.Fprintln(os.Stderr, "failed to run command: "+err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func Run(logName, command string, args ...string) (err error) {
|
||||
if logName == "" {
|
||||
logName = filepath.Base(command)
|
||||
}
|
||||
|
||||
logger := plog.Get(logName)
|
||||
plog.EnableFiles()
|
||||
|
||||
cmd := exec.Command(command, args...)
|
||||
cmd.Stdout = logger
|
||||
cmd.Stderr = logger
|
||||
return cmd.Run()
|
||||
}
|
@ -4,7 +4,7 @@ import (
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"novit.nc/direktil/pkg/config"
|
||||
"novit.tech/direktil/pkg/config"
|
||||
)
|
||||
|
||||
const cfgPath = "/config.yaml"
|
||||
|
@ -3,7 +3,7 @@ package vars
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"novit.nc/direktil/pkg/config"
|
||||
"novit.tech/direktil/pkg/config"
|
||||
)
|
||||
|
||||
type Var struct {
|
||||
|
Loading…
Reference in New Issue
Block a user