.. _automation: ========== Automation ========== Instructions to create automatic data uploads from your plant to SunPeek. The following assumes: - You are running as a non root user which has read write access to the directory where the plant data is stored and sudo permissions - The machine you are running on has outbound internet access - You start the instructions in a shell in the user's home directory 1. Run ``ls -a`` and see if ``.ssh`` appears in the output. If not run ``mkdir .ssh`` 2. ``cd .ssh`` 3. Run ``ssh-keygen -t ed25519 -f sunpeek-upload-key``. Then press enter twice to save the key without a password. This will create a public-private keypair. Public key will be saved as sunpeek-upload-key.pub, the private key as sunpeek-upload-key and this must be kept confidential. 4. Restrict permissions on the private key: ``chmod 600 sunpeek-upload-key`` 5. Type ``cat sunpeek-upload-key.pub`` to get the public key, and send it in an email. DO NOT send us sunpeek-upload-key, the private key! Wait for us to confirm that the server is configured with your public key before continuing. ---- .. note:: Text between < > in steps 6 and 8 should be replaced by your own values. 6. Run ``cd ``. 7. Test the data transfer. Run ``rsync -rtPzv -e "ssh -i ~/.ssh/sunpeek-upload-key" ./ your_plant@data-upload.sunpeek.org:./``. This command sends any files which are new or changed to the SunPeek data upload server. You should see a list of transferred files. 8. Configure a cronjob to run the transfer daily: Run ``crontab -e`` and enter this to configure crontab to run the transfer every hour: ``0 * * * * rsync -rtPz -e "ssh -i ~/.ssh/sunpeek-upload-key" your_plant@data-upload.sunpeek.org:./ > /tmp/sunpeek_cronjob_log.txt 2>&1``. Close the file, saving changes to the proposed filename.