Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct {
// AppPath is the path to the application binary.
AppPath string
// ID is the ID of the agent.
ID uuid.UUID
// Host is the hostname of the vakeel server.
Host string
// Port is the port of the vakeel server.
Port int
}
Data contains the data used to fill the stub agent template.
type ServiceGenerator ¶
type ServiceGenerator struct {
// contains filtered or unexported fields
}
ServiceGenerator is a template for creating stub agents.
It contains the data used to fill the stub agent template.
func New ¶
New creates a new ServiceGenerator instance with the given ID, host, and port.
Parameters: - id: The ID of the agent. - host: The hostname of the vakeel server. - port: The port of the vakeel server.
Returns: - *ServiceGenerator: A pointer to the ServiceGenerator instance. - error: An error if any.
func (*ServiceGenerator) Register ¶
func (t *ServiceGenerator) Register() error
Register registers the stub agent service file based on the operating system.
This function calls the generate function to generate the stub agent service file. Then, it checks if the operating system supports systemd or is OpenWrt. If it does, it enables and starts the service using the systemctl or /etc/init.d/vakeel commands respectively. If the operating system is neither OpenWrt nor supports systemd, it returns an error indicating that the operating system is unsupported.
Returns:
error: An error if the operating system is unsupported or if there is an error enabling or starting the service. Nil if the registration is successful.