Min 7 år sedan
incheckning
70fdb583b7
7 ändrade filer med 108 tillägg och 0 borttagningar
  1. 15 0
      archlinux-exclude.conf
  2. 0 0
      archlinuxarm-exclude.conf
  3. 25 0
      config
  4. 6 0
      mirrors.service
  5. 52 0
      mirrors.sh
  6. 8 0
      mirrors.timer
  7. 2 0
      shared-exclude.conf

+ 15 - 0
archlinux-exclude.conf

@@ -0,0 +1,15 @@
+- /archive
+- /community-staging
+- /community-testing
+- /gnome-unstable
+- /iso
+- /kde-unstable
+- /multilib-testing
+- /multilib-staging
+- /other
+- /sources
+- /staging
+- /testing
+P /*/
+
+

+ 0 - 0
archlinuxarm-exclude.conf


+ 25 - 0
config

@@ -0,0 +1,25 @@
+# Mirrors
+# URL | Exclude file | Target directory
+MIRRORS=(
+'rsync://mirrors.uk2.net/archlinux|archlinux-exclude.conf|archlinux'
+'http://repos.mirror.dynu.com/shared|shared-exclude.conf|archlinux/shared'
+'http://dk.mirror.archlinuxarm.org/armv7h/alarm/|archlinuxarm-exclude.conf|archlinux/alarm/os/armv7h/'
+'http://dk.mirror.archlinuxarm.org/armv7h/community|archlinuxarm-exclude.conf|archlinux/community/os/armv7h'
+'http://dk.mirror.archlinuxarm.org/armv7h/core|archlinuxarm-exclude.conf|archlinux/core/os/armv7h'
+'http://dk.mirror.archlinuxarm.org/armv7h/extra|archlinuxarm-exclude.conf|archlinux/extra/os/armv7h'
+)
+
+# Local path
+TARGET=/srv/mirrors
+
+# Exclude file
+EXCLUDE=exclude.conf
+
+# Lockfile dir
+LOCKDIR=/run/lock
+
+# Rsync options
+ROPTS="-rtli --delete-after --preallocate --delay-updates --no-motd --safe-links --delete-excluded --timeout=30 --contimeout=30"
+
+# Wget options
+WOPTS='-m -e robots=off -l 1 -nd -A *.pkg.* -A *.db* -A *.files*'

+ 6 - 0
mirrors.service

@@ -0,0 +1,6 @@
+[Unit]
+Description=Sync Repo Mirrors
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/mirrors

+ 52 - 0
mirrors.sh

@@ -0,0 +1,52 @@
+#!/bin/bash
+set -euo pipefail
+
+CONFIGDIR=/etc/mirrors
+CONFIGFILE=${CONFIGDIR}/config
+source ${CONFIGFILE}
+
+LOCKFILE=${LOCKDIR}/$(basename ${0}).lock
+
+[[ -f "${LOCKFILE}" ]] && {
+echo "Lock file $LOCKFILE found, skipping.."
+exit 0
+}
+
+#touch ${LOCKFILE}
+trap "/bin/rm -f ${LOCKFILE}" EXIT SIGHUP SIGINT SIGTERM
+
+# Show progress if argument is info
+# [[ "$1" == "info" ]] && ROPTS="$ROPTS --info=progress2 -h"
+
+for R in "${MIRRORS[@]}" ; do
+	RR=( ${R//|/ } )
+	MIRROR=${RR[0]}
+	EXCLUDEFILE=$CONFIGDIR/${RR[1]}
+	TARGETDIR=$TARGET/${RR[2]}
+	
+	[[ -r "${EXCLUDEFILE}" ]] || {
+		echo "Exclude file ${EXCLUDEFILE} for mirror ${MIRROR} not found"
+		continue
+	}
+
+	[[ -d "${TARGETDIR}" ]] || {
+		echo "Creating target dir ${TARGETDIR} for mirror ${MIRROR}"
+		mkdir -p ${TARGETDIR}
+	}
+
+	[[ -r "${TARGETDIR}" ]] || {
+		echo "Target dir ${TARGETDIR} for mirror ${MIRROR} not found"
+		continue
+	}
+
+	if [[ $MIRROR == rsync* ]]; then
+		rsync ${ROPTS} -f "merge ${EXCLUDEFILE}"  ${MIRROR}/ ${TARGETDIR}/
+	elif [[ $MIRROR == http* ]]; then
+		EXCLUDE=`cat ${EXCLUDEFILE}`
+		wget ${WOPTS} -R "'${EXCLUDE//[$'\t\r\n']/,}'" -P ${TARGETDIR} ${MIRROR}
+	else
+		echo "Unknown mirror URL: ${MIRROR}"
+	fi
+done
+sync
+exit 0

+ 8 - 0
mirrors.timer

@@ -0,0 +1,8 @@
+[Unit]
+Description=Timer for mirrors sync daily at 4:30 AM.
+
+[Timer]
+OnCalendar=*-*-* 04:30:00
+
+[Install]
+WantedBy=timers.target

+ 2 - 0
shared-exclude.conf

@@ -0,0 +1,2 @@
+blockify-*
+skypeforlinux-*