Richard Felkl | 2652549 | 2018-02-14 17:00:40 +0100 | [diff] [blame] | 1 | #!/bin/bash |
Richard Felkl | 99e1418 | 2018-02-15 15:32:30 +0100 | [diff] [blame] | 2 | WORKING_DIR="$PWD" |
Richard Felkl | 2652549 | 2018-02-14 17:00:40 +0100 | [diff] [blame] | 3 | while getopts "d:" option |
| 4 | do |
| 5 | case "${option}" |
| 6 | in |
Richard Felkl | 99e1418 | 2018-02-15 15:32:30 +0100 | [diff] [blame] | 7 | d|\?) WORKING_DIR="${OPTARG}";; |
Richard Felkl | 2652549 | 2018-02-14 17:00:40 +0100 | [diff] [blame] | 8 | esac |
| 9 | done |
| 10 | |
Richard Felkl | 99e1418 | 2018-02-15 15:32:30 +0100 | [diff] [blame] | 11 | TIME=$(date +%Y%m%d-%H%M%S) |
| 12 | DIR="$WORKING_DIR/aptly-packages-import-$TIME" |
| 13 | mkdir -p $DIR |
Richard Felkl | 2652549 | 2018-02-14 17:00:40 +0100 | [diff] [blame] | 14 | |
| 15 | PAYLOAD_LINE=`awk '/^__PAYLOAD_BELOW__/ {print NR + 1; exit 0; }' $0` |
| 16 | |
| 17 | tail -n+$PAYLOAD_LINE $0 | tar xzv -C $DIR |
| 18 | |
| 19 | REPOS="$(ls -1 $DIR)" |
| 20 | |
| 21 | for REPO in $REPOS |
| 22 | do |
| 23 | aptly repo add $REPO $DIR/$REPO |
Richard Felkl | 99e1418 | 2018-02-15 15:32:30 +0100 | [diff] [blame] | 24 | SNAPSHOT_NAME="$REPO-$TIME" |
Richard Felkl | 2652549 | 2018-02-14 17:00:40 +0100 | [diff] [blame] | 25 | aptly snapshot create $SNAPSHOT_NAME from repo $REPO |
| 26 | done |
| 27 | |
| 28 | aptly_publish_update.sh -av |
| 29 | |
| 30 | exit 0 |
| 31 | |
Richard Felkl | ec5941c | 2018-02-14 17:41:18 +0100 | [diff] [blame] | 32 | __PAYLOAD_BELOW__ |