Caps-Server/Training/train.sh

49 lines
1.7 KiB
Bash
Raw Normal View History

2021-12-20 17:52:32 +01:00
#!/bin/bash
########### SUDO COMMANDS WITHOUT PASSWORD #############################################
#
# Specific commands must be executable without sudo
#
# Add to sudoers file (sudo visudo):
#
# Disable password for specific commands
# pi ALL=(ALL:ALL) NOPASSWD: /usr/bin/chmod -R 755 /data/public/capserver/images
# pi ALL=(ALL:ALL) NOPASSWD: /usr/bin/mv /home/pi/classifier.mlmodel /data/public/capserver/
# pi ALL=(ALL:ALL) NOPASSWD: /usr/bin/mv /home/pi/classifier.version /data/public/capserver/
# pi ALL=(ALL:ALL) NOPASSWD: /usr/bin/chown -R www-data\:www-data /data/public/capserver/
#
########################################################################################
########### EXPLANATION OF RSYNC FLAGS #################################################
#
# -h human readable output
# -v verbose output
# -r recursive
# -P print information about long-running transfers, keep partial files (—-progress --partial)
# -t preserves modification times
# -u only update if newer
#
########################################################################################
source config.sh
2021-12-20 17:52:32 +01:00
echo "[INFO] Ensuring permissions for images on server..."
ssh -p $SSH_PORT ${SERVER} "sudo chmod -R 755 ${SERVER_ROOT_PATH}/images"
retVal=$?
if [ $retVal -ne 0 ]; then
echo '[ERROR] Failed to change image permissions'
return $retVal
fi
2021-12-20 17:52:32 +01:00
echo "[INFO] Transferring images from server..."
2022-05-02 13:48:11 +02:00
rsync -hrut --info=progress2 -e "ssh -p ${SSH_PORT}" ${SERVER}:/${SERVER_ROOT_PATH}/images/ "${IMAGE_DIR}"
2021-12-20 17:52:32 +01:00
retVal=$?
if [ $retVal -ne 0 ]; then
echo '[ERROR] Failed to transfer images from server'
return $retVal
fi
swift train.swift $SERVER_PATH $SERVER_AUTH $IMAGE_DIR $MODEL_FILE $TRAINING_ITERATIONS