#!/bin/sh set -e if [ $# -eq 0 ]; then echo "No arguments provided. Aborting..." exit 1 fi if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then echo "usage: ./movedebs.sh [-h] [MAIN_DIR INCOMING_DIR READY_SUFFIX] Deploys packages for you. Possible values for the arguments: MAIN_DIR path of the directory inside the repository where the packages will be storaged INCOMING_DIR local path of the 'incoming' directory READY_SUFFIX suffix used to flag a complete transfer of a file Dependencies: - " exit 0 fi if [ $# -lt 3 ]; then echo "Mandatory arguments: 'MAIN_DIR', 'INCOMING_DIR', 'INCOMING_DIR'. Aborting..." exit 1 fi MAIN_DIR="${1}" INCOMING_DIR="${2}" READY_SUFFIX="${3}" for ENTRY in "${INCOMING_DIR}"/*"${READY_SUFFIX}"; do # If is not a file skip if [ -f "${ENTRY}" ]; then FILENAME_DEB=$(basename --suffix="${READY_SUFFIX}" "${ENTRY}") BASEDIRPATH=$(dirname "${ENTRY}") mv "${BASEDIRPATH}/${FILENAME_DEB}" "${MAIN_DIR}/${FILENAME_DEB}" rm "${ENTRY}" fi done