Switch config file to yaml
This commit is contained in:
parent
2b06810bd7
commit
8879463cb9
@ -27,7 +27,7 @@ type cmdOptions struct {
|
|||||||
func parseCmdOptions() cmdOptions {
|
func parseCmdOptions() cmdOptions {
|
||||||
var o cmdOptions
|
var o cmdOptions
|
||||||
flag.StringVar(&o.cmd, "cmd", CMD_SERVE, "Mode to run command in ("+CMD_SERVE+","+CMD_SPINDOWNALL+")")
|
flag.StringVar(&o.cmd, "cmd", CMD_SERVE, "Mode to run command in ("+CMD_SERVE+","+CMD_SPINDOWNALL+")")
|
||||||
flag.StringVar(&o.config, "config", "dospin.json", "Path to the dospin config file")
|
flag.StringVar(&o.config, "config", "dospin.yaml", "Path to the dospin config file")
|
||||||
flag.StringVar(&o.logFile, "logFile", "stdout", "Path to the dospin log file")
|
flag.StringVar(&o.logFile, "logFile", "stdout", "Path to the dospin log file")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
return o
|
return o
|
||||||
|
20
dospin.json
20
dospin.json
@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"ApiToken": "<your token here>",
|
|
||||||
"Servers": {
|
|
||||||
"minecraft": {
|
|
||||||
"Ports": [25565],
|
|
||||||
"UsePublicIP": false,
|
|
||||||
"InitialSize": "4gb",
|
|
||||||
"Size": "4gb",
|
|
||||||
"Region": "nyc1",
|
|
||||||
"SshKeys": [
|
|
||||||
"Key1",
|
|
||||||
"gtalent2@gmail.com"
|
|
||||||
],
|
|
||||||
"UsePersistentImage": false,
|
|
||||||
"ImageSlug": "ubuntu-16-04-x64",
|
|
||||||
"Volumes": ["volume-nyc1-01"],
|
|
||||||
"UserData": "#!/bin/bash\napt-get update\napt-get install -y docker.io\nmkdir -p /mnt/volume-nyc1-01\nmount -o discard,defaults /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01 /mnt/volume-nyc1-01\necho /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01 /mnt/volume-nyc1-01 ext4 defaults,nofail,discard 0 0 | tee -a /etc/fstab\ndocker run -d --restart=always -p 25565:25565 -v /mnt/volume-nyc1-01/minecraft-server:/minecraft-server -w /minecraft-server -t java:8-alpine sh start.sh"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
26
dospin.yaml
Normal file
26
dospin.yaml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
api_token: <your token here>
|
||||||
|
servers:
|
||||||
|
minecraft:
|
||||||
|
ports:
|
||||||
|
- 25565
|
||||||
|
use_public_ip: false
|
||||||
|
initial_size: 4gb
|
||||||
|
size: 4gb
|
||||||
|
region: nyc1
|
||||||
|
ssh_keys:
|
||||||
|
- Key1
|
||||||
|
- gtalent2@gmail.com
|
||||||
|
use_persistent_image: false
|
||||||
|
image_slug: ubuntu-16-04-x64
|
||||||
|
volumes:
|
||||||
|
- volume-nyc1-01
|
||||||
|
user_data: |-
|
||||||
|
#!/bin/bash
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y docker.io
|
||||||
|
mkdir -p /mnt/volume-nyc1-01
|
||||||
|
mount -o discard,defaults /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01 /mnt/volume-nyc1-01
|
||||||
|
echo /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01 /mnt/volume-nyc1-01 ext4 defaults,nofail,discard 0 0 | tee -a /etc/fstab
|
||||||
|
docker run -d --restart=always -p 25565:25565 -v /mnt/volume-nyc1-01/minecraft-server:/minecraft-server -w /minecraft-server -t java:8-alpine sh start.sh
|
||||||
|
|
29
settings.go
29
settings.go
@ -8,26 +8,27 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"gopkg.in/yaml.v2"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
ApiToken string
|
ApiToken string `yaml:"api_token"`
|
||||||
Servers map[string]Server
|
Servers map[string]Server `yaml:"servers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
Ports []int
|
Ports []int `yaml:"ports"`
|
||||||
UsePublicIP bool
|
ActivityTimeoutMin int `yaml:"activity_timeout_min"`
|
||||||
InitialSize string
|
UsePublicIP bool `yaml:"use_public_ip"`
|
||||||
Size string
|
InitialSize string `yaml:"initial_size"`
|
||||||
Region string
|
Size string `yaml:"size"`
|
||||||
UsePersistentImage bool
|
Region string `yaml:"region"`
|
||||||
ImageSlug string
|
UsePersistentImage bool `yaml:"use_persistent_image"`
|
||||||
UserData string
|
ImageSlug string `yaml:"image_slug"`
|
||||||
SshKeys []string
|
UserData string `yaml:"user_data"`
|
||||||
Volumes []string
|
SshKeys []string `yaml:"ssh_keys"`
|
||||||
|
Volumes []string `yaml:"volumes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadSettings(path string) (Settings, error) {
|
func loadSettings(path string) (Settings, error) {
|
||||||
@ -37,7 +38,7 @@ func loadSettings(path string) (Settings, error) {
|
|||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(data, &s)
|
err = yaml.Unmarshal(data, &s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user