@@ -10,29 +10,31 @@ import (
1010)
1111
1212type awsTerraform struct {
13- Name string
14- Region string
15- InstanceType string
16- ConfigPath string
17- PubKeyPath string
18- PriKeyPath string
19- AccessKey string
20- SecretKey string
21- IPFS string
13+ Name string
14+ Region string
15+ InstanceType string
16+ ConfigPath string
17+ PubKeyPath string
18+ PriKeyPath string
19+ AccessKey string
20+ SecretKey string
21+ ServiceFile string
22+ LatestVersion string
2223}
2324
2425// tfConfig generates the terraform config file for deploying to AWS.
25- func (p providerAws ) tfConfig (name , region , instance , ipfs string ) error {
26+ func (p providerAws ) tfConfig (name , region , instance , latestVersion string ) error {
2627 tf := awsTerraform {
27- Name : name ,
28- Region : region ,
29- InstanceType : instance ,
30- ConfigPath : fmt .Sprintf ("~/.darknode/darknodes/%v/config.json" , name ),
31- PubKeyPath : fmt .Sprintf ("~/.darknode/darknodes/%v/ssh_keypair.pub" , name ),
32- PriKeyPath : fmt .Sprintf ("~/.darknode/darknodes/%v/ssh_keypair" , name ),
33- AccessKey : p .accessKey ,
34- SecretKey : p .secretKey ,
35- IPFS : ipfs ,
28+ Name : name ,
29+ Region : region ,
30+ InstanceType : instance ,
31+ ConfigPath : fmt .Sprintf ("~/.darknode/darknodes/%v/config.json" , name ),
32+ PubKeyPath : fmt .Sprintf ("~/.darknode/darknodes/%v/ssh_keypair.pub" , name ),
33+ PriKeyPath : fmt .Sprintf ("~/.darknode/darknodes/%v/ssh_keypair" , name ),
34+ AccessKey : p .accessKey ,
35+ SecretKey : p .secretKey ,
36+ ServiceFile : darknodeService ,
37+ LatestVersion : latestVersion ,
3638 }
3739
3840 t , err := template .New ("aws" ).Parse (awsTemplate )
@@ -156,12 +158,20 @@ resource "aws_instance" "darknode" {
156158 provisioner "remote-exec" {
157159
158160 inline = [
159- "wget -O darknode.gz {{.IPFS}} ",
160- "tar -zxvf darknode.gz ",
161- "mkdir -p $HOME/.darknode ",
161+ "set -x ",
162+ "mkdir -p $HOME/.darknode/bin ",
163+ "mkdir -p $HOME/.config/systemd/user ",
162164 "mv $HOME/config.json $HOME/.darknode/config.json",
163- "./install.sh",
164- "rm -r darknode.gz bin config install.sh",
165+ "curl -sL https://www.github.com/renproject/darknode-release/releases/latest/download/darknode > ~/.darknode/bin/darknode",
166+ "chmod +x ~/.darknode/bin/darknode",
167+ "echo {{.LatestVersion}} > ~/.darknode/version",
168+ <<EOT
169+ echo "{{.ServiceFile}}" > ~/.config/systemd/user/darknode.service
170+ EOT
171+ ,
172+ "loginctl enable-linger darknode",
173+ "systemctl --user enable darknode.service",
174+ "systemctl --user start darknode.service",
165175 ]
166176
167177 connection {
0 commit comments