#!/bin/sh set -e if [ $# -eq 0 ]; then echo "No arguments provided. Aborting..." exit 1 fi if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then echo "usage: ./deploy.sh [-h] [DIST_DIR INCOMING_DIR READY_SUFFIX] Deploys packages for you. Possible values for the arguments: DIST_DIR path of the binary package(s) to deploy INCOMING_DIR remote path of the 'incoming' directory READY_SUFFIX suffix used to flag a complete transfer of a file Dependencies: openssh-client " exit 0 fi if [ $# -lt 3 ]; then echo "Mandatory arguments: 'DIST_DIR', 'INCOMING_DIR', 'READY_SUFFIX'. Aborting..." exit 1 fi DIST_DIR="${1}" INCOMING_DIR="${2}" READY_SUFFIX="${3}" for ENTRY in "${DIST_DIR}"/*.deb; do # If is not a file skip if [ -f "${ENTRY}" ]; then FILENAME=$(basename "${ENTRY}") #scp "${ENTRY}" reposerver:"${INCOMING_DIR}/${FILENAME}" #scp /dev/null reposerver:"${INCOMING_DIR}/${FILENAME}${READY_SUFFIX}" cp "${ENTRY}" "${INCOMING_DIR}/${FILENAME}" touch "${INCOMING_DIR}/${FILENAME}${READY_SUFFIX}" fi done