Bash script to download and run the weeve-agent.
(For registering with the script) The Github personal access key is required to download the contents for the agents.
Please make sure:
- You have a Github Personal Access Token
- There is a file named .weeve-agent-secret in the local
- The above mentioned file contains the token (token pasted into the file)
- Set the value of the argument "token", with the path of the above mentioned file
curl -s https://raw.githubusercontent.com/weeveiot/weeve-agent-installer/dev/weeve-agent-installer.sh > weeve-agent-installer.sh
sudo sh weeve-agent-installer.sh token=<path to the secret file> nodename=<name of the node>
curl -s https://raw.githubusercontent.com/weeveiot/weeve-agent-installer/dev/weeve-agent-uninstaller.sh | sudo sh
- Install docker docker installation
- Make a folder in the home folder
mkdir weeve-agent
- Copy the agent to the instance
- scp -i ~/.ssh/agent-testing.pem "ubuntu@:/home/ubuntu/weeve-agent"
- Make it executable
chmod u+x weeve-agent/<agent-binary-name>
- Similarly, copy the configuration and bootstrap certificates to the instance, same folder
- To run the agent in the foreground
./weeve-agent/<agent-binary-name> -v --broker tls://asnhp33z3nubs-ats.iot.us-east-1.amazonaws.com:8883 --subClientId nodes/awsdev --pubClientId manager/awsdev --publish status --heartbeat 30 --name <name-of-the-node>
- To run the agent as systemd service
- Add it to the configuration
echo "ARG_NODENAME=--name <name-of-the-node>" >> ./weeve-agent/weeve-agent.argconf
- Add the following to weeve-agent.service
echo "WorkingDirectory=/home/ubuntu/weeve-agent" >> ./weeve-agent/weeve-agent.service
echo "ExecStart=/home/ubuntu/weeve-agent/<agent-binary-name> $ARG_VERBOSE $ARG_BROKER $ARG_SUB_CLIENT $ARG_PUB_CLIENT $ARG_PUBLISH $ARG_HEARTBEAT $ARG_NODENAME" >> ./weeve-agent/weeve-agent.service
- Move weeve-agent.service
sudo mv weeve-agent/weeve-agent.service /lib/systemd/system/
- Move weeve-agent.argconf
sudo mv weeve-agent/weeve-agent.argconf /lib/systemd/system/
- Enable the service to start at start-up
sudo systemctl enable weeve-agent
- Start the service
sudo systemctl start weeve-agent
- Add it to the configuration
Upon first execution;
The weeve agent bootstraps.
The thing name will be the environment followed by the ID, for example; awsdev_f5adbd1a-d4b7-4485-b5f4-2b901a92c80f
.
The certificate is created and uploaded to S3
It is possible to run multiple instances of the weeve agent in a single host. Each process would be running independently and be bootstrapped with as a dedicated IoT thing.
To delete the IoT thing, call the API - deleteNode. This will remove the following:
- Things from IoT core
- Node and deployments from DB
- Certificate from s3 bucket