diff --git a/workspace/scripts/06-install-pioreactor.sh b/workspace/scripts/06-install-pioreactor.sh index d60e2c9..4325073 100644 --- a/workspace/scripts/06-install-pioreactor.sh +++ b/workspace/scripts/06-install-pioreactor.sh @@ -86,7 +86,9 @@ common: EOT + sudo chown pioreactor:pioreactor $PIO_DIR/experiment_profiles/demo_logging_example.yaml +sudo -u $USERNAME touch $PIO_DIR/unit_config.ini if [ "$LEADER" == "1" ]; then @@ -102,7 +104,6 @@ fi if [ "$WORKER" == "1" ]; then - sudo -u $USERNAME touch $PIO_DIR/unit_config.ini sudo apt-get install -y python3-numpy if [ "$PIO_VERSION" == "develop" ]; then diff --git a/workspace/scripts/files/bash/firstboot_leader.sh b/workspace/scripts/files/bash/firstboot_leader.sh index 8709051..a6ed71d 100644 --- a/workspace/scripts/files/bash/firstboot_leader.sh +++ b/workspace/scripts/files/bash/firstboot_leader.sh @@ -9,6 +9,7 @@ USERNAME=pioreactor PIO_DIR=/home/$USERNAME/.pioreactor SSH_DIR=/home/$USERNAME/.ssh DB_LOC=$(crudini --get $PIO_DIR/config.ini storage database) +HOSTNAME=$(hostname) # clean up if this needs to run again. sudo -u $USERNAME rm -f $SSH_DIR/{authorized_keys,known_hosts,id_rsa,id_rsa.pub} @@ -18,11 +19,11 @@ sudo -u $USERNAME touch $SSH_DIR/known_hosts sudo -u $USERNAME ssh-keygen -q -t rsa -N '' -f $SSH_DIR/id_rsa sudo -u $USERNAME cat $SSH_DIR/id_rsa.pub > $SSH_DIR/authorized_keys -sudo -u $USERNAME ssh-keyscan "$(hostname)".local >> $SSH_DIR/known_hosts +sudo -u $USERNAME ssh-keyscan "$HOSTNAME".local >> $SSH_DIR/known_hosts -crudini --ini-options=nospace --set $PIO_DIR/config.ini cluster.topology leader_hostname "$(hostname)" -crudini --ini-options=nospace --set $PIO_DIR/config.ini cluster.topology leader_address "$(hostname)".local -crudini --ini-options=nospace --set $PIO_DIR/config.ini mqtt broker_address "$(hostname)".local +sudo -u $USERNAME crudini --ini-options=nospace --set $PIO_DIR/config.ini cluster.topology leader_hostname "$HOSTNAME" +sudo -u $USERNAME crudini --ini-options=nospace --set $PIO_DIR/config.ini cluster.topology leader_address "$HOSTNAME".local +sudo -u $USERNAME crudini --ini-options=nospace --set $PIO_DIR/config.ini mqtt broker_address "$HOSTNAME".local sqlite3 $DB_LOC "INSERT OR IGNORE INTO experiments (created_at, experiment, description) VALUES (STRFTIME('%Y-%m-%dT%H:%M:%f000Z', 'NOW'), 'Demo experiment', 'This is a demo experiment. Feel free to click around. When you are ready, create a new experiment in the dropdown to the left.');" @@ -31,7 +32,7 @@ sqlite3 $DB_LOC "INSERT OR IGNORE INTO experiments (created_at, experiment, desc sudo -u $USERNAME touch "$PIO_DIR/config_$HOSTNAME.ini" # set with the correct read/write permissions printf '# Any settings here are specific to %s, the leader, and override the settings in config.ini\n\n' "$HOSTNAME" >> "$PIO_DIR/config_$HOSTNAME.ini" -crudini --ini-options=nospace --set "$PIO_DIR/config_$HOSTNAME.ini" cluster.topology leader_address 127.0.0.1 -crudini --ini-options=nospace --set "$PIO_DIR/config_$HOSTNAME.ini" mqtt broker_address 127.0.0.1 +sudo -u $USERNAME crudini --ini-options=nospace --set "$PIO_DIR/config_$HOSTNAME.ini" cluster.topology leader_address 127.0.0.1 +sudo -u $USERNAME crudini --ini-options=nospace --set "$PIO_DIR/config_$HOSTNAME.ini" mqtt broker_address 127.0.0.1 -cp "$PIO_DIR/config_$HOSTNAME.ini" "$PIO_DIR/unit_config.ini" \ No newline at end of file +cp -a "$PIO_DIR/config_$HOSTNAME.ini" "$PIO_DIR/unit_config.ini" \ No newline at end of file diff --git a/workspace/scripts/files/bash/firstboot_leader_and_worker.sh b/workspace/scripts/files/bash/firstboot_leader_and_worker.sh index 6ffd76f..81d3707 100644 --- a/workspace/scripts/files/bash/firstboot_leader_and_worker.sh +++ b/workspace/scripts/files/bash/firstboot_leader_and_worker.sh @@ -21,9 +21,9 @@ sudo -u $USERNAME ssh-keygen -q -t rsa -N '' -f $SSH_DIR/id_rsa sudo -u $USERNAME cat $SSH_DIR/id_rsa.pub > $SSH_DIR/authorized_keys sudo -u $USERNAME ssh-keyscan "$HOSTNAME".local >> $SSH_DIR/known_hosts -crudini --ini-options=nospace --set $PIO_DIR/config.ini cluster.topology leader_hostname "$HOSTNAME" -crudini --ini-options=nospace --set $PIO_DIR/config.ini cluster.topology leader_address "$HOSTNAME".local -crudini --ini-options=nospace --set $PIO_DIR/config.ini mqtt broker_address "$HOSTNAME".local +sudo -u $USERNAME crudini --ini-options=nospace --set $PIO_DIR/config.ini cluster.topology leader_hostname "$HOSTNAME" +sudo -u $USERNAME crudini --ini-options=nospace --set $PIO_DIR/config.ini cluster.topology leader_address "$HOSTNAME".local +sudo -u $USERNAME crudini --ini-options=nospace --set $PIO_DIR/config.ini mqtt broker_address "$HOSTNAME".local sqlite3 "$DB_LOC" "INSERT OR IGNORE INTO experiments (created_at, experiment, description) VALUES (STRFTIME('%Y-%m-%dT%H:%M:%f000Z', 'NOW'), 'Demo experiment', 'This is a demo experiment. Feel free to click around. When you are ready, create a new experiment in the dropdown to the left.');" sqlite3 "$DB_LOC" "INSERT OR IGNORE INTO workers (pioreactor_unit, added_at, is_active) VALUES ('$HOSTNAME', STRFTIME('%Y-%m-%dT%H:%M:%f000Z', 'NOW'), 1);" @@ -33,9 +33,9 @@ sqlite3 "$DB_LOC" "INSERT OR IGNORE INTO experiment_worker_assignments (pioreact sudo -u $USERNAME touch $PIO_DIR/config_"$HOSTNAME".ini # set with the correct read/write permissions printf '# Any settings here are specific to %s, the leader, and override the settings in config.ini\n\n' "$HOSTNAME" >> $PIO_DIR/config_"$HOSTNAME".ini -crudini --ini-options=nospace --set $PIO_DIR/config_"$HOSTNAME".ini cluster.topology leader_address 127.0.0.1 -crudini --ini-options=nospace --set $PIO_DIR/config_"$HOSTNAME".ini mqtt broker_address 127.0.0.1 -crudini --ini-options=nospace --set $PIO_DIR/config_"$HOSTNAME".ini pioreactor model pioreactor_20ml -crudini --ini-options=nospace --set $PIO_DIR/config_"$HOSTNAME".ini pioreactor version 1.1 +sudo -u $USERNAME crudini --ini-options=nospace --set $PIO_DIR/config_"$HOSTNAME".ini cluster.topology leader_address 127.0.0.1 +sudo -u $USERNAME crudini --ini-options=nospace --set $PIO_DIR/config_"$HOSTNAME".ini mqtt broker_address 127.0.0.1 +sudo -u $USERNAME crudini --ini-options=nospace --set $PIO_DIR/config_"$HOSTNAME".ini pioreactor model pioreactor_20ml +sudo -u $USERNAME crudini --ini-options=nospace --set $PIO_DIR/config_"$HOSTNAME".ini pioreactor version 1.1 -cp "$PIO_DIR/config_$HOSTNAME.ini" "$PIO_DIR/unit_config.ini" \ No newline at end of file +cp -a "$PIO_DIR/config_$HOSTNAME.ini" "$PIO_DIR/unit_config.ini" \ No newline at end of file