blob: 2f253ae5c975eebdf16cf58b244ed5b319596af1 [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")
6DEBMLOG=/var/log/debmirror/${stamp}.log
Richard Felkl7ae81d62018-01-04 22:29:03 +01007MIRRORDIR=/srv/aptly/public
azvyagintsevf9f0d142018-01-10 15:27:17 +02008MCP_VERSION=${MCP_VERSION:-stable}
9MIRROR_HOST=${MIRROR_HOST:-"mirror.mirantis.com"}
10method=${CLONE_METHOD:-"rsync"}
Richard Felkl7ae81d62018-01-04 22:29:03 +010011
azvyagintsevf9f0d142018-01-10 15:27:17 +020012if [[ ${method} == "rsync" ]] ; then
13 m_root=":mirror/$MCP_VERSION/ubuntu"
14elif [[ ${method} == "http" ]] ; then
15 m_root="$MCP_VERSION/ubuntu"
16else
17 echo "LOG: Error: unsupported clone method!" 2>&1 | tee -a $DEBMLOG
18 exit 1
Richard Felkl7ae81d62018-01-04 22:29:03 +010019fi
20
azvyagintsevf9f0d142018-01-10 15:27:17 +020021### Script body ###
22echo "LOG: Start: $(date '+%Y_%m_%d_%H_%M_%S')" 2>&1 | tee -a $DEBMLOG
Richard Felkl7ae81d62018-01-04 22:29:03 +010023
azvyagintsevf9f0d142018-01-10 15:27:17 +020024mkdir -p $(dirname ${DEBMLOG}) ${MIRRORDIR}
Richard Felkl7ae81d62018-01-04 22:29:03 +010025# Ubuntu General
azvyagintsevf9f0d142018-01-10 15:27:17 +020026echo "LOG: Ubuntu Mirror" 2>&1 | tee -a $DEBMLOG
Richard Felkl7ae81d62018-01-04 22:29:03 +010027
azvyagintsevf9f0d142018-01-10 15:27:17 +020028debmirror --verbose --method=${method} --progress \
29 --host=${MIRROR_HOST} \
30 --arch=amd64 \
31 --dist=xenial,xenial-security,xenial-updates \
32 --root=${m_root} \
33 --section=main,multiverse,restricted,universe \
34 --rsync-extra=none \
35 --nosource \
36 --no-check-gpg \
37 --exclude-deb-section=games \
38 --exclude-deb-section=gnome \
39 --exclude-deb-section=Xfce \
40 --exclude-deb-section=sound \
41 --exclude-deb-section=doc \
42 --exclude-deb-section=electronics \
43 --exclude-deb-section=graphics \
44 --exclude-deb-section=hamradio \
45 --exclude-deb-section=localization \
46 --exclude-deb-section=kde \
47 --exclude-deb-section=video \
48 --exclude='/firefox*' \
49 --exclude='/chromium-browser*' \
50 --exclude='/ceph*' \
51 --exclude='/*-wallpapers*' \
52 --exclude='/language-pack-(?!en)' \
53 $MIRRORDIR/ubuntu 2>&1 | tee -a $DEBMLOG
Richard Felkl7ae81d62018-01-04 22:29:03 +010054
azvyagintsevf9f0d142018-01-10 15:27:17 +020055echo "LOG: Fixing ownership" 2>&1 | tee -a $DEBMLOG
56find "${MIRRORDIR}" -type d -o -type f -exec chown aptly:aptly '{}' \; 2>&1 | tee -a $DEBMLOG
Richard Felkl7ae81d62018-01-04 22:29:03 +010057
azvyagintsevf9f0d142018-01-10 15:27:17 +020058echo "LOG: Fixing permissions " 2>&1 | tee -a $DEBMLOG
59find "${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 +010060
azvyagintsevf9f0d142018-01-10 15:27:17 +020061echo "LOG: Mirror size " 2>&1 | tee -a $DEBMLOG
62du -hs "${MIRRORDIR}" 2>&1 | tee -a $DEBMLOG
63
64echo "LOG: Finish:$(date '+%Y_%m_%d_%H_%M_%S')" 2>&1 | tee -a $DEBMLOG
65