49 Commits

Author SHA1 Message Date
fd019bc407 v0.11.0
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline was successful
ci/woodpecker/tag/gitea Pipeline was successful
ci/woodpecker/release/publish-docs Pipeline is pending
ci/woodpecker/tag/publish-docs Pipeline was successful
2025-11-24 17:51:56 -06:00
febc2680f4 Update docs
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline was successful
2025-11-17 16:46:54 -06:00
caf2397349 Update docs
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline failed
2025-11-17 16:27:33 -06:00
172ca8712e Update docs
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline failed
2025-11-17 16:12:02 -06:00
bda16bcbb5 Update docs
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
2025-11-17 16:08:42 -06:00
b5d069112f Update docs
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline failed
2025-11-17 15:56:28 -06:00
f56393c84c fix small things 2025-11-17 15:55:51 -06:00
55ef8e1733 Update docs
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
2025-11-17 15:43:47 -06:00
075fc16ec9 Update docs
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline failed
2025-11-15 22:54:02 -06:00
0d6a13c1cf Cmd Type script now correctly appends arguments
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline was successful
2025-11-15 17:37:17 -06:00
e57939f858 add files
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
2025-10-21 23:19:00 -05:00
d45b1562fc started refactoring into executors using interfaces 2025-09-07 20:44:48 -05:00
7fe07f86a9 CLI: added exec hosts subcommand list 2025-07-23 22:05:44 -05:00
14c81a00a7 CLI: added exec hosts subcommand list 2025-07-23 22:04:48 -05:00
3eced64453 CLI: Exec subcommand host 2025-07-15 20:24:30 -05:00
c284d928fd CLI: Exec subcommand host 2025-07-15 20:24:06 -05:00
dd9da9452b CLI: Exec subcommand host 2025-07-15 20:23:58 -05:00
11d5121954 update deps 2025-07-14 20:48:53 -05:00
66d622b474 Improved error message for remote version package output 2025-07-09 23:21:46 -05:00
47b2aabd9f Improved error message for remote version package output 2025-07-09 23:20:11 -05:00
b91cf18b04 change file 2025-07-04 10:22:37 -05:00
305b504ca1 tests: beginning of tests using Docker 2025-07-04 09:02:27 -05:00
7be2679b91 change: Commands: host can now be localhost or 127.0.0.1 to run commands locally
All checks were successful
ci/woodpecker/push/go-lint Pipeline was successful
2025-03-21 09:09:56 -05:00
3c6e3ed914 v0.10.2
All checks were successful
ci/woodpecker/push/publish-docs Pipeline was successful
ci/woodpecker/tag/gitea Pipeline was successful
ci/woodpecker/tag/publish-docs Pipeline was successful
ci/woodpecker/release/publish-docs Pipeline was successful
2025-03-19 22:42:49 -05:00
02bc040e2a v0.10.2
All checks were successful
ci/woodpecker/push/go-lint Pipeline was successful
2025-03-19 22:41:18 -05:00
9f1f36215a v0.10.2 2025-03-19 22:40:06 -05:00
ff75f4bbcd feat: add variable support
All checks were successful
ci/woodpecker/push/go-lint Pipeline was successful
2025-03-16 23:43:12 -05:00
5f40713e98 feat: add variable support 2025-03-16 23:42:54 -05:00
cd5f7611a9 notifications: add http service
All checks were successful
ci/woodpecker/push/go-lint Pipeline was successful
2025-03-13 23:35:00 -05:00
b542711078 notifications: add http service 2025-03-13 23:34:37 -05:00
52dbc353e5 change: update go toolchain
All checks were successful
ci/woodpecker/push/go-lint Pipeline was successful
2025-03-12 23:22:52 -05:00
6bef0c3e5b notifications: add http config
All checks were successful
ci/woodpecker/push/go-lint Pipeline was successful
2025-03-12 10:10:45 -05:00
4d705d78fb fix: golang-ci-lint version
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
2025-03-11 22:22:39 -05:00
62d47ecfa7 fix: pipeline errors
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline was successful
ci/woodpecker/tag/gitea Pipeline was successful
ci/woodpecker/tag/publish-docs Pipeline was successful
ci/woodpecker/release/publish-docs Pipeline was successful
2025-03-11 22:08:59 -05:00
32444ff82e fix: docs and pipeline errors
Some checks failed
ci/woodpecker/tag/gitea Pipeline failed
ci/woodpecker/tag/publish-docs Pipeline was successful
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline failed
2025-03-11 21:55:51 -05:00
a5a7c05640 v0.10.1
Some checks failed
ci/woodpecker/push/publish-docs Pipeline was successful
ci/woodpecker/tag/gitea Pipeline failed
ci/woodpecker/tag/publish-docs Pipeline was successful
2025-03-11 21:37:58 -05:00
bfb81e11b2 version bump
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline was successful
2025-03-11 21:36:53 -05:00
fd4c83f9c0 Vault: keys are now referenced by name, and the actual data by data
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline failed
2025-03-11 21:33:06 -05:00
fe27c6396a LinuxUserManager: correct parameters for AddUser()
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
2025-03-11 16:13:29 -05:00
c89dde186a UserCommands: change field name
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline was successful
2025-03-11 15:37:12 -05:00
18a64de0de UserCommands: change field name 2025-03-11 15:36:43 -05:00
99c622b69f UserCommands: add field CreateUserHome 2025-03-11 15:30:07 -05:00
95e85e8b45 UserCommands: add ssh public keys when running locally
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
2025-03-11 15:21:02 -05:00
1a48c7bca5 change: create temp file when modifing password over SSH 2025-03-11 14:55:02 -05:00
5d21764ef1 fix: don't test empty env files
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
2025-03-11 13:42:40 -05:00
c7302f0e17 update docs
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline was successful
2025-03-10 12:34:33 -05:00
fb1c8ec4fb v0.10.0
Some checks failed
ci/woodpecker/push/publish-docs Pipeline was successful
ci/woodpecker/tag/gitea Pipeline was successful
ci/woodpecker/tag/publish-docs Pipeline was successful
ci/woodpecker/release/publish-docs Pipeline was successful
ci/woodpecker/push/go-lint Pipeline failed
2025-03-08 00:25:44 -06:00
fe9462dac0 version bump
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline was successful
2025-03-08 00:24:23 -06:00
d8453d1fb0 added external directives to Notifications, change case of keys in host, and update docs 2025-03-08 00:23:08 -06:00
148 changed files with 2918 additions and 872 deletions

0
.changes/0.2.4.md Normal file → Executable file
View File

0
.changes/header.tpl.md Normal file → Executable file
View File

0
.changes/unreleased/.gitkeep Normal file → Executable file
View File

View File

@@ -1,3 +0,0 @@
kind: Added
body: 'Hooks: improved logging when executing'
time: 2025-03-01T13:29:32.195438013-06:00

View File

@@ -1,3 +0,0 @@
kind: Added
body: 'User commands: adding SSH keys using config key `userSshPubKeys`'
time: 2025-03-03T23:42:48.009294808-06:00

View File

@@ -1,3 +0,0 @@
kind: Added
body: 'directives: added support for fetching values using directive `%{externalSource:key}%`'
time: 2025-03-03T23:45:05.666939653-06:00

View File

@@ -1,3 +0,0 @@
kind: Changed
body: 'Commands: if dir is not specified, run in config dir'
time: 2025-03-01T19:43:21.323077376-06:00

View File

@@ -1,3 +0,0 @@
kind: Changed
body: 'FileDirective: use the config directory if path is not absolute'
time: 2025-03-05T00:34:15.689980075-06:00

View File

@@ -1,3 +0,0 @@
kind: Fixed
body: 'LocalFetcher: return fetch error'
time: 2025-03-01T13:26:00.330176712-06:00

View File

@@ -1,3 +0,0 @@
kind: Fixed
body: 'Lists: load file key before attempting to load from current file'
time: 2025-03-01T13:28:01.739467944-06:00

View File

@@ -1,3 +0,0 @@
kind: Fixed
body: 'fix: host not in config file, but in ssh config, properly added to hosts struct'
time: 2025-03-01T18:24:34.81395054-06:00

View File

@@ -1,3 +0,0 @@
kind: Fixed
body: 'SSH: password authentication bugs'
time: 2025-03-04T23:57:06.326604774-06:00

View File

@@ -1,3 +0,0 @@
kind: Fixed
body: 'User commands: change user password works'
time: 2025-03-06T23:30:10.791394853-06:00

16
.changes/v0.10.0.md Executable file
View File

@@ -0,0 +1,16 @@
## v0.10.0 - 2025-03-08
### Added
* Hooks: improved logging when executing
* User commands: adding SSH keys using config key `userSshPubKeys`
* directives: added support for fetching values using directive `%{externalSource:key}%`
### Changed
* Commands: if dir is not specified, run in config dir
* FileDirective: use the config directory if path is not absolute
* Host: changes to case of some keys
* Notifications: added external directive to sensitive keys
### Fixed
* LocalFetcher: return fetch error
* Lists: load file key before attempting to load from current file
* fix: host not in config file, but in ssh config, properly added to hosts struct
* SSH: password authentication bugs
* User commands: change user password works

8
.changes/v0.10.1.md Executable file
View File

@@ -0,0 +1,8 @@
## v0.10.1 - 2025-03-11
### Added
* UserCommands: add ssh public keys when running locally
* UserCommands: add field CreateUserHome
### Changed
* UserCommands: create temp file when modifing password over SSH
* UserCommands: change field name
* Vault: keys are now referenced by `name`, and the actual data by `data`

6
.changes/v0.10.2.md Executable file
View File

@@ -0,0 +1,6 @@
## v0.10.2 - 2025-03-19
### Added
* Notifications: http service added
* Variable support. Can be referenced with `%{var:nameOfVar}%` in select string fields.
### Changed
* vault: initialize vault before validating config

21
.changes/v0.11.0.md Normal file
View File

@@ -0,0 +1,21 @@
## v0.11.0 - 2025-11-24
### Added
* feat: Package operation `versionCheck` supports regular expressions (see [regexp](https://pkg.go.dev/regexp) package for docs)
* Command lists: added `cmdLists.[name].notify` object
* Testing setup with Docker
* CLI: add global flag --hostsConfig that allows hosts to be dynamic in relation to the main config
* CLI: Exec subcommand `hosts`. See documentation for more details.
* CLI: added `exec hosts` subcommand `list`
* Add support for hosts in parallel
### Changed
* Commands: `host` can now be `localhost` or `127.0.0.1` to run commands locally
* lists loaded from external files only if no list config present in current file
* `PackageManager.Parse` renamed to `ParseRemotePackageManagerVersionOutput`. This now returns arrays of PackageManagerCommon.Package and errors.
* Internal: refactoring and renaming functions
* Commands: moved output-prefixed keys to the `commands.[name].output` object
* Change internal method name for better understanding
* Improved error message for remote version package output
### Fixed
* Command Lists: hooks now run correctly when commands finish
* Log file passed using `--log-file` correctly used
* Cmd Type `script` now correctly appends arguments

0
.changes/v0.3.0.md Normal file → Executable file
View File

0
.changes/v0.3.1.md Normal file → Executable file
View File

0
.changes/v0.4.0.md Normal file → Executable file
View File

0
.changes/v0.5.0.md Normal file → Executable file
View File

0
.changes/v0.6.0.md Normal file → Executable file
View File

0
.changes/v0.6.1.md Normal file → Executable file
View File

0
.changes/v0.7.0.md Normal file → Executable file
View File

0
.changes/v0.7.1.md Normal file → Executable file
View File

0
.changes/v0.7.2.md Normal file → Executable file
View File

0
.changes/v0.7.3.md Normal file → Executable file
View File

0
.changes/v0.7.4.md Normal file → Executable file
View File

0
.changes/v0.7.5.md Normal file → Executable file
View File

0
.changes/v0.7.6.md Normal file → Executable file
View File

0
.changes/v0.7.7.md Normal file → Executable file
View File

0
.changes/v0.7.8.md Normal file → Executable file
View File

0
.changes/v0.8.0.md Normal file → Executable file
View File

0
.changes/v0.9.0.md Normal file → Executable file
View File

0
.changes/v0.9.1.md Normal file → Executable file
View File

0
.changie.yaml Normal file → Executable file
View File

0
.frontmatter/database/mediaDb.json Normal file → Executable file
View File

0
.frontmatter/database/taxonomyDb.json Normal file → Executable file
View File

0
.github/workflows/release.yml vendored Normal file → Executable file
View File

2
.gitignore vendored Normal file → Executable file
View File

@@ -5,6 +5,6 @@ dist/
.codegpt
*.log
*.sh
/*.sh
/*.yaml
/*.yml

0
.gitmodules vendored Normal file → Executable file
View File

0
.goreleaser/gitea.yml Normal file → Executable file
View File

0
.goreleaser/github.yml Normal file → Executable file
View File

0
.goreleaser/vern.yml Normal file → Executable file
View File

3
.vscode/settings.json vendored Normal file → Executable file
View File

@@ -9,5 +9,6 @@
"mautrix",
"nikoksr",
"Strs"
]
],
"CodeGPT.apiKey": "CodeGPT Plus Beta"
}

2
.woodpecker/gitea.yml Normal file → Executable file
View File

@@ -1,9 +1,7 @@
name: goreleaser release
steps:
golang:
image: golang:1.23
commands:
- go mod tidy
- go install github.com/goreleaser/goreleaser/v2@v2.7.0
- goreleaser release -f .goreleaser/gitea.yml --release-notes=".changes/$(go run backy.go version -V).md"
environment:

2
.woodpecker/go-lint.yml Normal file → Executable file
View File

@@ -5,7 +5,7 @@ steps:
- go build
- go test
release:
image: golangci/golangci-lint:v1.53.3
image: golangci/golangci-lint:v1.64.7
commands:
- golangci-lint run -v --timeout 5m

4
.woodpecker/publish-docs.yml Normal file → Executable file
View File

@@ -1,11 +1,11 @@
steps:
build:
image: hugomods/hugo:ci
image: hugomods/hugo:debian-ci-0.147.2
commands:
- git submodule foreach 'git fetch origin; git checkout $(git describe --tags `git rev-list --tags --max-count=1`);'
- cd docs
- hugo mod get -u github.com/divinerites/plausible-hugo
- hugo mod get -u github.com/McShelby/hugo-theme-relearn@7.3.1
- hugo mod get -u github.com/McShelby/hugo-theme-relearn@8.2.0
- hugo
deploy:

55
CHANGELOG.md Normal file → Executable file
View File

@@ -6,6 +6,61 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](https://github.com/miniscruff/changie).
## v0.11.0 - 2025-11-24
### Added
* feat: Package operation `versionCheck` supports regular expressions (see [regexp](https://pkg.go.dev/regexp) package for docs)
* Command lists: added `cmdLists.[name].notify` object
* Testing setup with Docker
* CLI: add global flag --hostsConfig that allows hosts to be dynamic in relation to the main config
* CLI: Exec subcommand `hosts`. See documentation for more details.
* CLI: added `exec hosts` subcommand `list`
* Add support for hosts in parallel
### Changed
* Commands: `host` can now be `localhost` or `127.0.0.1` to run commands locally
* lists loaded from external files only if no list config present in current file
* `PackageManager.Parse` renamed to `ParseRemotePackageManagerVersionOutput`. This now returns arrays of PackageManagerCommon.Package and errors.
* Internal: refactoring and renaming functions
* Commands: moved output-prefixed keys to the `commands.[name].output` object
* Change internal method name for better understanding
* Improved error message for remote version package output
### Fixed
* Command Lists: hooks now run correctly when commands finish
* Log file passed using `--log-file` correctly used
* Cmd Type `script` now correctly appends arguments
## v0.10.2 - 2025-03-19
### Added
* Notifications: http service added
* Variable support. Can be referenced with `%{var:nameOfVar}%` in select string fields.
### Changed
* vault: initialize vault before validating config
## v0.10.1 - 2025-03-11
### Added
* UserCommands: add ssh public keys when running locally
* UserCommands: add field CreateUserHome
### Changed
* UserCommands: create temp file when modifing password over SSH
* UserCommands: change field name
* Vault: keys are now referenced by `name`, and the actual data by `data`
## v0.10.0 - 2025-03-08
### Added
* Hooks: improved logging when executing
* User commands: adding SSH keys using config key `userSshPubKeys`
* directives: added support for fetching values using directive `%{externalSource:key}%`
### Changed
* Commands: if dir is not specified, run in config dir
* FileDirective: use the config directory if path is not absolute
* Host: changes to case of some keys
* Notifications: added external directive to sensitive keys
### Fixed
* LocalFetcher: return fetch error
* Lists: load file key before attempting to load from current file
* fix: host not in config file, but in ssh config, properly added to hosts struct
* SSH: password authentication bugs
* User commands: change user password works
## v0.9.1 - 2025-03-01
### Changed
* Use EnvVar AWS_PROFILE to get S3 profile

0
License Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

1
backy.code-workspace Normal file → Executable file
View File

@@ -18,6 +18,7 @@
"maunium",
"mautrix",
"nikoksr",
"packagemanagercommon",
"rawbytes",
"remotefetcher",
"Strs"

0
backy.go Normal file → Executable file
View File

0
cmd/.gitignore vendored Normal file → Executable file
View File

9
cmd/backup.go Normal file → Executable file
View File

@@ -30,9 +30,14 @@ func init() {
}
func Backup(cmd *cobra.Command, args []string) {
backyConfOpts := backy.NewOpts(cfgFile, backy.AddCommandLists(cmdLists), backy.SetLogFile(logFile), backy.SetCmdStdOut(cmdStdOut))
backyConfOpts := backy.NewConfigOptions(configFile,
backy.AddCommandLists(cmdLists),
backy.SetLogFile(logFile),
backy.EnableCommandStdOut(cmdStdOut),
backy.SetHostsConfigFile(hostsConfigFile))
backyConfOpts.InitConfig()
backyConfOpts.ReadConfig()
backyConfOpts.ParseConfigurationFile()
backyConfOpts.RunListConfig("")
for _, host := range backyConfOpts.Hosts {

54
cmd/backup_test.go Executable file
View File

@@ -0,0 +1,54 @@
package cmd
// import (
// "bufio"
// "encoding/json"
// "os"
// "os/exec"
// "strings"
// "testing"
// "github.com/stretchr/testify/assert"
// )
// // TestConfigOptions tests the configuration options for the backy package.
// func Test_ErrorHook(t *testing.T) {
// configFile := "-f ../../tests/ErrorHook.yml"
// logFile := "--log-file=ErrorHook.log"
// backyCommand := exec.Command("go", "run", "../../backy.go", configFile, logFile, "backup")
// backyCommand.Stderr = os.Stdout
// backyCommand.Stdout = os.Stdout
// err := backyCommand.Run()
// assert.Nil(t, err)
// os.Remove("ErrorHook.log")
// logFileData, logFileErr := os.ReadFile("ErrorHook.log")
// if logFileErr != nil {
// assert.FailNow(t, logFileErr.Error())
// }
// var JsonData []map[string]interface{}
// jsonScanner := bufio.NewScanner(strings.NewReader(string(logFileData)))
// for jsonScanner.Scan() {
// var jsonDataLine map[string]interface{}
// err = json.Unmarshal(jsonScanner.Bytes(), &jsonDataLine)
// assert.Nil(t, err)
// JsonData = append(JsonData, jsonDataLine)
// }
// for _, v := range JsonData {
// _, ok := v["error"]
// if !ok {
// assert.FailNow(t, "error does not exist\n")
// // return
// }
// }
// // t.Logf("%s", logFileData)
// // t.Logf("%v", JsonData)
// }
// func TestBackupErrorHook(t *testing.T) {
// logFile = "ErrorHook.log"
// configFile = "../tests/ErrorHook.yml"
// }

2
cmd/config.go Normal file → Executable file
View File

@@ -20,7 +20,7 @@ package cmd
// func config(cmd *cobra.Command, args []string) {
// opts := backy.NewOpts(cfgFile, backy.cronEnabled())
// opts := backy.NewConfigOptions(configFile, backy.cronEnabled())
// opts.InitConfig()
// }

7
cmd/cron.go Normal file → Executable file
View File

@@ -18,13 +18,14 @@ var (
func cron(cmd *cobra.Command, args []string) {
parseS3Config()
opts := backy.NewOpts(cfgFile,
opts := backy.NewConfigOptions(configFile,
backy.EnableCron(),
backy.SetLogFile(logFile),
backy.SetCmdStdOut(cmdStdOut))
backy.EnableCommandStdOut(cmdStdOut),
backy.SetHostsConfigFile(hostsConfigFile))
opts.InitConfig()
opts.ReadConfig()
opts.ParseConfigurationFile()
opts.Cron()
}

10
cmd/exec.go Normal file → Executable file
View File

@@ -21,7 +21,7 @@ var (
)
func init() {
execCmd.AddCommand(hostExecCommand)
execCmd.AddCommand(hostExecCommand, hostsExecCommand)
}
@@ -32,8 +32,12 @@ func execute(cmd *cobra.Command, args []string) {
logging.ExitWithMSG("Please provide a command to run. Pass --help to see options.", 1, nil)
}
opts := backy.NewOpts(cfgFile, backy.AddCommands(args), backy.SetLogFile(logFile), backy.SetCmdStdOut(cmdStdOut))
opts := backy.NewConfigOptions(configFile,
backy.AddCommands(args),
backy.SetLogFile(logFile),
backy.EnableCommandStdOut(cmdStdOut),
backy.SetHostsConfigFile(hostsConfigFile))
opts.InitConfig()
opts.ReadConfig()
opts.ParseConfigurationFile()
opts.ExecuteCmds()
}

17
cmd/host.go Normal file → Executable file
View File

@@ -35,10 +35,13 @@ func init() {
// 2. stdin (on command line) (TODO)
func Host(cmd *cobra.Command, args []string) {
backyConfOpts := backy.NewOpts(cfgFile, backy.SetLogFile(logFile), backy.SetCmdStdOut(cmdStdOut))
backyConfOpts := backy.NewConfigOptions(configFile,
backy.SetLogFile(logFile),
backy.EnableCommandStdOut(cmdStdOut),
backy.SetHostsConfigFile(hostsConfigFile))
backyConfOpts.InitConfig()
backyConfOpts.ReadConfig()
backyConfOpts.ParseConfigurationFile()
// check CLI input
if hostsList == nil {
@@ -46,14 +49,20 @@ func Host(cmd *cobra.Command, args []string) {
}
for _, h := range hostsList {
if backy.IsHostLocal(h) {
continue
}
// check if h exists in the config file
_, hostFound := backyConfOpts.Hosts[h]
if !hostFound {
// check if h exists in the SSH config file
hostFoundInConfig, s := backy.CheckIfHostHasHostName(h)
hostFoundInConfig, s := backy.DoesHostHaveHostName(h)
if !hostFoundInConfig {
logging.ExitWithMSG("host "+h+" not found", 1, &backyConfOpts.Logger)
}
if backyConfOpts.Hosts == nil {
backyConfOpts.Hosts = make(map[string]*backy.Host)
}
// create host with hostname and host
backyConfOpts.Hosts[h] = &backy.Host{Host: h, HostName: s}
}
@@ -68,5 +77,5 @@ func Host(cmd *cobra.Command, args []string) {
}
}
backyConfOpts.ExecCmdsSSH(cmdList, hostsList)
backyConfOpts.ExecCmdsOnHosts(cmdList, hostsList)
}

93
cmd/hosts.go Executable file
View File

@@ -0,0 +1,93 @@
package cmd
import (
"maps"
"slices"
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
"git.andrewnw.xyz/CyberShell/backy/pkg/logging"
"github.com/spf13/cobra"
)
var (
runCommandsInParallel bool
hostsExecCommand = &cobra.Command{
Use: "hosts [--command=command1 --command=command2 ... | -c command1 -c command2 ...]",
Short: "Runs command defined in config file on the hosts in order specified.",
Long: "Hosts executes specified commands on all the hosts defined in config file.\nUse the --commands or -c flag to choose the commands.",
Run: Hosts,
}
hostsListExecCommand = &cobra.Command{
Use: "list list1 list2 ...",
Short: "Runs lists in order specified defined in config file on all hosts.",
Long: "Lists executes specified lists on all the hosts defined in hosts config.\nPass the names of lists as arguments after command.",
Run: HostsList,
}
)
func init() {
hostsExecCommand.AddCommand(hostsListExecCommand)
hostsListExecCommand.Flags().BoolVarP(&runCommandsInParallel, "parallel", "p", false, "Run commands in parallel on hosts")
parseS3Config()
}
// cli input should be hosts and commands. Hosts are defined in config files.
// commands can be passed by the following mutually exclusive options:
// 1. as a list of commands defined in the config file
// 2. stdin (on command line) (TODO)
func Hosts(cmd *cobra.Command, args []string) {
backyConfOpts := backy.NewConfigOptions(configFile,
backy.SetLogFile(logFile),
backy.EnableCommandStdOut(cmdStdOut),
backy.SetHostsConfigFile(hostsConfigFile))
backyConfOpts.InitConfig()
backyConfOpts.ParseConfigurationFile()
for _, h := range backyConfOpts.Hosts {
hostsList = append(hostsList, h.Host)
}
if cmdList == nil {
logging.ExitWithMSG("error: commands must be specified", 1, &backyConfOpts.Logger)
}
for _, c := range cmdList {
_, cmdFound := backyConfOpts.Cmds[c]
if !cmdFound {
logging.ExitWithMSG("cmd "+c+" not found", 1, &backyConfOpts.Logger)
}
}
backyConfOpts.ExecCmdsOnHosts(cmdList, hostsList)
}
func HostsList(cmd *cobra.Command, args []string) {
backyConfOpts := backy.NewConfigOptions(configFile,
backy.SetLogFile(logFile),
backy.EnableCommandStdOut(cmdStdOut),
backy.SetHostsConfigFile(hostsConfigFile))
backyConfOpts.InitConfig()
backyConfOpts.ParseConfigurationFile()
if len(args) == 0 {
logging.ExitWithMSG("error: no lists specified", 1, &backyConfOpts.Logger)
}
for _, l := range args {
_, listFound := backyConfOpts.CmdConfigLists[l]
if !listFound {
logging.ExitWithMSG("list "+l+" not found", 1, &backyConfOpts.Logger)
}
}
maps.DeleteFunc(backyConfOpts.CmdConfigLists, func(k string, v *backy.CmdList) bool {
return !slices.Contains(args, k)
})
backyConfOpts.ExecuteListOnHosts(args, runCommandsInParallel)
}

20
cmd/list.go Normal file → Executable file
View File

@@ -22,13 +22,13 @@ var (
Use: "cmds [cmd1 cmd2 cmd3...]",
Short: "List commands defined in config file.",
Long: "List commands defined in config file",
Run: ListCmds,
Run: ListCommands,
}
listCmdLists = &cobra.Command{
Use: "lists [list1 list2 ...]",
Short: "List lists defined in config file.",
Long: "List lists defined in config file",
Run: ListCmdLists,
Run: ListCommandLists,
}
)
@@ -40,7 +40,7 @@ func init() {
}
func ListCmds(cmd *cobra.Command, args []string) {
func ListCommands(cmd *cobra.Command, args []string) {
// setup based on whats passed in:
// - cmds
@@ -54,17 +54,19 @@ func ListCmds(cmd *cobra.Command, args []string) {
parseS3Config()
opts := backy.NewOpts(cfgFile, backy.SetLogFile(logFile))
opts := backy.NewConfigOptions(configFile,
backy.SetLogFile(logFile),
backy.SetHostsConfigFile(hostsConfigFile))
opts.InitConfig()
opts.ReadConfig()
opts.ParseConfigurationFile()
for _, v := range cmdsToList {
opts.ListCommand(v)
}
}
func ListCmdLists(cmd *cobra.Command, args []string) {
func ListCommandLists(cmd *cobra.Command, args []string) {
parseS3Config()
@@ -74,10 +76,12 @@ func ListCmdLists(cmd *cobra.Command, args []string) {
logging.ExitWithMSG("Error: lists subcommand needs lists", 1, nil)
}
opts := backy.NewOpts(cfgFile, backy.SetLogFile(logFile))
opts := backy.NewConfigOptions(configFile,
backy.SetLogFile(logFile),
backy.SetHostsConfigFile(hostsConfigFile))
opts.InitConfig()
opts.ReadConfig()
opts.ParseConfigurationFile()
for _, v := range listsToList {
opts.ListCommandList(v)

18
cmd/root.go Normal file → Executable file
View File

@@ -13,11 +13,12 @@ import (
var (
// Used for flags.
cfgFile string
verbose bool
cmdStdOut bool
logFile string
s3Endpoint string
configFile string
hostsConfigFile string
verbose bool
cmdStdOut bool
logFile string
s3Endpoint string
rootCmd = &cobra.Command{
Use: "backy",
@@ -35,12 +36,13 @@ func Execute() {
}
func init() {
rootCmd.PersistentFlags().StringVar(&logFile, "log-file", "", "log file to write to")
rootCmd.PersistentFlags().StringVar(&logFile, "logFile", "", "log file to write to")
rootCmd.PersistentFlags().BoolVar(&cmdStdOut, "cmdStdOut", false, "Pass to print command output to stdout")
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "f", "", "config file to read from")
rootCmd.PersistentFlags().StringVarP(&configFile, "config", "f", "", "config file to read from")
rootCmd.PersistentFlags().StringVar(&hostsConfigFile, "hostsConfig", "", "yaml hosts file to read from")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Sets verbose level")
rootCmd.PersistentFlags().StringVar(&s3Endpoint, "s3-endpoint", "", "Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.")
rootCmd.PersistentFlags().StringVar(&s3Endpoint, "s3Endpoint", "", "Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.")
rootCmd.AddCommand(backupCmd, execCmd, cronCmd, versionCmd, listCmd)
}

2
cmd/version.go Normal file → Executable file
View File

@@ -7,7 +7,7 @@ import (
"github.com/spf13/cobra"
)
const versionStr = "0.9.2"
const versionStr = "0.11.0"
var (
versionCmd = &cobra.Command{

0
docs/.gitignore vendored Normal file → Executable file
View File

0
docs/.hugo_build.lock Normal file → Executable file
View File

0
docs/archetypes/default.md Normal file → Executable file
View File

1
docs/config.yaml Normal file → Executable file
View File

@@ -13,6 +13,7 @@ module:
imports:
- path: github.com/divinerites/plausible-hugo
- path: github.com/McShelby/hugo-theme-relearn
version: "v8.2.0"
params:
themeVariant:
- auto: []

0
docs/content/_index.md Normal file → Executable file
View File

View File

@@ -26,8 +26,9 @@ Flags:
--cmdStdOut Pass to print command output to stdout
-f, --config string config file to read from
-h, --help help for backy
--log-file string log file to write to
--s3-endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
--hostsConfig string yaml hosts file to read from
--logFile string log file to write to
--s3Endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
-v, --verbose Sets verbose level
Use "backy [command] --help" for more information about a command.
@@ -51,8 +52,9 @@ Flags:
Global Flags:
--cmdStdOut Pass to print command output to stdout
-f, --config string config file to read from
--log-file string log file to write to
--s3-endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
--hostsConfig string yaml hosts file to read from
--logFile string log file to write to
--s3Endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
-v, --verbose Sets verbose level
```
@@ -70,8 +72,9 @@ Flags:
Global Flags:
--cmdStdOut Pass to print command output to stdout
-f, --config string config file to read from
--log-file string log file to write to
--s3-endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
--hostsConfig string yaml hosts file to read from
--logFile string log file to write to
--s3Endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
-v, --verbose Sets verbose level
```
@@ -86,6 +89,7 @@ Usage:
Available Commands:
host Runs command defined in config file on the hosts in order specified.
hosts Runs command defined in config file on the hosts in order specified.
Flags:
-h, --help help for exec
@@ -93,8 +97,9 @@ Flags:
Global Flags:
--cmdStdOut Pass to print command output to stdout
-f, --config string config file to read from
--log-file string log file to write to
--s3-endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
--hostsConfig string yaml hosts file to read from
--logFile string log file to write to
--s3Endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
-v, --verbose Sets verbose level
Use "backy exec [command] --help" for more information about a command.
@@ -117,8 +122,9 @@ Flags:
Global Flags:
--cmdStdOut Pass to print command output to stdout
-f, --config string config file to read from
--log-file string log file to write to
--s3-endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
--hostsConfig string yaml hosts file to read from
--logFile string log file to write to
--s3Endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
-v, --verbose Sets verbose level
```
@@ -138,8 +144,9 @@ Flags:
Global Flags:
--cmdStdOut Pass to print command output to stdout
-f, --config string config file to read from
--log-file string log file to write to
--s3-endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
--hostsConfig string yaml hosts file to read from
--logFile string log file to write to
--s3Endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
-v, --verbose Sets verbose level
```
@@ -161,8 +168,9 @@ Flags:
Global Flags:
--cmdStdOut Pass to print command output to stdout
-f, --config string config file to read from
--log-file string log file to write to
--s3-endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
--hostsConfig string yaml hosts file to read from
--logFile string log file to write to
--s3Endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
-v, --verbose Sets verbose level
Use "backy list [command] --help" for more information about a command.
@@ -181,8 +189,9 @@ Flags:
Global Flags:
--cmdStdOut Pass to print command output to stdout
-f, --config string config file to read from
--log-file string log file to write to
--s3-endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
--hostsConfig string yaml hosts file to read from
--logFile string log file to write to
--s3Endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
-v, --verbose Sets verbose level
```
## list lists
@@ -199,7 +208,8 @@ Flags:
Global Flags:
--cmdStdOut Pass to print command output to stdout
-f, --config string config file to read from
--log-file string log file to write to
--s3-endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
--hostsConfig string yaml hosts file to read from
--logFile string log file to write to
--s3Endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
-v, --verbose Sets verbose level
```

2
docs/content/cli/exec.md Normal file → Executable file
View File

@@ -15,5 +15,5 @@ The `exec` subcommand can do some things that the configuration file can't do ye
The commands have to be defined in the config file. The hosts need to at least be in the ssh_config(5) file.
```sh
backy exec host [--commands=command1 -commands=command2 ... | -c command1 -c command2 ...] [--hosts=host1 --hosts=hosts2 ... | -m host1 -c host2 ...] [flags]
backy exec host [--commands=command1 -commands=command2 ... | -c command1 -c command2 ...] [--hosts=host1 --hosts=hosts2 ... | -m host1 -m host2 ...] [flags]
```

29
docs/content/cli/list.md Executable file
View File

@@ -0,0 +1,29 @@
---
title: List
---
List commands, lists, or hosts defined in config file
Usage:
```
backy list [command]
```
Available Commands:
cmds List commands defined in config file.
lists List lists defined in config file.
Flags:
```
-h, --help help for list
```
Global Flags:
```
--cmdStdOut Pass to print command output to stdout
-f, --config string config file to read from
--log-file string log file to write to
--s3-endpoint string Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.
-v, --verbose Sets verbose level
```

0
docs/content/config/_index.md Normal file → Executable file
View File

12
docs/content/config/command-lists.md Normal file → Executable file
View File

@@ -35,12 +35,12 @@ If a remote config file is specified (on the command-line using `-f`) and the li
```
| key | description | type | required
| --- | --- | --- | --- |
| `order` | Defines the sequence of commands to execute | `[]string` | yes |
| `getOutput` | Command(s) output is in the notification(s) | `bool` | no |
| `notifications` | The notification service(s) and ID(s) to use on success and failure. Must be *`service.id`*. See the [notifications documentation page](/config/notifications/) for more | `[]string` | no |
| `name` | Optional name of the list | `string` | no |
| `cron` | Time at which to schedule the list. Only has affect when cron subcommand is run. | `string` | no |
| --- | --- | --- | ---
| `order` | Defines the sequence of commands to execute | `[]string` | yes
| `sendNotificationOnSuccess` | Whether to send notification on list success with the commands' output | `bool` | no
| `notifications` | The notification service(s) and ID(s) to use on success and failure. Must be *`service.id`*. See the [notifications documentation page](/config/notifications/) for more | `[]string` | no
| `name` | Optional name of the list | `string` | no
| `cron` | Time at which to schedule the list. Only has affect when cron subcommand is run. | `string` | no
### Order

63
docs/content/config/commands/_index.md Normal file → Executable file
View File

@@ -12,17 +12,18 @@ weight: 1
Values available for this section **(case-sensitive)**:
| name | notes | type | required
| --- | --- | --- | --- |
| `cmd` | Defines the command to execute | `string` | yes |
| `Args` | Defines the arguments to the command | `[]string` | no |
| `environment` | Defines environment variables for the command | `[]string` | no |
| `type` | See documentation further down the page. Additional fields may be required. | `string` | no |
| `getOutput` | Command(s) output is in the notification(s) | `bool` | no |
| `host` | If not specified, the command will execute locally. | `string` | no |
| `scriptEnvFile` | When type is `scriptFile` or `script`, this file is prepended to the input. | `string` | no |
| `shell` | Run the command in the shell | `string` | no |
| `hooks` | Hooks are used at the end of the individual command. Must have at least `error`, `success`, or `final`. | `map[string][]string` | no |
| name | notes | type | required | External directive support |
| ----------------| ------------------------------------------------------------------------------------------------------- | --------------------- | -------- |----------------------------|
| `cmd` | Defines the command to execute | `string` | yes | No |
| `Args` | Defines the arguments to the command | `[]string` | no | No |
| `environment` | Defines environment variables for the command | `[]string` | no | Partial |
| `type` | See documentation further down the page. Additional fields may be required. | `string` | no | No |
| `getOutput` | Command(s) output is in the notification(s) | `bool` | no | No |
| `host` | Depricated: use `hosts`. If not specified, the command will execute locally. | `string` | no | No |
| `hosts` | Must be specified to run commands both locallly and in parrallel. | `[]string` | no | No |
| `scriptEnvFile` | When type is `scriptFile` or `script`, this file is prepended to the input. | `string` | no | No |
| `shell` | Run the command in the shell | `string` | no | No |
| `hooks` | Hooks are used at the end of the individual command. Must have at least `error`, `success`, or `final`. | `map[string][]string` | no | No |
#### cmd
@@ -51,7 +52,12 @@ Get command output when a notification is sent.
Is not required. Can be `true` or `false`.
#### host
### host
{{% notice warning %}}
Depricated: use `hosts` instead.
{{% /notice %}}
{{% notice info %}}
If any `host` is not defined or left blank, the command will run on the local machine.
@@ -66,6 +72,36 @@ For example, say that I have a host defined in my SSH config with the `Host` def
If I assign a value to host as `host: web-prod` and don't specify this value in the `hosts` object, web-prod will be used as the `Host` in searching the SSH config files.
{{% /notice %}}
### hosts
{{% notice info %}}
If any `command.[name].hosts` index is `localhost` or `127.0.0.1`, the command will run on the local machine.
You can also remove the field to have the command run locally.
{{% /notice %}}
Host may or may not be defined in the `hosts` section.
{{% notice info %}}
If any `host` from the commands section does not match any object in the `hosts` section, the `Host` is assumed to be this value. This value will be used to search in the default SSH config files.
For example, say that I have a host defined in my SSH config with the `Host` defined as `web-prod`.
If I assign a value to host as `host: web-prod` and don't specify this value in the `hosts` object, web-prod will be used as the `Host` in searching the SSH config files.
{{% /notice %}}
###### Example:
```yaml
command:
start-some-process:
cmd: start-server
hosts:
- prod-1
- prod-2
```
### shell
If shell is defined, the command will run in the specified shell.
@@ -95,8 +131,9 @@ The following options are available:
The environment variables support expansion:
- using escaped values `$VAR` or `${VAR}`
- using any external directive, and if using the env directive, the variable will be read from a `.env` file
For now, the variables have to be defined in an `.env` file in the same directory that the program is run from.
<!-- For now, the variables expanded have to be defined in an `.env` file in the same directory that the program is run from. -->
If using it with host specified, the SSH server has to be configured to accept those env variables.

6
docs/content/config/commands/packages.md Normal file → Executable file
View File

@@ -8,7 +8,7 @@ This is dedicated to `package` commands. The command `type` field must be `packa
| name | notes | type | required |
| --- | --- | --- | --- |
| `packageName` | The name of a package to be modified. | `string` | yes |
| `packageName` | The name of a package to be modified. | `[]packagemanagercommon.Package` | yes |
| `packageManager` | The name of the package manger to be used. | `string` | yes |
| `packageOperation` | The type of operation to perform. | `string` | yes |
| `packageVersion` | The version of a package. | `string` | no |
@@ -22,7 +22,9 @@ The following is an example of a package command:
update-docker:
type: package
shell: zsh
packageName: docker-ce
packages:
- name: docker-ce
version: 10
packageManager: apt
packageOperation: install
host: debian-based-host

20
docs/content/config/commands/user-commands.md Normal file → Executable file
View File

@@ -6,14 +6,18 @@ description: This is dedicated to user commands.
This is dedicated to `user` commands. The command `type` field must be `user`. User is a type that allows one to perform user operations. There are several additional options available when `type` is `user`:
| name | notes | type | required |
| --- | --- | --- | --- |
| `userName` | The name of a user to be configured. | `string` | yes |
| `userOperation` | The type of operation to perform. | `string` | yes |
| `userID` | The user ID to use. | `string` | yes |
| `userGroups` | The groups the user should be added to. | `[]string` | yes |
| `userShell` | The shell for the user. | `string` | yes |
| `userHome` | The user's home directory. | `string` | no |
| name | notes | type | required | External directive support
| ----------------| -------------------------------------------------------------| ---------- | ---------| --------------------------|
| `userName` | The name of a user to be configured. | `string` | yes | no |
| `userOperation` | The type of operation to perform. | `string` | yes | no |
| `userID` | The user ID to use. | `string` | no | no |
| `userGroups` | The groups the user should be added to. | `[]string` | no | no |
| `systemUser` | Create a system user. | `bool` | no | no |
| `userCreateHome`| Create the home directory. | `bool` | no | no |
| `userSshPubKeys`| The keys to add to the user's authorized keys. | `[]string` | no | yes |
| `userShell` | The shell for the user. | `string` | no | no |
| `userHome` | The user's home directory. | `string` | no | no |
| `userPassword` | The new password value when using the `password` operation. | `string` | no | yes |
#### example

View File

@@ -0,0 +1,15 @@
---
title: "External Directives"
weight: 2
description: How to set up external directives.
---
External directives are for including data that should not be in the config file. The following directives are supported:
- `%{file:path/to/file}%`
- `%{env:ENV_VAR}%`
- `%{vault:vault-key}%`
See the docs of each command if the field is supported.
If the file path does not begin with a `/`, the config file's directory will be used as the starting point.

28
docs/content/config/hosts.md Normal file → Executable file
View File

@@ -5,20 +5,20 @@ description: >
This page tells you how to use hosts.
---
| Key | Description | Type | Required |
|----------------------|---------------------------------------------------------------|----------|----------|
| `OS` | Operating system of the host (used for package commands) | `string` | no |
| `config` | Path to the SSH config file | `string` | no |
| `host` | Specifies the `Host` ssh_config(5) directive | `string` | yes |
| `hostname` | Hostname of the host | `string` | no |
| `knownhostsfile` | Path to the known hosts file | `string` | no |
| `port` | Port number to connect to | `uint16` | no |
| `proxyjump` | Proxy jump hosts, comma-separated | `string` | no |
| `password` | Password for SSH authentication | `string` | no |
| `privatekeypath` | Path to the private key file | `string` | no |
| `privatekeypassword` | Password for the private key file | `string` | no |
| `user` | Username for SSH authentication | `string` | no |
| Key | Description | Type | Required | External directive support |
|----------------------|---------------------------------------------------------------|----------|----------|----------------------------|
| `OS` | Operating system of the host (used for package commands) | `string` | no | No |
| `config` | Path to the SSH config file | `string` | no | No |
| `host` | Specifies the `Host` ssh_config(5) directive | `string` | yes | No |
| `hostname` | Hostname of the host | `string` | no | No |
| `knownHostsFile` | Path to the known hosts file | `string` | no | No |
| `port` | Port number to connect to | `uint16` | no | No |
| `proxyjump` | Proxy jump hosts, comma-separated | `string` | no | No |
| `password` | Password for SSH authentication | `string` | no | No |
| `privateKeyPath` | Path to the private key file | `string` | no | No |
| `privateKeyPassword` | Password for the private key file | `string` | no | Yes |
| `user` | Username for SSH authentication | `string` | no | No |
## exec host subcommand
Backy has a subcommand `exec host`. This subcommand takes the flags of `-m host1 -m host2`. For now these hosts need to be defined in the config file.
Backy has a subcommand `exec host`. This subcommand takes the flags of `-m host1 -m host2`. The commands can also be specified by `-c command1 -c command2`.

28
docs/content/config/notifications.md Normal file → Executable file
View File

@@ -39,23 +39,23 @@ There must be a section with an id (eg. `mail.test-svr`) following one of these
### mail
| key | description | type
| --- | --- | ---
| `host` | Specifies the SMTP host to connect to | `string`
| `port` | Specifies the SMTP port | `uint16`
| `senderaddress` | Address from which to send mail | `string`
| `to` | Recipients to send emails to | `[]string`
| `username` | SMTP username | `string`
| `password` | SMTP password | `string`
| key | description | type | External directive support |
| --- | --- | --- | --- |
| `host` | Specifies the SMTP host to connect to | `string` | no
| `port` | Specifies the SMTP port | `uint16` | no
| `senderaddress` | Address from which to send mail | `string` | no
| `to` | Recipients to send emails to | `[]string` | no
| `username` | SMTP username | `string` | no
| `password` | SMTP password | `string` | yes
### matrix
| key | description | type
| --- | --- | ---
| `home-server` | Specifies the Matrix server connect to | `string`
| `room-id` | Specifies the room ID of the room to send messages to | `string`
| `access-token` | Matrix access token | `string`
| `user-id` | Matrix user ID | `string`
| key | description | type | External directive support |
| --- | --- | ---| ---- |
| `home-server` | Specifies the Matrix server connect to | `string` | no
| `room-id` | Specifies the room ID of the room to send messages to | `string` | no
| `access-token` | Matrix access token | `string` | yes
| `user-id` | Matrix user ID | `string` | no
To get your access token (assumes you are using [Element](https://element.io/)) :

0
docs/content/config/remote-resources.md Normal file → Executable file
View File

14
docs/content/config/vault.md Normal file → Executable file
View File

@@ -6,7 +6,7 @@ description: Set up and configure vault.
[Vault](https://www.vaultproject.io/) is a tool for storing secrets and other data securely.
Vault config can be used by prefixing `vault:` in front of a password or ENV var.
A Vault key can be used by prefixing `%{vault:vault.keys.name}%` in a field that supports external directives.
This is the object in the config file:
@@ -18,10 +18,12 @@ vault:
keys:
- name: mongourl
mountpath: secret
key: data
path: mongo/url
type: # KVv1 or KVv2
- name:
path:
type:
mountpath:
type: KVv2 # KVv1 or KVv2
- name: someKeyName
mountpath: secret
key: keyData
type: KVv2
path: some/path
```

2
docs/content/examples/backy.yaml Normal file → Executable file
View File

@@ -71,7 +71,7 @@ hosts:
hostname: some-hostname
config: ~/.ssh/config
user: user
privatekeypath: /path/to/private/key
privateKeyPath: /path/to/private/key
port: 22
# can also be env:VAR
password: file:/path/to/file

0
docs/content/examples/example.yml Normal file → Executable file
View File

0
docs/content/getting-started/_index.md Normal file → Executable file
View File

8
docs/content/getting-started/config.md Normal file → Executable file
View File

@@ -124,13 +124,13 @@ notifications:
### Logging
cmd-std-out controls whether commands output is echoed to StdOut.
`cmd-std-out` controls whether commands output is echoed to StdOut.
If logfile is not defined, the log file will be written to the config directory in the file `backy.log`.
If `logfile` is not defined, the log file will be written to the config directory in the file `backy.log`.
`console-disabled` controls whether the logging messages are echoed to StdOut. Default is false.
`verbose` basically does nothing as all necessary info is already output.
`verbose` prints out debugging messages.
```yaml
logging:
@@ -144,7 +144,7 @@ logging:
[Vault](https://www.vaultproject.io/) can be used to get some configuration values and ENV variables securely.
```
```yaml
vault:
token: hvs.tXqcASvTP8wg92f7riyvGyuf
address: http://127.0.0.1:8200

0
docs/content/getting-started/install.md Normal file → Executable file
View File

0
docs/content/repositories/_index.md Normal file → Executable file
View File

4
docs/go.mod Normal file → Executable file
View File

@@ -3,6 +3,6 @@ module git.andrewnw.xyz/CyberShell/backy/docs
go 1.19
require (
github.com/McShelby/hugo-theme-relearn v0.0.0-20250103114405-80e448e5bdaa // indirect
github.com/divinerites/plausible-hugo v1.21.1 // indirect
github.com/McShelby/hugo-theme-relearn v0.0.0-20251115105808-d9ca8e8d8f59 // indirect
github.com/divinerites/plausible-hugo v1.22.0 // indirect
)

14
docs/go.sum Normal file → Executable file
View File

@@ -1,10 +1,4 @@
github.com/McShelby/hugo-theme-relearn v0.0.0-20230209073138-890d12ea922d h1:weq1mrQ/qNAvGrNgvZVL1K8adbT3bswZf2ABLr/LCIA=
github.com/McShelby/hugo-theme-relearn v0.0.0-20230209073138-890d12ea922d/go.mod h1:mKQQdxZNIlLvAj8X3tMq+RzntIJSr9z7XdzuMomt0IM=
github.com/McShelby/hugo-theme-relearn v0.0.0-20241210183303-16d4de84becf h1:bMx4kwM7Q+dAzvSOWs3XWZ25o+n4mI0GPHqzbzeWb3M=
github.com/McShelby/hugo-theme-relearn v0.0.0-20241210183303-16d4de84becf/go.mod h1:mKQQdxZNIlLvAj8X3tMq+RzntIJSr9z7XdzuMomt0IM=
github.com/McShelby/hugo-theme-relearn v0.0.0-20250102210630-dd0597ffa4b2 h1:sWaC1/dL65v3iRvblEAaBLpKC5TIT0R9JASk1hZNET8=
github.com/McShelby/hugo-theme-relearn v0.0.0-20250102210630-dd0597ffa4b2/go.mod h1:mKQQdxZNIlLvAj8X3tMq+RzntIJSr9z7XdzuMomt0IM=
github.com/McShelby/hugo-theme-relearn v0.0.0-20250103114405-80e448e5bdaa h1:G+OnMEzK4XOzbbcf1SmaGyOYJ0h5idp/IJdguWs8ioU=
github.com/McShelby/hugo-theme-relearn v0.0.0-20250103114405-80e448e5bdaa/go.mod h1:mKQQdxZNIlLvAj8X3tMq+RzntIJSr9z7XdzuMomt0IM=
github.com/divinerites/plausible-hugo v1.21.1 h1:ZTWwjhZ0PmLMacCVGlcGiYFEZW7VaYE767tchDskOug=
github.com/divinerites/plausible-hugo v1.21.1/go.mod h1:cxr+YB3FUwbLon8KCs4pV4Ankbkq6lJxTQUpNb5KqPo=
github.com/McShelby/hugo-theme-relearn v0.0.0-20251115105808-d9ca8e8d8f59 h1:mnEjz/Wrpv6Hea26KeFJPx94w9g9ZHIurUEWvPdaEvs=
github.com/McShelby/hugo-theme-relearn v0.0.0-20251115105808-d9ca8e8d8f59/go.mod h1:mKQQdxZNIlLvAj8X3tMq+RzntIJSr9z7XdzuMomt0IM=
github.com/divinerites/plausible-hugo v1.22.0 h1:2pZheSaIMc+EtwcEeZv0ioU2qBOEZa1Ii7IaR/9II9k=
github.com/divinerites/plausible-hugo v1.22.0/go.mod h1:cxr+YB3FUwbLon8KCs4pV4Ankbkq6lJxTQUpNb5KqPo=

19
docs/layouts/_default/baseof.html Normal file → Executable file
View File

@@ -1,7 +1,7 @@
<!DOCTYPE html>
{{- block "storeOutputFormat" . }}{{ end }}
{{- if .IsHome }}
{{- $hugoVersion := "0.126.0" }}
{{- $hugoVersion := "0.141.0" }}
{{- if lt hugo.Version $hugoVersion }}
{{- errorf "The Relearn theme requires Hugo %s or later" $hugoVersion }}
{{- end }}
@@ -36,12 +36,12 @@
{{ (printf $link (partial "permalink.gotmpl" (dict "to" .)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
{{- end }}
{{- end }}
{{- partialCached "favicon.html" . }}
{{- partial "stylesheet.html" . }}
{{- partial "dependencies.gotmpl" (dict "page" . "location" "header") }}
{{- partial "dependencies.html" (dict "page" . "location" "header") }}
{{- partial "custom-header.html" . }}
</head>
<body class="mobile-support {{ with .Store.Get "relearnOutputFormat" }}{{ . }}{{ else }}html{{ end }}{{- if .Site.Params.disableInlineCopyToClipBoard }} disableInlineCopyToClipboard{{ end }}{{- if .Site.Params.disableHoverBlockCopyToClipBoard }} disableHoverBlockCopyToClipBoard{{ end }}" data-url="{{ partial "permalink.gotmpl" (dict "to" .) }}">
<body class="mobile-support {{ with .Store.Get "relearnOutputFormat" }}{{ . }}{{ else }}html{{ end }}{{- if .Site.Params.disableHoverBlockCopyToClipBoard }} disableHoverBlockCopyToClipBoard{{ end }}" data-url="{{ partial "permalink.gotmpl" (dict "to" .) }}">
<div id="R-body" class="default-animation">
<div id="R-body-overlay"></div>
<nav id="R-topbar">
@@ -53,7 +53,7 @@
{{- $showBreadcrumb := (and (not .Params.disableBreadcrumb) (not .Site.Params.disableBreadcrumb)) }}
{{- if $showBreadcrumb }}
<ol class="topbar-breadcrumbs breadcrumbs highlightable" itemscope itemtype="http://schema.org/BreadcrumbList">
{{- partial "breadcrumbs.html" (dict "page" .) }}
{{- partial "breadcrumbs.html" (dict "page" . "schema" true) }}
</ol>
{{- else }}
<span class="topbar-breadcrumbs highlightable">
@@ -74,11 +74,8 @@
{{- partial "custom-comments.html" . }}
</div>
{{- block "menu" . }}{{ end }}
{{- $assetBusting := partialCached "assetbusting.gotmpl" . }}
<script src="{{"js/clipboard.min.js" | relURL}}{{ $assetBusting }}" defer></script>
<script src="{{"js/perfect-scrollbar.min.js" | relURL}}{{ $assetBusting }}" defer></script>
{{- partial "dependencies.gotmpl" (dict "page" . "location" "footer") }}
<script src="{{"js/theme.js" | relURL}}{{ $assetBusting }}" defer></script>
{{- partial "dependencies.html" (dict "page" . "location" "footer") }}
{{- partial "custom-footer.html" . }}
<div id="toast-container" role="status" aria-live="polite" aria-atomic="false"></div>
</body>
</html>
</html>

0
docs/layouts/partials/logo.html Normal file → Executable file
View File

0
docs/layouts/shortcodes/code.html Normal file → Executable file
View File

0
docs/vangen.json Normal file → Executable file
View File

0
docs/vangen/backy/index.html Normal file → Executable file
View File

18
examples/backy.yaml Normal file → Executable file
View File

@@ -29,20 +29,22 @@ commands:
update-docker:
type: package
shell: zsh # best to run package commands in a shell
packageName: docker-ce
Args:
- docker-ce-cli
packages:
- name: docker-ce
version: latest
- name: docker-ce-cli
version: latest
packageManager: apt
packageOperation: install
update-dockerApt:
# type: package
shell: zsh
cmd: apt
Args:
- update
- "&&"
- apt install -y docker-ce
- docker-ce-cli
packages:
- name: docker-ce
version: latest
- name: docker-ce-cli
version: latest
packageManager: apt
packageOperation: install

3
examples/example.yml Normal file → Executable file
View File

@@ -7,7 +7,8 @@ commands:
- down
# if host is not defined, command will be run locally
# The host has to be defined in either the config file or the SSH Config files
host: some-host
hosts:
- prod
hooks:
error:
- some-other-command-when-failing

0
frontmatter.json Normal file → Executable file
View File

92
go.mod Normal file → Executable file
View File

@@ -1,78 +1,78 @@
module git.andrewnw.xyz/CyberShell/backy
go 1.23
go 1.23.0
toolchain go1.23.6
replace git.andrewnw.xyz/CyberShell/backy => /home/andrew/Projects/backy
toolchain go1.23.7
require (
github.com/aws/aws-sdk-go-v2/service/s3 v1.76.0
github.com/aws/aws-sdk-go-v2/service/s3 v1.83.0
github.com/dmarkham/enumer v1.5.11
github.com/go-co-op/gocron v1.37.0
github.com/hashicorp/vault/api v1.15.0
github.com/google/uuid v1.6.0
github.com/hashicorp/vault/api v1.20.0
github.com/joho/godotenv v1.5.1
github.com/kevinburke/ssh_config v1.2.0
github.com/knadh/koanf/parsers/yaml v0.1.0
github.com/knadh/koanf/providers/rawbytes v0.1.0
github.com/knadh/koanf/v2 v2.1.2
github.com/knadh/koanf/parsers/yaml v1.1.0
github.com/knadh/koanf/providers/rawbytes v1.0.0
github.com/knadh/koanf/v2 v2.2.2
github.com/mattn/go-isatty v0.0.20
github.com/minio/minio-go/v7 v7.0.84
github.com/minio/minio-go/v7 v7.0.94
github.com/mitchellh/go-homedir v1.1.0
github.com/nikoksr/notify v1.3.0
github.com/pkg/errors v0.9.1
github.com/pkg/sftp v1.13.7
github.com/rs/zerolog v1.33.0
github.com/pkg/sftp v1.13.9
github.com/rs/zerolog v1.34.0
github.com/sethvargo/go-password v0.3.1
github.com/spf13/cobra v1.8.1
golang.org/x/crypto v0.33.0
github.com/spf13/cobra v1.9.1
golang.org/x/crypto v0.40.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v3 v3.0.1
maunium.net/go/mautrix v0.23.0
mvdan.cc/sh/v3 v3.10.0
maunium.net/go/mautrix v0.24.1
mvdan.cc/sh/v3 v3.12.0
)
require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.36.1 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.8 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.32 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.32 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.32 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.5.6 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.13 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.13 // indirect
github.com/aws/smithy-go v1.22.2 // indirect
github.com/aws/aws-sdk-go-v2 v1.36.5 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.36 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.36 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.36 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.17 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.17 // indirect
github.com/aws/smithy-go v1.22.4 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/go-jose/go-jose/v4 v4.0.1 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/go-jose/go-jose/v4 v4.1.1 // indirect
github.com/go-viper/mapstructure/v2 v2.3.0 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.9 // indirect
github.com/hashicorp/go-secure-stdlib/parseutil v0.2.0 // indirect
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
github.com/hashicorp/go-sockaddr v1.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl v1.0.1-vault-7 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/knadh/koanf/maps v0.1.2 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/minio/crc64nvme v1.0.2 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/pascaldekloe/name v1.0.0 // indirect
github.com/pascaldekloe/name v1.0.1 // indirect
github.com/philhofer/fwd v1.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/rs/xid v1.6.0 // indirect
@@ -84,14 +84,16 @@ require (
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
go.mau.fi/util v0.8.4 // indirect
github.com/tinylib/msgp v1.3.0 // indirect
go.mau.fi/util v0.8.8 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3 // indirect
golang.org/x/mod v0.23.0 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/time v0.10.0 // indirect
golang.org/x/tools v0.30.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/exp v0.0.0-20250711185948-6ae5c78190dc // indirect
golang.org/x/mod v0.26.0 // indirect
golang.org/x/net v0.42.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.34.0 // indirect
golang.org/x/text v0.27.0 // indirect
golang.org/x/time v0.12.0 // indirect
golang.org/x/tools v0.35.0 // indirect
)

Some files were not shown because too many files have changed in this diff Show More