blob: 4bb1489d3c16f5ba06d9f1009e2af97ca1d4b88d [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 \
52 --exclude='/firefox*' \
53 --exclude='/chromium-browser*' \
54 --exclude='/ceph*' \
55 --exclude='/*-wallpapers*' \
56 --exclude='/language-pack-(?!en)' \
57 $MIRRORDIR/ubuntu 2>&1 | tee -a $DEBMLOG
Richard Felkl7ae81d62018-01-04 22:29:03 +010058
azvyagintsevf9f0d142018-01-10 15:27:17 +020059echo "LOG: Fixing ownership" 2>&1 | tee -a $DEBMLOG
60find "${MIRRORDIR}" -type d -o -type f -exec chown aptly:aptly '{}' \; 2>&1 | tee -a $DEBMLOG
Richard Felkl7ae81d62018-01-04 22:29:03 +010061
azvyagintsevf9f0d142018-01-10 15:27:17 +020062echo "LOG: Fixing permissions " 2>&1 | tee -a $DEBMLOG
63find "${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 +010064
azvyagintsevf9f0d142018-01-10 15:27:17 +020065echo "LOG: Mirror size " 2>&1 | tee -a $DEBMLOG
66du -hs "${MIRRORDIR}" 2>&1 | tee -a $DEBMLOG
67
68echo "LOG: Finish:$(date '+%Y_%m_%d_%H_%M_%S')" 2>&1 | tee -a $DEBMLOG
69