From 1cd63794081c51ae9a0cc95dc49d9cfa19039e45 Mon Sep 17 00:00:00 2001 From: B Stack Date: Mon, 6 Feb 2017 11:18:31 -0500 Subject: rearranged directories to be FHS 3.0 compliant --- usr/local/bin/deploy | 2 +- usr/share/mirror/deploy.sh | 298 +++++++++++++++++++++ usr/share/mirror/docs/.mirror.spec.swp | Bin 0 -> 12288 bytes usr/share/mirror/docs/README.txt | 91 +++++++ usr/share/mirror/docs/debian/conffiles | 0 usr/share/mirror/docs/debian/control | 0 usr/share/mirror/docs/debian/postinst | 0 usr/share/mirror/docs/debian/postrm | 0 usr/share/mirror/docs/debian/preinst | 0 usr/share/mirror/docs/debian/prerm | 0 usr/share/mirror/docs/files-for-versioning.txt | 4 + usr/share/mirror/docs/mirror.spec | 88 ++++++ usr/share/mirror/docs/packaging.txt | 35 +++ usr/share/mirror/examples/FOOTER.html | 5 + usr/share/mirror/examples/HEADER.html | 48 ++++ .../mirror/examples/example-debian/FOOTER.html | 4 + .../mirror/examples/example-debian/HEADER.html | 13 + .../examples/example-debian/example-debian.gpg | 51 ++++ .../examples/example-debian/example-debian.list | 1 + .../example-debian/update-example-debian.sh | 28 ++ usr/share/mirror/examples/example-rpm/FOOTER.html | 8 + usr/share/mirror/examples/example-rpm/HEADER.html | 9 + .../mirror/examples/example-rpm/example-rpm.repo | 8 + .../examples/example-rpm/update-example-rpm.sh | 9 + usr/share/mirror/examples/favicon.ico | Bin 0 -> 4286 bytes usr/share/mirror/examples/favicon.png | Bin 0 -> 575 bytes usr/share/mirror/inc/localize_git.sh | 2 + usr/share/mirror/inc/pack | 100 +++++++ usr/share/mirror/inc/rsync | 38 +++ usr/share/mirror/inc/scrub.txt | 29 ++ usr/share/mirror/mirror-master.sh | 287 ++++++++++++++++++++ usr/share/mirror/scripts/centos | 7 + usr/share/mirror/scripts/fedora-epel | 7 + usr/share/mirror/scripts/fedora-releases | 8 + usr/share/mirror/scripts/fedora-updates | 7 + usr/share/mirror/scripts/libreoffice | 7 + usr/share/mirror/scripts/linuxmint-isos | 7 + usr/share/mirror/scripts/linuxmint-repos | 7 + usr/share/mirror/scripts/old-scripts.tgz | Bin 0 -> 3616 bytes usr/share/mirror/scripts/putty | 13 + usr/share/mirror/scripts/rsyslog | 12 + usr/share/mirror/scripts/ssh | 7 + usr/share/mirror/scripts/ubuntu | 7 + usr/share/mirror/scripts/ubuntu-releases | 7 + 44 files changed, 1253 insertions(+), 1 deletion(-) create mode 100755 usr/share/mirror/deploy.sh create mode 100644 usr/share/mirror/docs/.mirror.spec.swp create mode 100644 usr/share/mirror/docs/README.txt create mode 100644 usr/share/mirror/docs/debian/conffiles create mode 100644 usr/share/mirror/docs/debian/control create mode 100755 usr/share/mirror/docs/debian/postinst create mode 100755 usr/share/mirror/docs/debian/postrm create mode 100755 usr/share/mirror/docs/debian/preinst create mode 100755 usr/share/mirror/docs/debian/prerm create mode 100644 usr/share/mirror/docs/files-for-versioning.txt create mode 100644 usr/share/mirror/docs/mirror.spec create mode 100644 usr/share/mirror/docs/packaging.txt create mode 100644 usr/share/mirror/examples/FOOTER.html create mode 100644 usr/share/mirror/examples/HEADER.html create mode 100644 usr/share/mirror/examples/example-debian/FOOTER.html create mode 100644 usr/share/mirror/examples/example-debian/HEADER.html create mode 100644 usr/share/mirror/examples/example-debian/example-debian.gpg create mode 100644 usr/share/mirror/examples/example-debian/example-debian.list create mode 100755 usr/share/mirror/examples/example-debian/update-example-debian.sh create mode 100644 usr/share/mirror/examples/example-rpm/FOOTER.html create mode 100644 usr/share/mirror/examples/example-rpm/HEADER.html create mode 100644 usr/share/mirror/examples/example-rpm/example-rpm.repo create mode 100755 usr/share/mirror/examples/example-rpm/update-example-rpm.sh create mode 100644 usr/share/mirror/examples/favicon.ico create mode 100644 usr/share/mirror/examples/favicon.png create mode 100755 usr/share/mirror/inc/localize_git.sh create mode 100755 usr/share/mirror/inc/pack create mode 100644 usr/share/mirror/inc/rsync create mode 100644 usr/share/mirror/inc/scrub.txt create mode 100755 usr/share/mirror/mirror-master.sh create mode 100755 usr/share/mirror/scripts/centos create mode 100755 usr/share/mirror/scripts/fedora-epel create mode 100755 usr/share/mirror/scripts/fedora-releases create mode 100755 usr/share/mirror/scripts/fedora-updates create mode 100755 usr/share/mirror/scripts/libreoffice create mode 100755 usr/share/mirror/scripts/linuxmint-isos create mode 100755 usr/share/mirror/scripts/linuxmint-repos create mode 100644 usr/share/mirror/scripts/old-scripts.tgz create mode 100755 usr/share/mirror/scripts/putty create mode 100755 usr/share/mirror/scripts/rsyslog create mode 100755 usr/share/mirror/scripts/ssh create mode 100755 usr/share/mirror/scripts/ubuntu create mode 100755 usr/share/mirror/scripts/ubuntu-releases (limited to 'usr') diff --git a/usr/local/bin/deploy b/usr/local/bin/deploy index f7b33a6..947da85 120000 --- a/usr/local/bin/deploy +++ b/usr/local/bin/deploy @@ -1 +1 @@ -/etc/mirror/inc/deploy.sh \ No newline at end of file +/usr/share/mirror/deploy.sh \ No newline at end of file diff --git a/usr/share/mirror/deploy.sh b/usr/share/mirror/deploy.sh new file mode 100755 index 0000000..2a03abc --- /dev/null +++ b/usr/share/mirror/deploy.sh @@ -0,0 +1,298 @@ +#!/bin/sh +# File: /usr/share/mirror/deploy.sh +# Author: bgstack15@gmail.com +# Startdate: 2016-07-14 09:53:09 +# Title: Script that Deploys a Package +# Purpose: To make it easy to deploy to the mirror a new version of a package +# Package: mirror +# History: +# Usage: +# Reference: ftemplate.sh 2016-07-12a; framework.sh 2016-05-25a +# mirror-master from mirror-1.0-2.noarch.rpm +# This script has a symlink: /usr/local/bin/deploy +# Improve: +# * provide better package name and version parsing +fiversion="2016-05-25a" +deployversion="2016-07-14a" + +usage() { + less -F >&2 <&1 | grep -viE "failed to preserve ownership for" +} + +# DEFINE FUNCTIONS + +# DEFINE TRAPS + +function clean_deploy { + #rm -f $logfile >/dev/null 2>&1 + [ ] #use at end of entire script if you need to clean up tmpfiles +} + +function CTRLC { + #trap "CTRLC" 2 + [ ] #useful for controlling the ctrl+c keystroke +} + +function CTRLZ { + #trap "CTRLZ" 18 + [ ] #useful for controlling the ctrl+z keystroke +} + +function parseFlag { + flag=$1 + hasval=0 + case $flag in + # INSERT FLAGS HERE + "d" | "debug" | "DEBUG" | "dd" ) setdebug; ferror "debug level ${debug}";; + "u" | "usage" | "help" | "h" ) usage; exit 1;; + "V" | "fcheck" | "version" ) ferror "${scriptfile} version ${deployversion}"; exit 1;; + #"i" | "infile" | "inputfile" ) getval;infile1=$tempval;; + "c" | "conffile" ) getval;conffile=$tempval;; + esac + + debuglev 10 && { [[ hasval -eq 1 ]] && ferror "flag: $flag = $tempval" || ferror "flag: $flag"; } +} + +# DETERMINE LOCATION OF FRAMEWORK +while read flocation; do if [[ -x $flocation ]] && [[ $( $flocation --fcheck ) -ge 20160229 ]]; then frameworkscript=$flocation; break; fi; done <&2 && exit 4 + +# REACT TO OPERATING SYSTEM TYPE +case $( uname -s ) in + AIX) [ ];; + Linux) [ ];; + *) echo "$scriptfile: 3. Indeterminate OS: $( uname -s )" 1>&2 && exit 3;; +esac + +# INITIALIZE VARIABLES +# variables set in framework: +# today server thistty scriptdir scriptfile scripttrim +# is_cronjob stdin_piped stdout_piped stderr_piped sendsh sendopts +. ${frameworkscript} || echo "$0: framework did not run properly. Continuing..." 1>&2 +conffile=/etc/mirror/deploy.conf +logfile=${scriptdir}/${scripttrim}.${today}.out +interestedparties="bgstack15@example.com" + +# REACT TO ROOT STATUS +case $is_root in + 1) # proper root + [ ] ;; + sudo|"") # sudo to root or not root at all + ferror "${scriptfile}: 5. Please run as root. Aborted." + exit 5 + ;; +esac + +# SET CUSTOM SCRIPT AND VALUES +#setval 1 sendsh sendopts</dev/null | head -n1 ) + ;; + debian|ubuntu) + sourcefile=$( { find "${inputpackagedir}" -regex ".*${packagename}-${packageversion}.*" -regex ".*.deb"; find "${inputlocation}" -regex ".*${packagename}-${packageversion}.*" -regex ".*.deb";} 2>/dev/null | head -n1 ) + ;; + *) # including tarball, tar + sourcefile=$( { find "${inputpackagedir}" -regex ".*${packagename}-${packageversion}.*" -regex ".*.master.tgz"; find "${inputlocation}" -regex ".*${packagename}-${packageversion}.*" -regex ".*.master.tgz"; } 2>/dev/null | head -n1 ) + ;; + esac + + # DERIVE TARBALL FILE + sourcetarfile=$( { find "${inputpackagedir}" -regex ".*${packagename}-${packageversion}.*" -regex ".*.master.tgz"; find "${inputlocation}" -regex ".*${packagename}-${packageversion}.*" -regex ".*.master.tgz"; } 2>/dev/null | head -n1 ) + debuglev 5 && ferror "sourcefile=${sourcefile}" + debuglev 5 && ferror "sourcetarfile=${sourcetarfile}" + + # CALCULATE DESTINATION FILE + destinationdir=$( { find "${thispackagedir}" -maxdepth 0 -type d; find "${thislocation}" -maxdepth 0 -type d; } 2>/dev/null | grep -viE "^$" | head -n1 ) + #debuglev 5 && ferror "destinationdir=${destinationdir}" + [[ ! -d "${destinationdir}" ]] && ferror "Zone ${thiszone} file ${sourcefile} cannot be copied to the invalid directory \"${destinationdir}\". Skipped." && continue + destinationfile=$( echo "${destinationdir}/$( basename "${sourcefile}" )" | sed -e 's!\/\+!\/!g;' ) + debuglev 5 && ferror "destinationfile=${destinationfile}" + + # PERFORM FILE COPY + if [[ ! -f "${sourcefile}" ]]; + then + ferror "Sourcefile ${sourcefile} not found. Skipped the copy action." + else + fileaction copy "${sourcefile}" "${destinationfile}" + thiszoneused=1 + fi + + # IF ZONELINK + eval thislink=\${${thiszone}link} + case "${thislink}" in + "1"|"y"|"yes"|"Y"|"YES") + # have already derived tarball file + if [[ ! -f "${sourcetarfile}" ]]; + then + # link was yes, but tarball does not exist, so soft error. + ferror "Sourcetarfile ${sourcetarfile} not found. Skipped the tar file symlink." + else + # CALCULATE DESTINATION TARBALL FILE + destinationtarfile="$( echo "${destinationdir}/$( basename "${sourcetarfile}" )" | sed -e 's!\/\+!\/!g;' )" + + # PERFORM TARBALL SYMLINK + fileaction symlink "${sourcetarfile}" "${destinationtarfile}" + fi + ;; + *) # no + [ ] + ;; + esac + + # IF ZONE WAS UPDATED + eval thisupdatescript=\${${thiszone}updatescript} + if [[ thiszoneused -ne 0 ]]; + then + [[ -n "${thisupdatescript}" ]] && { + if [[ ! -x "${thisupdatescript}" ]]; + then + ferror "Cannot execute the updatescript ${thisupdatescript}. Skipped." + else + # is executable + debuglev 2 && ferror "Execute ${thisupdatescript}" + ! debuglev 4 && ${thisupdatescript} + fi + } + fi + + } # end if-not-input-zone + done +#} | tee -a $logfile + +# EMAIL LOGFILE +#$sendsh $sendopts "$server $scriptfile out" $logfile $interestedparties diff --git a/usr/share/mirror/docs/.mirror.spec.swp b/usr/share/mirror/docs/.mirror.spec.swp new file mode 100644 index 0000000..63104ce Binary files /dev/null and b/usr/share/mirror/docs/.mirror.spec.swp differ diff --git a/usr/share/mirror/docs/README.txt b/usr/share/mirror/docs/README.txt new file mode 100644 index 0000000..b7194df --- /dev/null +++ b/usr/share/mirror/docs/README.txt @@ -0,0 +1,91 @@ +File: etc/mirror/README.txt +Package: mirror 1.0-7 +Author: bgstack15@gmail.com +Startdate: 2016-06-08 +Title: Readme file for mirror +Purpose: All packages should come with a readme +Usage: Read it. +Reference: README.txt +Improve: +Document: Below this line + +### WELCOME + +mirror is basically a collection of scripts that provide the sync instructions to make a local repository of software. + +## Steps to take before using mirror for the first time +Configure these files: +/etc/httpd/sites/mirror.conf +/etc/mirror/inc/rsync +/etc/mirror/mirror.conf + +Select a storage directory. On the EXAMPLE mirror, we used an nfs mount for multiple locations. +--- BEGIN excerpt from mirror.example.com:/etc/fstab +linux-nfs2.example.com:/vol/linux_mirror /mnt/realmirror nfs defaults,uid=1539249479 0 0 +/mnt/realmirror/mirror /mnt/mirror none bind 0 0 +/mnt/mirror /var/www/html/mirror.example.com none bind 0 0 +--- END + +## Scripts to run +The files called by mirror-master are the ones that actually do the source and target selection and file operations. By default they are located in /etc/mirror/scripts/ +To enable a script, you must mark the executable flag: +chmod +x /etc/mirror/scripts/filetostart + +It is recommended to start with certain ones enabled. You can use this command: +chmod +x /etc/mirror/scripts/{centos,fedora-epel,fedora-releases,fedora-updates,libreoffice,putty,ssh,ubuntu,ubuntu-releases} + +## Configuring the web server +Included in this package are some apache configs. +For a nice intro page, a template is provided at /etc/mirror/inc/HEADER.html + +## Maintaining your mirror server +Fedora only keeps current the two latest versions. +Ubuntu keeps certain versions current: check http://releases.ubuntu.com/ for which versions. + +### USAGE BLOCK +usage: mirror-master.sh [-duV] [ -f | --file /etc/mirror/mirror.conf ] [ --scriptsdir /etc/mirror/scripts ] [ scriptname ] +version ${mirrormasterversion} + -d debug Show debugging info, including parsed variables. + -u usage Show this usage block. + -V version Show script version number. + -f file Use specified config file. Default is /etc/mirror/mirror.conf + --scriptsdir Use specified scripts directory. Will override anything in the called conf file +Return values: +0 Normal +1 Help or version info displayed +2 mirror-master is already running +3 Unable to modify important file +4 Unable to find dependency +5 Not run as root or sudo +Examples: + mirror-master.sh centos + This command will run only the scripts/centos file. + mirror-master.sh centos putty + This command will run only centos and putty files. + mirror-master.sh + This command will run all files with o+x perms in scriptsdir directory. + +### REFERENCE + +### CHANGELOG +1.0-2 2016-06-10 +uses config file /etc/mirror/mirror.conf + +1.0-3 2016-07-14 +added supplementary script /etc/mirror/inc/deploy.sh +New feature: deploy +See its config file /etc/mirror/inc/deploy.conf + +2016-10-28 mirror 1.0-4 +Adding elemants for safe publishing on github +Added repos for linuxmint + +2016-11-11 mirror 1.0-5 +adding favicon, licensed CC BY 3.0 by Lorc + +2017-01-11 mirror-1.0-6 +Updated all scripts for the bgscripts-1.1-28 directory migration to /usr/share/bgscripts + +2017-02-06 mirror-1.0-7 +Rearranged directory structure to comply with FHS 3.0 +Included a zz_proxy.conf example diff --git a/usr/share/mirror/docs/debian/conffiles b/usr/share/mirror/docs/debian/conffiles new file mode 100644 index 0000000..e69de29 diff --git a/usr/share/mirror/docs/debian/control b/usr/share/mirror/docs/debian/control new file mode 100644 index 0000000..e69de29 diff --git a/usr/share/mirror/docs/debian/postinst b/usr/share/mirror/docs/debian/postinst new file mode 100755 index 0000000..e69de29 diff --git a/usr/share/mirror/docs/debian/postrm b/usr/share/mirror/docs/debian/postrm new file mode 100755 index 0000000..e69de29 diff --git a/usr/share/mirror/docs/debian/preinst b/usr/share/mirror/docs/debian/preinst new file mode 100755 index 0000000..e69de29 diff --git a/usr/share/mirror/docs/debian/prerm b/usr/share/mirror/docs/debian/prerm new file mode 100755 index 0000000..e69de29 diff --git a/usr/share/mirror/docs/files-for-versioning.txt b/usr/share/mirror/docs/files-for-versioning.txt new file mode 100644 index 0000000..e7f7a9e --- /dev/null +++ b/usr/share/mirror/docs/files-for-versioning.txt @@ -0,0 +1,4 @@ +inc/localize_git.sh +inc/scrub.txt +docs/README.txt +docs/mirror.spec diff --git a/usr/share/mirror/docs/mirror.spec b/usr/share/mirror/docs/mirror.spec new file mode 100644 index 0000000..38513eb --- /dev/null +++ b/usr/share/mirror/docs/mirror.spec @@ -0,0 +1,88 @@ +Summary: Mirror +Name: mirror +Version: 1.0 +Release: 7 +License: CC BY-SA 4.0 +Group: Applications/System +Source: mirror.tgz +URL: bgstack15@gmail.com +#Distribution: +#Vendor: +Packager: Bgstack15 +Buildarch: noarch +PreReq: bgscripts >= 1.1-28 +Requires: httpd >= 2.2 + +%description +Mirror is the rpm package for the official mirror.example.com installation. + +%prep +%setup + +%build + +%install +rsync -a . %{buildroot}/ + +%clean +rm -rf ${buildroot} + +%pre + +%post + +%preun + +%files +%config /etc/sudoers.d/50_mirror-sudo +%config /etc/cron.d/mirror.cron +/etc/mirror/mirror-master.sh +/etc/mirror/scripts/ssh +/etc/mirror/scripts/libreoffice +/etc/mirror/scripts/linuxmint-repos +/etc/mirror/scripts/ubuntu +/etc/mirror/scripts/putty +/etc/mirror/scripts/rsyslog +/etc/mirror/scripts/centos +/etc/mirror/scripts/fedora-epel +/etc/mirror/scripts/old-scripts.tgz +/etc/mirror/scripts/ubuntu-releases +/etc/mirror/scripts/linuxmint-isos +/etc/mirror/scripts/fedora-releases +/etc/mirror/scripts/fedora-updates +/etc/mirror/docs/debian/postinst +/etc/mirror/docs/debian/conffiles +/etc/mirror/docs/debian/prerm +/etc/mirror/docs/debian/postrm +/etc/mirror/docs/debian/control +/etc/mirror/docs/debian/preinst +%doc %attr(444, -, -) /etc/mirror/docs/README.txt +/etc/mirror/docs/mirror.spec +%doc %attr(444, -, -) /etc/mirror/docs/packaging.txt +%doc %attr(444, -, -) /etc/mirror/docs/files-for-versioning.txt +%config /etc/mirror/inc/deploy.conf +/etc/mirror/inc/pack +/etc/mirror/inc/localize_git.sh +/etc/mirror/inc/deploy.sh +%doc %attr(444, -, -) /etc/mirror/inc/scrub.txt +/etc/mirror/inc/rsync +/etc/mirror/examples/favicon.ico +/etc/mirror/examples/FOOTER.html +/etc/mirror/examples/HEADER.html +/etc/mirror/examples/example-debian/example-debian.list +/etc/mirror/examples/example-debian/update-example-debian.sh +/etc/mirror/examples/example-debian/FOOTER.html +/etc/mirror/examples/example-debian/HEADER.html +/etc/mirror/examples/example-debian/example-debian.gpg +/etc/mirror/examples/example-rpm/FOOTER.html +/etc/mirror/examples/example-rpm/HEADER.html +/etc/mirror/examples/example-rpm/example-rpm.repo +/etc/mirror/examples/example-rpm/update-example-rpm.sh +/etc/mirror/examples/favicon.png +%config /etc/mirror/mirror.conf +%config /etc/httpd/sites/10.1.8.63.conf +%config /etc/httpd/sites/mntscripts.conf +%config /etc/httpd/sites/mirror.conf +%verify(link) /usr/local/bin/deploy +/usr/share/httpd/icons/repo.png +/usr/share/httpd/icons/rpm.png diff --git a/usr/share/mirror/docs/packaging.txt b/usr/share/mirror/docs/packaging.txt new file mode 100644 index 0000000..a97d4c5 --- /dev/null +++ b/usr/share/mirror/docs/packaging.txt @@ -0,0 +1,35 @@ +File: etc/mirror/packaging.txt +Package: mirror +Author: bgstack15 +Startdate: 2016-06-09 +Title: Packaging instructions for mirror +Purpose: To make it easier to build the package +Usage: +Reference: bgscripts package packaging.txt +Improve: +Document: Below this line + +### PACKAGING for rhel/centos +rpmbuilddir=~/rpmbuild/ +package=mirror +version=1.0-5 +shortversion=1.0 +packagespecfile="${package}-${version}/etc/${package}/docs/${package}.spec" +sed -i -n '1,/^\%files$/p;' ${rpmbuilddir}/SOURCES/"${packagespecfile}" +cd ${rpmbuilddir}/SOURCES/"${package}-${version}" +find * ! -type d ! -regex '.*?.swp' ! -regex '.*?DEBIAN.*?' | sed -e 's/^/\//;' -e 's/\(.*\.txt\)/%doc %attr(444, -, -) \1/;' -e 's/\(.*\.\(conf\|cron\)\|.*sudoers\.d\)/%config \1/;' -e 's/\(.*bin.*\)/%verify(link) \1/;' -e 's/\(.*\)\.py$/\1\.py\n\1\.pyc\n\1\.pyo/;' >> ${rpmbuilddir}/SOURCES/"${packagespecfile}" +rm -rf ${rpmbuilddir}/SOURCES/"${package}-${shortversion}" +cp -prf ${rpmbuilddir}/SOURCES/"${package}-${version}" ${rpmbuilddir}/SOURCES/"${package}-${shortversion}" +rm -rf ${rpmbuilddir}/SOURCES/"${package}-${shortversion}"/DEBIAN +cd ${rpmbuilddir}/SOURCES +rm -rf "${package}".tgz; tar -zc --exclude='.git' -f "${package}.tgz" "${package}-${shortversion}" && rm -rf ${rpmbuilddir}/SOURCES/"${package}-${shortversion}" +cp -p ${rpmbuilddir}/SOURCES/"${packagespecfile}" ${rpmbuilddir}/SPECS +cd ${rpmbuilddir}/RPMS/noarch +rpmbuild -bb "${rpmbuilddir}"/SPECS/"${package}".spec + +### PACKAGING in a master.tgz +cd ~/deb 2>/dev/null || cd ~/rpmbuild/SOURCES +package=mirror +version=1.0-5 +rm -rf ./"${package}-${version}".master.tgz +tar -zcf "${package}-${version}".master.tgz "${package}-${version}"/ diff --git a/usr/share/mirror/examples/FOOTER.html b/usr/share/mirror/examples/FOOTER.html new file mode 100644 index 0000000..517920b --- /dev/null +++ b/usr/share/mirror/examples/FOOTER.html @@ -0,0 +1,5 @@ + + +Favicon licensed CC BY 3.0 by Lorc. Available on http://game-icons.net/ + + diff --git a/usr/share/mirror/examples/HEADER.html b/usr/share/mirror/examples/HEADER.html new file mode 100644 index 0000000..1130cfc --- /dev/null +++ b/usr/share/mirror/examples/HEADER.html @@ -0,0 +1,48 @@ + + + + + Welcome to mirror.example.com + + + + +

Welcome to mirror.example.com

+ +
+
+ +This is IT's Open Source software +mirror. We have gobs of software here to save you time downloading it from the +internet. If you need ftp access, try ftp://mirror.example.com. + +

+ +If there is a project you would like to see mirrored, let us know at the e-mail +address at the bottom and we'll see what we can do. We can't guarantee your +favorite project will be mirrored, but if you have a reasonable request, we +will most likely be able to comply. + +

+ +WARNING! There is no guarantee that this box will always be +up or that the software contained on it will be up-to-date, bug-free, safe, +uncorrupted or complete. Use this box and the software contained on it +at your own risk. +Due to the nature of maintaining this box, IT cannot take any responsibility +for problems or damage incurred by the software from this box. Please +DO NOT contact the Helpdesk with problems or questions concerning +this box. If you have questions, comments, or problem reports, contact mirror Administrator. However, as this is an "unofficial" +IT project, any response may be highly delayed. +

+That being said, have fun! +E-Mail the administrator at: mirror@example.com. +


+ +
+Force http: http://mirror.example.com +Force https: https://mirror.example.com
+ + diff --git a/usr/share/mirror/examples/example-debian/FOOTER.html b/usr/share/mirror/examples/example-debian/FOOTER.html new file mode 100644 index 0000000..7879e1c --- /dev/null +++ b/usr/share/mirror/examples/example-debian/FOOTER.html @@ -0,0 +1,4 @@ + + + + diff --git a/usr/share/mirror/examples/example-debian/HEADER.html b/usr/share/mirror/examples/example-debian/HEADER.html new file mode 100644 index 0000000..6ffade1 --- /dev/null +++ b/usr/share/mirror/examples/example-debian/HEADER.html @@ -0,0 +1,13 @@ + +mirror.example.com/ubuntu/example-debian repository + +

mirror.example.com/bgscripts

+
+

You can install the example-debian repo in the /etc/apt/sources.list.d/ directory with these command: +

+sudo wget --quiet http://mirror.example.com/ubuntu/example-debian/example-debian.gpg -O /root/example-debian.gpg
+sudo apt-key add /root/example-debian.gpg	
+sudo wget --quiet http://mirror.example.com/ubuntu/example-debian/example-debian.list -O /etc/apt/sources.list.d/example-debian.list
+
+ + diff --git a/usr/share/mirror/examples/example-debian/example-debian.gpg b/usr/share/mirror/examples/example-debian/example-debian.gpg new file mode 100644 index 0000000..d64a765 --- /dev/null +++ b/usr/share/mirror/examples/example-debian/example-debian.gpg @@ -0,0 +1,51 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v2.0.22 (GNU/Linux) + +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 +=ggDE +-----END PGP PUBLIC KEY BLOCK----- diff --git a/usr/share/mirror/examples/example-debian/example-debian.list b/usr/share/mirror/examples/example-debian/example-debian.list new file mode 100644 index 0000000..ad21fbb --- /dev/null +++ b/usr/share/mirror/examples/example-debian/example-debian.list @@ -0,0 +1 @@ +deb http://mirror.example.com/ubuntu/example-debian/ / diff --git a/usr/share/mirror/examples/example-debian/update-example-debian.sh b/usr/share/mirror/examples/example-debian/update-example-debian.sh new file mode 100755 index 0000000..0a6e7a0 --- /dev/null +++ b/usr/share/mirror/examples/example-debian/update-example-debian.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# working directory +repodir=/mnt/mirror/ubuntu/example-debian/ +cd ${repodir} +chmod 0644 *deb 1>/dev/null 2>&1 + +# create the package index +dpkg-scanpackages -m . > Packages +cat Packages | gzip -9c > Packages.gz + +# create the Release file +PKGS=$(wc -c Packages) +PKGS_GZ=$(wc -c Packages.gz) +cat < Release +Architectures: all +Date: $(date -R) +MD5Sum: + $(md5sum Packages | cut -d" " -f1) $PKGS + $(md5sum Packages.gz | cut -d" " -f1) $PKGS_GZ +SHA1: + $(sha1sum Packages | cut -d" " -f1) $PKGS + $(sha1sum Packages.gz | cut -d" " -f1) $PKGS_GZ +SHA256: + $(sha256sum Packages | cut -d" " -f1) $PKGS + $(sha256sum Packages.gz | cut -d" " -f1) $PKGS_GZ +EOF +gpg --batch --yes --passphrase-file /root/.gnupg/linuxadmin -abs -o Release.gpg Release diff --git a/usr/share/mirror/examples/example-rpm/FOOTER.html b/usr/share/mirror/examples/example-rpm/FOOTER.html new file mode 100644 index 0000000..57b6775 --- /dev/null +++ b/usr/share/mirror/examples/example-rpm/FOOTER.html @@ -0,0 +1,8 @@ + + +mirror.example.com/example-rpm repository + + +

Most contents are licensed under CC BY-SA 4.0.

+ + diff --git a/usr/share/mirror/examples/example-rpm/HEADER.html b/usr/share/mirror/examples/example-rpm/HEADER.html new file mode 100644 index 0000000..105f0d8 --- /dev/null +++ b/usr/share/mirror/examples/example-rpm/HEADER.html @@ -0,0 +1,9 @@ + + +

mirror.example.com/example-rpm

+
+

You can install the example-rpm.repo in the /etc/yum.repos.d/ directory with this command: +

wget http://mirror.example.com/example-rpm/example-rpm.repo -O /etc/yum.repos.d/example-rpm.repo
+yum -y install bgscripts keepalive
+ + diff --git a/usr/share/mirror/examples/example-rpm/example-rpm.repo b/usr/share/mirror/examples/example-rpm/example-rpm.repo new file mode 100644 index 0000000..12bca22 --- /dev/null +++ b/usr/share/mirror/examples/example-rpm/example-rpm.repo @@ -0,0 +1,8 @@ +# example-rpm.repo +# Install with: +# wget http://mirror.example.com/bgscripts/example-rpm.repo -O /etc/yum.repos.d/example-rpm.repo +[example-rpm] +name=example-rpm +baseurl=http://mirror.example.com/bgscripts/ +gpgcheck=0 +#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 diff --git a/usr/share/mirror/examples/example-rpm/update-example-rpm.sh b/usr/share/mirror/examples/example-rpm/update-example-rpm.sh new file mode 100755 index 0000000..b3003af --- /dev/null +++ b/usr/share/mirror/examples/example-rpm/update-example-rpm.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# working directory +repodir=/mnt/mirror/bgscripts/ +cd ${repodir} +chmod 0644 *rpm 1>/dev/null 2>&1 + +# create the package index +createrepo . diff --git a/usr/share/mirror/examples/favicon.ico b/usr/share/mirror/examples/favicon.ico new file mode 100644 index 0000000..28e780c Binary files /dev/null and b/usr/share/mirror/examples/favicon.ico differ diff --git a/usr/share/mirror/examples/favicon.png b/usr/share/mirror/examples/favicon.png new file mode 100644 index 0000000..fce9365 Binary files /dev/null and b/usr/share/mirror/examples/favicon.png differ diff --git a/usr/share/mirror/inc/localize_git.sh b/usr/share/mirror/inc/localize_git.sh new file mode 100755 index 0000000..e386977 --- /dev/null +++ b/usr/share/mirror/inc/localize_git.sh @@ -0,0 +1,2 @@ +#!/bin/sh +\cp -pRf /home/work/mirror.clean/.git /home/bgstack15/rpmbuild/SOURCES/mirror-1.0-7/ diff --git a/usr/share/mirror/inc/pack b/usr/share/mirror/inc/pack new file mode 100755 index 0000000..99ec477 --- /dev/null +++ b/usr/share/mirror/inc/pack @@ -0,0 +1,100 @@ +#!/bin/bash + +# DETERMINE LOCATION OF FRAMEWORK +while read flocation; do if test -x ${flocation} && test "$( ${flocation} --fcheck )" -ge 20170111; then frameworkscript="${flocation}"; break; fi; done <&2 && exit 4 + +. ${frameworkscript} || echo "$0: framework did not run properly. Continuing..." 1>&2 + +type=""; + +case "${thisflavor}" in + redhat|rhel|centos|fedora|korora) type=rpm;; + debian|ubuntu) type=dpkg;; + *) type=targz;; +esac + +echo " $@ " | grep -qiE -- "help|usage|\s-h\s|\s-\?" 1>/dev/null 2>&1 && { + # display help and exit + less -F </dev/null 2>&1 && type=rpm +echo " $@ " | grep -qiE -- "debian|ubuntu|deb\s|dpkg" 1>/dev/null 2>&1 && type=dpkg +echo " $@ " | grep -qiE -- "tar|tgz|gz" 1>/dev/null 2>&1 && type=targz +echo " $@ " | grep -qiE -- "scrub" 1>/dev/null 2>&1 && type=scrub + +# Display information +echo "packaging ${package}-${version} as ${type}" +echo " $@ " | grep -qiE -- "debug|\s-d[ 0-9]{0,3}\s" 1>/dev/null 2>&1 && exit 0 + +case "${type}" in + rpm) + +########## PACKAGING for rhel/centos +# if you copy-paste this, be sure to define package, version, shortversion +rpmbuilddir=~/rpmbuild/ +packagespecfile="${package}-${version}/etc/${package}/docs/${package}.spec" +sed -i -n '1,/^\%files$/p;' "${rpmbuilddir}/SOURCES/${packagespecfile}" +cd "${rpmbuilddir}/SOURCES/${package}-${version}" +find * ! -type d ! -regex '.*?.swp' ! -regex '.*?DEBIAN.*?' | sed -e 's/^/\//;' -e 's/\(.*\.txt\)/%doc %attr(444, -, -) \1/;' -e 's/\(.*\.\(conf\|cron\)\|.*sudoers\.d\)/%config \1/;' -e 's/\(.*bin.*\)/%verify(link) \1/;' -e 's/\(.*\)\.py$/\1\.py\n\1\.pyc\n\1\.pyo/;' >> "${rpmbuilddir}/SOURCES/${packagespecfile}" +rm -rf "${rpmbuilddir}/SOURCES/${package}-${shortversion}" +cp -prf "${rpmbuilddir}/SOURCES/${package}-${version}" "${rpmbuilddir}/SOURCES/${package}-${shortversion}" +rm -rf "${rpmbuilddir}/SOURCES/${package}-${shortversion}/DEBIAN" +cd "${rpmbuilddir}/SOURCES" +rm -rf "${package}.tgz"; tar -zc --exclude='.git' -f "${package}.tgz" "${package}-${shortversion}" && rm -rf "${rpmbuilddir}/SOURCES/${package}-${shortversion}/" +cp -p "${rpmbuilddir}/SOURCES/${packagespecfile}" "${rpmbuilddir}/SPECS" +cd "${rpmbuilddir}/RPMS/noarch" +rpmbuild -bb "${rpmbuilddir}/SPECS/${package}.spec" +rm -rf "${rpmbuilddir}/SOURCES/${package}.tgz" + + ;; + dpkg) + +########## PACKAGING for ubuntu +# You need package dpkg-dev to build packages. +# if you copy-paste this, be sure to define package, version +debdir=~/deb +echo "Gotta say unh. Deb format for ${package} has not yet been implemented. Aborted." +exit 1 + + ;; + targz) + +########## PACKAGING in a master.tgz +# if you copy-paste this, be sure to define package, version +cd ~/deb 2>/dev/null || cd ~/rpmbuild/SOURCES +rm -rf "./${package}-${version}.master.tgz" +tar -zcf "${package}-${version}.master.tgz" "${package}-${version}/" + + ;; + scrub) + +########## SCRUB for publication +# if you copy-paste this, be sure to define package, version +cd ~/deb 2>/dev/null || cd ~/rpmbuild/SOURCES +cd "$( find . -name "*scrub.txt" | grep -iE "${package}-${version}\/" | xargs dirname )" +/usr/share/bgscripts/scrub.py + + ;; + unknown) + echo "error: check $0 for errors on type ${type}." 1>&2 + ;; +esac diff --git a/usr/share/mirror/inc/rsync b/usr/share/mirror/inc/rsync new file mode 100644 index 0000000..710ecb7 --- /dev/null +++ b/usr/share/mirror/inc/rsync @@ -0,0 +1,38 @@ +#!/bin/sh +# +# rsync: Specific functions and options for rsync use +# Original source may be from David Lowry but is uncertain. + +#RSYNCOPTIONS="--delete-during -l -p -r -t -v" +RSYNCOPTIONS="-rlptv --del" +MIRRORDIR='/mnt/mirror' + +function rmirror { + if [ -z "$2" ] ; then + echo "Usage: rmirror SOURCE DEST [EXCLUDES...]" + echo "Example: rmirror localhost:pub/project project stuff morestuff" + exit 1 + fi + + SOURCE=$1; shift + DEST=$1; shift + EXCLUDES= + + if [ ! -d "$MIRRORDIR/$DEST" ] ; then + mkdir "$MIRRORDIR/$DEST" + fi + + for OPT in $*; do + EXCLUDES="$EXCLUDES --exclude=$OPT" + done + + #date + echo rsync $RSYNCOPTIONS "$SOURCE/" "$MIRRORDIR/$DEST" $EXCLUDES + rsync $RSYNCOPTIONS "$SOURCE/" "$MIRRORDIR/$DEST" $EXCLUDES || exit 1 + #date +} + +function rmirrorn { + RSYNCOPTIONS="-n $RSYNCOPTIONS" + rmirror $* +} diff --git a/usr/share/mirror/inc/scrub.txt b/usr/share/mirror/inc/scrub.txt new file mode 100644 index 0000000..f7d5b53 --- /dev/null +++ b/usr/share/mirror/inc/scrub.txt @@ -0,0 +1,29 @@ +# for scrubpy version 2016-11-16a or newer +source /home/bgstack15/rpmbuild/SOURCES/mirror-1.0-7 +target /home/work/mirror.clean +ignore "tgz png gif jpg pyc pyo git swp ico" +# rest of the lines are "OLD WORD" "NEW WORD" +BGSTACK15 BGSTACK15 +Bgstack15 Bgstack15 +bgstack15 bgstack15 +BNAME BNAME +Bname Bname +bname bname +STACK15 STACK15 +Stack15 Stack15 +stack15 stack15 +Alice Alice +alice alice +User1 User1 +user1 user1 +Luser1 Auser1 +luser1 auser1 +EXAMPLE EXAMPLE +example example +".COM" ".COM" +".com" ".com" +"203.0." "203.0." +SMITH123 SMITH123 +Smith123 Smith123 +smith123 smith123 +one one diff --git a/usr/share/mirror/mirror-master.sh b/usr/share/mirror/mirror-master.sh new file mode 100755 index 0000000..8c7f33e --- /dev/null +++ b/usr/share/mirror/mirror-master.sh @@ -0,0 +1,287 @@ +#!/bin/sh +# Filename: mirror-master.sh +# Location: /usr/share/mirror/mirror.sh +# Author: bgstack15@gmail.com +# Startdate: 2015-12-14 08:52:20 +# Title: Master Mirror Script +# Purpose: Wraps around individual mirror scripts and logs nicely +# Package: +# History: +# 2016-01-07 Fixed logic for detecting already-running instance +# 2016-06-08 Modified to use mirror.conf config file, for mirror-1.0-2 +# 2017-01-11 Updated new location for framework +# 2017-02-06 rearranged mirror package to FHS 3.0 +# Usage: Call in cron every day +# Reference: ftemplate.sh 2015-11-23a; framework.sh 2015-11-23a +# mirror.luser1 (2014-11-11) +# Improve: +fiversion="2015-11-23a" +mirrormasterversion="2017-02-06a" + +usage() { + less -F >&2 <&2 2>/dev/null + rm -f $lockfile >/dev/null 2>&1 + trap '' 0 + [ ] #use at end of entire script if you need to clean up tmpfiles +} + +function CTRLC { + #trap "CTRLC" 2 + [ ] #useful for controlling the ctrl+c keystroke +} + +function CTRLZ { + #trap "CTRLZ" 18 + [ ] #useful for controlling the ctrl+z keystroke +} + +function parseFlag { + flag=$1 + hasval=0 + case $flag in + # INSERT FLAGS HERE + "d" | "debug" | "DEBUG" | "dd" ) setdebug; ferror "debug level ${debug}";; + "u" | "usage" | "help") usage; exit 1;; + "V" | "fcheck" | "version") ferror "${scriptfile} version ${mirrormasterversion}"; exit 1;; + #"i" | "infile" | "inputfile") getval;infile1=$tempval;; + "f" | "file" | "conf" | "config") getval; conffile="${tempval}";; + "scriptsdir") getval; scriptsdir="${tempval}";; + esac + + debuglev 10 && { [[ hasval -eq 1 ]] && ferror "flag: $flag = $tempval" || ferror "flag: $flag"; } +} + +# DETERMINE LOCATION OF FRAMEWORK +while read flocation; do if [[ -x $flocation ]] && [[ $( $flocation --fcheck ) -ge 20160525 ]]; then frameworkscript=$flocation; break; fi; done <&2 && exit 4 + +# INITIALIZE VARIABLES +# variables set in framework: +# today server thistty scriptdir scriptfile scripttrim +# is_cronjob stdin_piped stdout_piped stderr_piped sendsh sendopts +. ${frameworkscript} || echo "$0: framework did not run properly. Continuing..." 1>&2 +infile1= +outfile1= +# DEFAULTS unless overwritten by the mirror.conf or command line +lockfile=/var/lock/mirror.lock +logdir=/var/log/mirror/; mkdir -p ${logdir} 2>/dev/null; +logfile=${logdir}/mirror.${today}.log +errorfile=${logdir}/mirror.${today}.err +scriptsdirdefault=/etc/mirror/scripts +scriptsdir="${scriptsdirdefault}" +interestedparties="root" +keeplogs=14 +options= +conffiledefault=/etc/mirror/mirror.conf +conffile="${conffiledefault}" + +# REACT TO ROOT STATUS +case $is_root in + 1) # proper root + [ ] ;; + sudo) # sudo to root + [ ] ;; + "") # not root at all + if [[ ! $(whoami) = "mirror" ]]; + then + ferror "${scriptfile}: 5. Please run as root or sudo. Aborted." + exit 5 + fi + ;; +esac + +# SET CUSTOM SCRIPT AND VALUES +#setval 1 sendsh sendopts</dev/null; + then + # lockfile exists and points to a valid running process + ferror "${scriptfile}: 2. Mirror is already running. Aborted." + exit 2 + else + rm ${lockfile} + fi +fi + +# Lock the queue +if ! touch ${lockfile}; +then + ferror "${scriptfile}: 2. Could not create lockfile ${lockfile}. Aborted." + exit 2 +else + echo "$$" > ${lockfile} +fi + +# Ensure files can be created +for word in ${logfile} ${errorfile}; +do + if ! touch ${word}; + then + ferror "${scriptfile}: 3. Could not modify file ${word}. Aborted." + exit 3 + fi +done + +# Perform logfile cleanup +if [ -n ${keeplogs} ]; +then + find "${logdir}" -type f -mtime "+${keeplogs}" -exec rm -f {} \; 2>/dev/null +fi + +# MAIN LOOP +exec 3>&1 +{ + { + debugstring= + debuglev 1 && debugstring="debugging " + flecho "BEGIN ${debugstring}mirror" + flecho "BEGIN ${debugstring}errors" 1>&2 + + if [ -n thiscount ] && [[ thiscount -ge 1 ]]; + then + for word in ${fallopts}; + do + thisfile=$( find ${scriptsdir} -type f -perm /o=x -name "${word}" ) + if debuglev 1; + then + [[ -f "${thisfile}" ]] && \ + echo "${thisfile}" || \ + flecho "not found: ${scriptsdir}/${word}. Skipped." 1>&2 + else + [[ -f "${thisfile}" ]] && \ + find ${scriptsdir} -type f -perm /o=x -name "${word}" -exec {} $options \; || \ + flecho "not found: ${scriptsdir}/${word}. Skipped." 1>&2 + fi + done + else + if debuglev 1; + then + find "${scriptsdir}" -type f -perm /o=x + else + find "${scriptsdir}" -type f -perm /o=x -exec {} $options \; + fi + fi + + flecho "END ${debugstring}mirror" + flecho "END ${debugstring}errors" 1>&2 + } 2>&1 1>&3 | tee -a ${errorfile} 1>&2 +} 3>&1 | tee -a $logfile + +# EMAIL LOGFILE +# will only get here if not interrupted by user input +cat ${errorfile} >> ${logfile} +#$sendsh $sendopts "$server $scriptfile out" $logfile $interestedparties diff --git a/usr/share/mirror/scripts/centos b/usr/share/mirror/scripts/centos new file mode 100755 index 0000000..b812bde --- /dev/null +++ b/usr/share/mirror/scripts/centos @@ -0,0 +1,7 @@ +#!/bin/sh +# File: /etc/mirror/scripts/centos +# ftp://mirror.nandomedia.com/pub/CentOS/ + +source /etc/mirror/inc/rsync + +rmirror mirrors.kernel.org::centos centos '[234]*/' 'alpha/' 's390*/' 'ia64/' diff --git a/usr/share/mirror/scripts/fedora-epel b/usr/share/mirror/scripts/fedora-epel new file mode 100755 index 0000000..88f0c77 --- /dev/null +++ b/usr/share/mirror/scripts/fedora-epel @@ -0,0 +1,7 @@ +#!/bin/sh +# File: /etc/mirror/scripts/fedora-epel +# + +source /etc/mirror/inc/rsync + +rmirror mirror.cogentco.com::fedora-epel fedora/epel 4/ testing/ diff --git a/usr/share/mirror/scripts/fedora-releases b/usr/share/mirror/scripts/fedora-releases new file mode 100755 index 0000000..b7d0928 --- /dev/null +++ b/usr/share/mirror/scripts/fedora-releases @@ -0,0 +1,8 @@ +#!/bin/sh +# File: /etc/mirror/scripts/fedora-releases +# + +source /etc/mirror/inc/rsync + +rmirror mirrors.kernel.org::fedora/releases fedora/linux/releases 21/ 22/ 23/ test/ */Live */debug */armhfp + diff --git a/usr/share/mirror/scripts/fedora-updates b/usr/share/mirror/scripts/fedora-updates new file mode 100755 index 0000000..4ba729d --- /dev/null +++ b/usr/share/mirror/scripts/fedora-updates @@ -0,0 +1,7 @@ +#!/bin/sh +# File: /etc/mirror/scripts/fedora-updates +# + +source /etc/mirror/inc/rsync + +rmirror mirror.lstn.net::fedora-enchilada/updates fedora/linux/updates '[89]/' '1[0-9]/' '2[0-3]/' testing/ */ppc */ppc64 */armhfp diff --git a/usr/share/mirror/scripts/libreoffice b/usr/share/mirror/scripts/libreoffice new file mode 100755 index 0000000..cf88808 --- /dev/null +++ b/usr/share/mirror/scripts/libreoffice @@ -0,0 +1,7 @@ +#!/bin/sh +# File: /etc/mirror/scripts/libreoffice +# https://wiki.documentfoundation.org/Infra/Mirroring#Example_commands + +# + +rsync --no-motd -rlptH -hi --delete rsync://rsync.documentfoundation.org/tdf-pub/ /mnt/mirror/tdf diff --git a/usr/share/mirror/scripts/linuxmint-isos b/usr/share/mirror/scripts/linuxmint-isos new file mode 100755 index 0000000..674f96e --- /dev/null +++ b/usr/share/mirror/scripts/linuxmint-isos @@ -0,0 +1,7 @@ +#!/bin/sh +# File: /etc/mirror/scripts/linuxmint +# + +source /etc/mirror/inc/rsync + +rmirror rsync://ftp.heanet.ie/pub/linuxmint.com linuxmint/isos diff --git a/usr/share/mirror/scripts/linuxmint-repos b/usr/share/mirror/scripts/linuxmint-repos new file mode 100755 index 0000000..d73136c --- /dev/null +++ b/usr/share/mirror/scripts/linuxmint-repos @@ -0,0 +1,7 @@ +#!/bin/sh +# File: /etc/mirror/scripts/linuxmint +# + +source /etc/mirror/inc/rsync + +rmirror rsync://rsync-packages.linuxmint.com/packages linuxmint/packages diff --git a/usr/share/mirror/scripts/old-scripts.tgz b/usr/share/mirror/scripts/old-scripts.tgz new file mode 100644 index 0000000..c4abc34 Binary files /dev/null and b/usr/share/mirror/scripts/old-scripts.tgz differ diff --git a/usr/share/mirror/scripts/putty b/usr/share/mirror/scripts/putty new file mode 100755 index 0000000..82e7edd --- /dev/null +++ b/usr/share/mirror/scripts/putty @@ -0,0 +1,13 @@ +#!/bin/sh +# File: /etc/mirror/scripts/putty +# + +source /etc/mirror/inc/rsync + +rmirror rsync.chiark.greenend.org.uk::ftp/users/sgtatham/putty-website-mirror putty + +# make symlink for latest +rm -f /mnt/mirror/putty/latest +latest=$( find /mnt/mirror/putty/* -maxdepth 0 -type d -regex '.*[0-9]\.[0-9][0-9].*' | sort -n | tail -n1 ) +latest=${latest##*/} +ln -s "${latest}" /mnt/mirror/putty/latest diff --git a/usr/share/mirror/scripts/rsyslog b/usr/share/mirror/scripts/rsyslog new file mode 100755 index 0000000..8776f43 --- /dev/null +++ b/usr/share/mirror/scripts/rsyslog @@ -0,0 +1,12 @@ +#!/bin/sh +# File: /etc/mirror/scripts/rsyslog +# Reference: http://www.freeside.biz/mediawiki/index.php/Freeside:Documentation:MirroringRPMRepo + +source /etc/mirror/inc/rsync + +mkdir -p /mnt/mirror/rsyslog >/dev/null 2>&1 +cd /mnt/mirror/rsyslog +wget --mirror -nv -nH -np http://rpms.adiscon.com/v8-stable/ + +echo "Removing index.html files:" +find /mnt/mirror/rsyslog -name 'index.html*' -print -exec /bin/rm {} \; diff --git a/usr/share/mirror/scripts/ssh b/usr/share/mirror/scripts/ssh new file mode 100755 index 0000000..d08f629 --- /dev/null +++ b/usr/share/mirror/scripts/ssh @@ -0,0 +1,7 @@ +#!/bin/sh +# File: /etc/mirror/scripts/ssh +# + +source /etc/mirror/inc/rsync + +rmirror mirrors.nycbug.org::OpenBSD/OpenSSH ssh diff --git a/usr/share/mirror/scripts/ubuntu b/usr/share/mirror/scripts/ubuntu new file mode 100755 index 0000000..b575ba6 --- /dev/null +++ b/usr/share/mirror/scripts/ubuntu @@ -0,0 +1,7 @@ +#!/bin/sh +# File: /etc/mirror/scripts/ubuntu/ubuntu +# + +source /etc/mirror/inc/rsync + +rmirror archive.ubuntu.com::ubuntu ubuntu/ubuntu *breezy* *warty* *hoary* *dapper* *edgy* *feisty* gutsy* intrepid* jaunty* karmic* lucid* maverick* natty* oneiric* quantal* raring* saucy* vivid* wily* *[_-]powerpc* *[_-]sparc* *[_-]ia64* pool/**/*.tar.* *.diff.gz* *.dsc source/ diff --git a/usr/share/mirror/scripts/ubuntu-releases b/usr/share/mirror/scripts/ubuntu-releases new file mode 100755 index 0000000..14a2406 --- /dev/null +++ b/usr/share/mirror/scripts/ubuntu-releases @@ -0,0 +1,7 @@ +#!/bin/sh +# File: /etc/mirror/scripts/ubuntu-releases +# + +source /etc/mirror/inc/rsync + +rmirror rsync://mirrors.us.kernel.org/ubuntu-releases/ ubuntu/releases edubuntu/ *powerpc* *sparc* *-4.*-* *-5.*-* *-6.*-* -- cgit