dotsetup is a library for seting up dotfiles.
This library use sudo
& curl
command internally.
This library setup dotfiles by combining task
and finally executing all tasks..
task
represents execution entity corresponding one line shell command.
For exmaple, dotsetup.Curl
corresponds to curl
command.
This sample executes series of process to
- install
sample-package
- fetch
index.html
fromexample.com
import (
"github.com/moba1/dotsetup/v3"
"log"
)
// set `sample-package` installing task
sp := dotsetup.Package{
Name: "sample-package"
}
// set fetching index.html to /tmp
c := dotsetup.Curl{
Args: []string{"-o", "/tmp/index.html", "https://example.com/index.html"}
}
// execute all tasks
// order: sp -> c
s := dotsetup.NewScript([]dotsetup.Task{sp, c})
// enable debug mode
s.Debug = true
if err := s.Execute("sudo password"); err != nil {
log.Fatal(err)
}
$ go test -v ./...
Success of this test will be determined by the environment. Now, test supported OS are
- Debian
- CentOS (8~)
- Fedora
- Arch Linux
- OpenSUSE tumbleweed/leap
- Ubuntu
- Gentoo
task
represents shell command.
install package.
Property | type | description |
---|---|---|
Name | string | target package name |
import "github.com/moba1/dotsetup/v3"
// install `sample-package`
p := dotsetup.Package{
Name: "sample-package"
}
This task represents curl
command.
Property | type | description |
---|---|---|
Args | []string | curl command arguments |
import "github.com/moba1/dotsetup/v3"
// execute `curl -o /tmp/sample.txt https://github.com`
c := dotsetup.Curl{
Args: []string{
"-o", "/tmp/sample.txt", "https://github.com"
}
}
create directory.
Property | type | description |
---|---|---|
Path | string | directory path |
Mode | string | directory mode |
import "github.com/moba1/dotsetup/v3"
// create `/tmp/directory` directory with mode "rwxr-xr-x"
d := dotsetup.Directory{
Path: "/tmp/directory"
Mode: "755"
}
execute shell command.
Property | type | description |
---|---|---|
RawCommands | []dotsetup.ExecuteCommand | shell commands |
import "github.com/moba1/dotsetup/v3"
// execute `sudo -S ls -l`
e := dotsetup.Execute{
RawCommands: []dotsetup.ExecuteCommand{
RawCommand: dotsetup.RawCommand{"ls", "-l"},
DoRoot: true
},
}
create symbolic link.
Property | type | description |
---|---|---|
Source | string | source path |
Destination | string | destination path |
Force | set force mode |
import "github.com/moba1/dotsetup/v3"
// put symbolic link from `/dev/null` to `/tmp/null`
l := dotsetup.Link{
Source: "/dev/null"
Destination: "/tmp/null"
Force: true
}
Os
var is os name.
If runtime is Linux, Os
var is equal to /etc/os-release
's ID
var.
In other runtime, equal to runtime.GOOS
.