Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/preetam/ifstated-conf-gen
https://github.com/preetam/ifstated-conf-gen
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/preetam/ifstated-conf-gen
- Owner: Preetam
- Created: 2014-03-03T19:31:30.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-03-04T03:36:45.000Z (almost 11 years ago)
- Last Synced: 2024-11-10T00:38:57.813Z (3 months ago)
- Language: Go
- Size: 125 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ifstated-conf-gen
====This is a really simple tool to generate `/etc/ifstated.conf` files on OpenBSD.
Usage
---
First, create a JSON with the necessary fields. An example is provided as `example.json`:```json
{
"Device": "em0",
"Vlans": [
{
"Id": 1,
"Address": "10.0.0.1",
"Netmask": "255.255.255.0"
},
{
"Id": 2,
"Address": "10.0.1.1",
"Netmask": "255.255.255.0"
}
]
}
```All you have to do is pipe the JSON configuration and the generated `ifstated.conf` file
will be printed to stdout.`$ cat example.json | go run main.go template.go`
```
# This file is generated automatically. DO NOT EDIT.
init-state auto
fw_carp_up = "carp0.link.up"
fw_carp_init = "carp0.link.unknown"state auto {
if ($fw_carp_init)
run "sleep 10"
if ($fw_carp_up)
set-state fw_master
if (! $fw_carp_up)
set-state fw_slave
}state fw_master {
init {
run "ifconfig em0 up"
run "ifconfig vlan1 create"
run "ifconfig vlan1 10.0.0.1 netmask 255.255.255.0 vlan 1 vlandev em0"
run "ifconfig vlan2 create"
run "ifconfig vlan2 10.0.1.1 netmask 255.255.255.0 vlan 2 vlandev em0"
}if ($fw_carp_init) {
run "sleep 2"
}
if (! $fw_carp_up)
set-state fw_slave
}state fw_slave {
init {
run "ifconfig vlan1 destroy"
run "ifconfig vlan2 destroy"
run "ifconfig em0 down"
}if ($fw_carp_init)
run "sleep 2"
if ($fw_carp_up)
set-state fw_master
}
```Of course, you can also build a dependency-free binary and deploy it across
all of your servers:`$ go build`
License
---
MIT