blob: dfca9308426e7aee4581215b491135f2f35d17d8 [file] [log] [blame]
Richard Felkl7ae81d62018-01-04 22:29:03 +01001#!/bin/bash
2
azvyagintsevf9f0d142018-01-10 15:27:17 +02003set -xe
4set -o pipefail
5stamp=$(date "+%Y_%m_%d_%H_%M_%S")
Richard Felklc76c4752018-01-11 15:42:26 +01006LOGDIR=/var/log/debmirror
7DEBMLOG=${LOGDIR}/${stamp}.log
Richard Felkl7ae81d62018-01-04 22:29:03 +01008MIRRORDIR=/srv/aptly/public
azvyagintsevf9f0d142018-01-10 15:27:17 +02009MCP_VERSION=${MCP_VERSION:-stable}
10MIRROR_HOST=${MIRROR_HOST:-"mirror.mirantis.com"}
11method=${CLONE_METHOD:-"rsync"}
Richard Felkl7ae81d62018-01-04 22:29:03 +010012
Richard Felklc76c4752018-01-11 15:42:26 +010013mkdir -p ${LOGDIR}
14mkdir -p ${MIRRORDIR}
15
azvyagintsevf9f0d142018-01-10 15:27:17 +020016if [[ ${method} == "rsync" ]] ; then
17 m_root=":mirror/$MCP_VERSION/ubuntu"
18elif [[ ${method} == "http" ]] ; then
19 m_root="$MCP_VERSION/ubuntu"
20else
21 echo "LOG: Error: unsupported clone method!" 2>&1 | tee -a $DEBMLOG
22 exit 1
Richard Felkl7ae81d62018-01-04 22:29:03 +010023fi
24
azvyagintsevf9f0d142018-01-10 15:27:17 +020025### Script body ###
26echo "LOG: Start: $(date '+%Y_%m_%d_%H_%M_%S')" 2>&1 | tee -a $DEBMLOG
Richard Felkl7ae81d62018-01-04 22:29:03 +010027
azvyagintsevf9f0d142018-01-10 15:27:17 +020028mkdir -p $(dirname ${DEBMLOG}) ${MIRRORDIR}
Richard Felkl7ae81d62018-01-04 22:29:03 +010029# Ubuntu General
azvyagintsevf9f0d142018-01-10 15:27:17 +020030echo "LOG: Ubuntu Mirror" 2>&1 | tee -a $DEBMLOG
Richard Felkl7ae81d62018-01-04 22:29:03 +010031
azvyagintsevf9f0d142018-01-10 15:27:17 +020032debmirror --verbose --method=${method} --progress \
33 --host=${MIRROR_HOST} \
34 --arch=amd64 \
35 --dist=xenial,xenial-security,xenial-updates \
36 --root=${m_root} \
37 --section=main,multiverse,restricted,universe \
38 --rsync-extra=none \
39 --nosource \
40 --no-check-gpg \
41 --exclude-deb-section=games \
42 --exclude-deb-section=gnome \
43 --exclude-deb-section=Xfce \
44 --exclude-deb-section=sound \
45 --exclude-deb-section=doc \
46 --exclude-deb-section=electronics \
47 --exclude-deb-section=graphics \
48 --exclude-deb-section=hamradio \
49 --exclude-deb-section=localization \
50 --exclude-deb-section=kde \
51 --exclude-deb-section=video \
azvyagintsev5b7f49e2018-01-12 18:07:47 +020052 --exclude='/android*' \
azvyagintsevf9f0d142018-01-10 15:27:17 +020053 --exclude='/firefox*' \
54 --exclude='/chromium-browser*' \
55 --exclude='/ceph*' \
56 --exclude='/*-wallpapers*' \
57 --exclude='/language-pack-(?!en)' \
azvyagintsevd1129f82018-01-12 16:31:33 +020058 --include='/main(.*)manpages' \
azvyagintsev5b7f49e2018-01-12 18:07:47 +020059 --include='/main(.*)python-(.*)doc' \
60 --include='/main(.*)python-(.*)network' \
azvyagintsevf9f0d142018-01-10 15:27:17 +020061 $MIRRORDIR/ubuntu 2>&1 | tee -a $DEBMLOG
Richard Felkl7ae81d62018-01-04 22:29:03 +010062
azvyagintsevf9f0d142018-01-10 15:27:17 +020063echo "LOG: Fixing ownership" 2>&1 | tee -a $DEBMLOG
64find "${MIRRORDIR}" -type d -o -type f -exec chown aptly:aptly '{}' \; 2>&1 | tee -a $DEBMLOG
Richard Felkl7ae81d62018-01-04 22:29:03 +010065
azvyagintsevf9f0d142018-01-10 15:27:17 +020066echo "LOG: Fixing permissions " 2>&1 | tee -a $DEBMLOG
67find "${MIRRORDIR}" -type d -o -type f -exec chmod u+rw,g+r,o+r-w {} \; 2>&1 | tee -a $DEBMLOG
Richard Felkl7ae81d62018-01-04 22:29:03 +010068
azvyagintsevf9f0d142018-01-10 15:27:17 +020069echo "LOG: Mirror size " 2>&1 | tee -a $DEBMLOG
70du -hs "${MIRRORDIR}" 2>&1 | tee -a $DEBMLOG
71
72echo "LOG: Finish:$(date '+%Y_%m_%d_%H_%M_%S')" 2>&1 | tee -a $DEBMLOG
73