#!/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 echo "[INFO] Working in directory ${WORK_DIR}" cd $WORK_DIR retVal=$? if [ $retVal -ne 0 ]; then echo '[ERROR] Directory not found' return $retVal fi 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 echo "[INFO] Transferring images from server..." rsync -hrut --info=progress2 -e "ssh -p ${SSH_PORT}" ${SERVER}:/${SERVER_ROOT_PATH}/images/ "${IMAGE_DIR}" 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