From d4c88bb918b201fe2de66bbbca0672c9aca94531 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 9 May 2017 17:19:17 +0200 Subject: [PATCH] [big-update] Now shares automatically 1. authorized_keys 2. unlock code via mysql on the server --- clone/clone | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/clone/clone b/clone/clone index 458ef39..91a79a5 100755 --- a/clone/clone +++ b/clone/clone @@ -231,8 +231,6 @@ step6(){ sudo chown 666:666 /mnt/home/sats/.ssh/config; sudo chmod 444 /mnt/home/sats/.ssh/config; - - echo "<<< done"; step7; @@ -385,7 +383,7 @@ step9(){ echo "$UNLOCK_CODE" | sudo tee /mnt/home/sats/satsd/conf/machine.unlock > /dev/null; echo "$WAREHOUSE_TOKEN" | sudo tee /mnt/home/sats/satsd/conf/warehouse.token > /dev/null; - echo "$MACHINE_ID;$UNLOCK_CODE" | tee ./server/created > /dev/null; + echo "$MACHINE_ID;$UNLOCK_CODE" | tee -a ./server/created > /dev/null; # (3) Adjust permissions # echo " (.) Adjust permissions"; @@ -407,12 +405,24 @@ step9(){ -# [10] BLablslkfjdlkdsjfks +# [10] Umount device and share data to server #========================================================# step10(){ + echo "\n>>> Finishing properly"; + echo " (.) Copying SATS public key to server's authorized_keys"; + cat ./server/authorized_keys | tail -n 1 | ssh smmp-server "cat >> ~/authorized_keys" || echo " (!) Cannot share public key"; + + echo " (.) Copying SATS unlock code to server's database"; + DB_PASS="e6mmCpx9Oks5BwS1rcPIrgRDIGLrmDQn9oqX0tqF2VhyiLDW6yKJFrafewwCZ63njYaDKiNjiAS11hrLYij7HaxTdHb33tEqby34vgVrUYaUnwPnCJHmkoyR3TfjcZNCPti8VZG0Oooq7qSHy4lcD6T4EFCcOQ_yHjVIfibvbuZqQcPTUvbDP_9910mRDBUADShIe4sjK2FLOTCz6usUKkNqTH3PldRfAgGl182Zw9tiSPJfvQZX3S2bKblNuZf1"; + DB_USER="sats-set-unlock"; + DB_DATABASE="logauth"; + ssh smmp-server "echo \"UPDATE machine SET unlock_code='$UNLOCK_CODE' WHERE id_machine = $MACHINE_ID;\" | mysql -u$DB_USER -p$DB_PASS --database=$DB_DATABASE" || echo " (!) Cannot share unlock code"; + + echo " (.) Unmounting remote device"; sudo umount /mnt; + echo "<<< done"; }