localdevices / libre360

GNU Affero General Public License v3.0
17 stars 5 forks source link

Change deployment process to allow for updating of child pi ID #152

Closed smathermather closed 3 years ago

smathermather commented 3 years ago

Setting up a child pi takes a lot of time. For a 7-8 camera rig, the process might take 4-8 hours, including downloading updates. The process can be particularly slow if run on a pi0, which is the recommended platform.

Child Pi deployment scripts currently generate an identity for they pi and set that to hostname, etc.. This means that simple cloning of the SD isn't enough to speed up the above process. We need to deploy each and every time, which can be 30-60 minutes per pi. For simplicity, the generation of an ID on deployment makes sense, but we should add a script which will regenerate the pi id.

smathermather commented 3 years ago

child_pi_setup.sh calls provisioning/database_setup_child.sh for this in the deployment process currently. provisioning/database_setup_child.sh runs provisioning/dbase_child.sql which does lots of stuff, including setting the UUID and setting the hostname and hosts file using this info:

# retrieve the child's uuid and change the hostname of child accordingly
hostname_prefix=`sudo -u postgres psql -d odm360 -t -c "SELECT (device_uuid) FROM device;"`
echo $hostname_prefix | sudo tee /etc/hostname
sudo sed -i "s/raspberrypi/$hostname_prefix/g" /etc/hosts

So to run an update, we need to:

  1. Query the current hostname prefix
  2. Truncate the device table
  3. Update the device table with a new ID
  4. Use the new hostname prefix to update /etc/hostname and /etc/hosts
smathermather commented 3 years ago

Ok, pull request to patch: https://github.com/OpenDroneMap/odm360/pull/153

hcwinsemius commented 3 years ago

Suggestion: give the child a unique id once it connects to a parent the first time. In this way we can ensure we can use ready-made images for SD cards instead of a tedious install process requiring logging into pis.

smathermather commented 3 years ago

I would say this is complete with https://github.com/localdevices/odm360/blob/main/child_pi_setup_rename.sh, but we should open a separate issue for API triggering of changes to child pi.