2020-12-21 15:43:24 +00:00
|
|
|
{
|
|
|
|
"builders": [
|
|
|
|
{
|
|
|
|
"type": "digitalocean",
|
|
|
|
"image": "ubuntu-18-04-x64",
|
|
|
|
"region": "nyc1",
|
|
|
|
"size": "s-1vcpu-1gb",
|
2021-01-07 15:52:51 +00:00
|
|
|
"snapshot_name": "packer-syncthing-{{timestamp}}",
|
2020-12-21 15:43:24 +00:00
|
|
|
"ssh_username": "root"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"provisioners": [
|
2020-12-29 20:20:26 +00:00
|
|
|
{
|
|
|
|
"type": "shell",
|
|
|
|
"inline": [
|
2020-12-31 19:19:27 +00:00
|
|
|
"sudo apt-get update",
|
|
|
|
"sudo apt-get install -y bindfs",
|
2020-12-29 20:20:26 +00:00
|
|
|
"sudo useradd -m syncthing",
|
|
|
|
"sudo mkdir -p /mnt/syncthing-volume",
|
2020-12-31 19:19:27 +00:00
|
|
|
"sudo mkdir -p /mnt/syncthing",
|
2020-12-29 20:20:26 +00:00
|
|
|
"sudo echo \"/dev/disk/by-label/syncthing-volume /mnt/syncthing-volume ext4 defaults,nofail,discard,noatime 0 2\" >> /etc/fstab",
|
2020-12-31 19:19:27 +00:00
|
|
|
"sudo echo \"/mnt/syncthing-volume /mnt/syncthing fuse.bindfs force-user=syncthing,force-group=syncthing 0 0\" >> /etc/fstab",
|
2020-12-29 20:20:26 +00:00
|
|
|
"sudo findmnt --verify --verbose"
|
|
|
|
]
|
|
|
|
},
|
2020-12-21 15:43:24 +00:00
|
|
|
{
|
|
|
|
"type": "file",
|
|
|
|
"source": "syncthing@.service",
|
|
|
|
"destination": "/tmp/syncthing@.service"
|
|
|
|
},
|
2020-12-29 20:20:26 +00:00
|
|
|
{
|
|
|
|
"type": "file",
|
|
|
|
"source": "syncthing-config.xml",
|
|
|
|
"destination": "/tmp/syncthing-config.xml"
|
|
|
|
},
|
2020-12-31 03:22:18 +00:00
|
|
|
{
|
|
|
|
"type": "file",
|
|
|
|
"source": "syncthing-cert.pem",
|
|
|
|
"destination": "/tmp/syncthing-cert.pem"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "file",
|
|
|
|
"source": "syncthing-key.pem",
|
|
|
|
"destination": "/tmp/syncthing-key.pem"
|
|
|
|
},
|
2020-12-21 15:43:24 +00:00
|
|
|
{
|
|
|
|
"type": "shell",
|
|
|
|
"inline": [
|
|
|
|
"curl -s https://syncthing.net/release-key.txt | sudo apt-key add -",
|
|
|
|
"echo \"deb https://apt.syncthing.net/ syncthing stable\" | sudo tee /etc/apt/sources.list.d/syncthing.list",
|
|
|
|
"sudo apt-get update",
|
|
|
|
"sudo apt-get install -y syncthing",
|
2020-12-29 20:20:26 +00:00
|
|
|
"sudo mkdir -p /home/syncthing/.config/syncthing",
|
|
|
|
"sudo mv /tmp/syncthing-config.xml /home/syncthing/.config/syncthing/config.xml",
|
2020-12-31 03:22:18 +00:00
|
|
|
"sudo mv /tmp/syncthing-cert.pem /home/syncthing/.config/syncthing/cert.pem",
|
|
|
|
"sudo mv /tmp/syncthing-key.pem /home/syncthing/.config/syncthing/key.pem",
|
2020-12-29 20:20:26 +00:00
|
|
|
"sudo chown -R syncthing:syncthing /home/syncthing/.config/syncthing",
|
2020-12-21 15:43:24 +00:00
|
|
|
"sudo mv /tmp/syncthing@.service /etc/systemd/system/syncthing@.service",
|
|
|
|
"sudo systemctl daemon-reload",
|
|
|
|
"sudo systemctl enable syncthing@syncthing"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "file",
|
|
|
|
"source": "syncthing.conf",
|
|
|
|
"destination": "/tmp/syncthing.conf"
|
|
|
|
},
|
2020-12-31 16:04:47 +00:00
|
|
|
{
|
|
|
|
"type": "file",
|
|
|
|
"source": "certbot/live/syncthing.jeremydormitzer.com/fullchain.pem",
|
|
|
|
"destination": "/tmp/https-cert.pem"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "file",
|
|
|
|
"source": "certbot/live/syncthing.jeremydormitzer.com/privkey.pem",
|
|
|
|
"destination": "/tmp/https-key.pem"
|
|
|
|
},
|
2020-12-21 15:43:24 +00:00
|
|
|
{
|
|
|
|
"type": "shell",
|
|
|
|
"inline": [
|
|
|
|
"sudo apt-get install -y nginx",
|
|
|
|
"sudo mv /tmp/syncthing.conf /etc/nginx/sites-available/syncthing.conf",
|
2020-12-31 16:04:47 +00:00
|
|
|
"sudo mv /tmp/https-cert.pem /home/syncthing/.config/syncthing/https-cert.pem",
|
|
|
|
"sudo mv /tmp/https-key.pem /home/syncthing/.config/syncthing/https-key.pem",
|
|
|
|
"sudo chown -R syncthing:syncthing /home/syncthing/.config/syncthing",
|
2020-12-21 15:43:24 +00:00
|
|
|
"sudo ln -s /etc/nginx/sites-available/syncthing.conf /etc/nginx/sites-enabled/",
|
|
|
|
"sudo unlink /etc/nginx/sites-enabled/default",
|
|
|
|
"sudo systemctl enable nginx"
|
|
|
|
]
|
|
|
|
}
|
2020-12-31 16:04:47 +00:00
|
|
|
],
|
|
|
|
"post-processors": [
|
|
|
|
{
|
|
|
|
"type": "manifest"
|
|
|
|
}
|
2020-12-21 15:43:24 +00:00
|
|
|
]
|
|
|
|
}
|