func Populate(dirPath string, hostnameMap map[string]net.IP) error {
	var err error
	dirPath, err = expandDirPath(dirPath)
	if err != nil {
		return err
	}
	logrus.Debugf("populating state dir %q", dirPath)
	if err = os.MkdirAll(dirPath, 0755); err != nil {
		return err
	}
	hostsFilePath := filepath.Join(dirPath, "hosts")
	if err = etchosts.Populate(hostsFilePath, hostnameMap, ""); err != nil {
		return err
	}
	hostAliasesFilePath := filepath.Join(dirPath, "hostaliases")
	hostAliasesFile, err := os.Create(hostAliasesFilePath)
	if err != nil {
		return err
	}
	defer hostAliasesFile.Close()
	if err = hostaliases.Populate(hostAliasesFile, hostaliases.DefaultFQDNBackend, hostnameMap); err != nil {
		return err
	}
	readmeMDFilePath := filepath.Join(dirPath, "README.md")
	if err = os.WriteFile(readmeMDFilePath, []byte(readmeMD), 0644); err != nil {
		return err
	}
	return nil
}
Populate populates the state dir.
When the dir path is empty, it is interpreted as "~/.norouter/agent".
The dir path is expanded using ../filepathutil.Expand .

The following files are created in the directory: "hosts", "hostaliases", "README.md"
package statedir
import (
	"errors"
	"net"
	"os"
	"os/user"
	"path/filepath"
	"github.com/norouter/norouter/pkg/agent/etchosts"
	"github.com/norouter/norouter/pkg/agent/filepathutil"
	"github.com/norouter/norouter/pkg/agent/hostaliases"
	"github.com/sirupsen/logrus"
)
const readmeMD = `# NoRouter agent state directory
This directory was created by NoRouter agent.
You can safely remove this directory if NoRouter is not running.
Files in this directory:
- README.md:    This file
- hosts:        Can be used as /etc/hosts
- hostaliases:  Can be used as $HOSTALIASES
## About "hosts" file:
The hosts file can be used as /etc/hosts if you copy to there manually.
To write /etc/hosts automatically, set .[]hosts.writeEtcHosts in the manifest file.
## About "hostaliases" file
The hostaliases file can be used as $HOSTALIASES if supported by applications.
Note that the file does not contain virtual hostnames with dots, such as "host1.norouter.local".
See hostname(7).
## Changing the path of this directory
Set .[]hosts.stateDir.pathOnAgent in the manifest file.
To disallow creating this directory, set .[]hosts.stateDir.disable to true.
- - -
For further information, see https: 
`