Mirror image: add aptly-add-packages.sh

Change-Id: Id32f3beb864e159ab22ac3dd32dc71c880ff6fdb
diff --git a/mirror-image/aptly-add-packages.sh b/mirror-image/aptly-add-packages.sh
new file mode 100755
index 0000000..2483526
--- /dev/null
+++ b/mirror-image/aptly-add-packages.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+DIR="$PWD"
+while getopts "d:"  option
+do
+ case "${option}"
+  in
+  d|\?) DIR="${OPTARG}";;
+  esac
+done
+
+mkdir $DIR
+
+PAYLOAD_LINE=`awk '/^__PAYLOAD_BELOW__/ {print NR + 1; exit 0; }' $0`
+
+tail -n+$PAYLOAD_LINE $0 | tar xzv -C $DIR
+
+REPOS="$(ls -1 $DIR)"
+
+for REPO in $REPOS
+do
+    aptly repo add $REPO $DIR/$REPO
+    SNAPSHOT_NAME="$REPO-$(date +%Y%m%d-%H%M%S)"
+    aptly snapshot create $SNAPSHOT_NAME from repo $REPO
+done
+
+aptly_publish_update.sh -av
+
+exit 0
+
+__PAYLOAD_BELOW__
\ No newline at end of file