diff options
author | Chris Severance | 2017-06-26 14:27:17 -0400 |
---|---|---|
committer | Chris Severance | 2017-06-26 14:27:17 -0400 |
commit | bcdfe5f385df1c77c6af6d9d6fe7d7faf5df8cd2 (patch) | |
tree | b89945557051fd94cba475eef1c7a73dca1437a8 | |
parent | 2dd7069c709677e04e71fb217cef97ab63c465af (diff) | |
download | aur-bcdfe5f385df1c77c6af6d9d6fe7d7faf5df8cd2.tar.gz |
Revamp for 3.4.5, some breaking changes
-rw-r--r-- | .SRCINFO | 67 | ||||
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | PKGBUILD | 695 | ||||
-rw-r--r-- | amanda.install | 138 | ||||
-rw-r--r-- | tapetypes.txt | 35 | ||||
-rw-r--r-- | xinetd.amanda | 13 | ||||
-rw-r--r-- | xinetd.amanda.tcp | 18 | ||||
-rw-r--r-- | xinetd.amanda.udp | 18 |
8 files changed, 869 insertions, 118 deletions
@@ -1,26 +1,71 @@ # Generated by mksrcinfo v8 -# Wed Jun 15 00:14:25 UTC 2016 +# Mon Jun 26 18:22:30 UTC 2017 pkgbase = amanda - pkgdesc = Advanced Maryland Automatic Network Disk Archiver - pkgver = 3.3.9 + pkgdesc = Advanced Maryland Automatic Network Disk Archiver network backup for Linux Windows clients, supports SSH, AES, GPG, encryption, tape, RAIT, mirror, changers, Amazon S3, ipv6, DVD, NDMP, VTL, advanced scripting + pkgver = 3.4.5 pkgrel = 1 url = http://www.amanda.org install = amanda.install arch = i686 arch = x86_64 license = custom + license = GPL + makedepends = swig + makedepends = grep + makedepends = splint + makedepends = gettext + makedepends = sed depends = perl>=5.6.0 depends = glib2>=2.2.0 depends = gawk - depends = gnuplot depends = tar>=1.12 - depends = xinetd - optdepends = dump: for creating backups in dump format - optdepends = samba: for backing up Windows hosts - source = http://downloads.sourceforge.net/amanda/amanda-3.3.9.tar.gz - source = xinetd.amanda - sha256sums = 2520b95ca96f1d521d582b7c94bd631486e7029eda1de8e1887d74b323549a41 - sha256sums = f872bb0d1e35ecad0c9369b59f7a5061ba2711f8895b2d7a2684cd0079fa0420 + depends = gzip + depends = curl>=7.10 + depends = openssl + depends = openssh + depends = cron + depends = libarchive + depends = readline + depends = netcat + depends = sudo + depends = bash + depends = perl-encode-locale + depends = perl-io-socket-ssl + depends = perl-json + depends = perl-net-ssleay + depends = perl-uri + depends = perl-xml-namespacesupport + depends = perl-xml-parser + depends = perl-xml-sax + depends = perl-xml-simple + optdepends = gnuplot: amplot pictures + optdepends = dump: creating backups in dump format + optdepends = samba: backing up Windows hosts + optdepends = bzip2: better compression for dumptype + optdepends = xz: better compression for dumptype + optdepends = gnupg: amcrypt encryption + optdepends = aespipe: amcrypt encryption + optdepends = sharutils: amcrypt encryption with uuencode + optdepends = mt-st-git: manual tape drive control for blocksize, testing, and restore + optdepends = mtx-svn: advanced tape media changer support + optdepends = cups: printed reports + optdepends = mailx: email notifications + optdepends = ncompress: .Z compression + optdepends = xfsdump: direct XFS backup with xfsdump xfsrestore + optdepends = dump: direct EXT backup with dump restore + options = !strip + backup = etc/amanda-security.conf + backup = var/lib/amanda/.amandahosts + backup = etc/amanda/MyConfig/amanda.conf + backup = etc/amanda/MyConfig/disklist + source = https://prdownloads.sourceforge.net/amanda/amanda-3.4.5.tar.gz + source = xinetd.amanda.udp + source = xinetd.amanda.tcp + source = tapetypes.txt + sha256sums = bf05ea512676c7520ccff8d711e17176ea2aec47f7c517669cee02e8ab201343 + sha256sums = 3db294c9d7c610e9c0d531dcc2725dbddf1213fad64f04bc7cf9b1b9c30e9803 + sha256sums = 46446a8dc4ee8ec39ed0a3e2636fb02a198565e8111abe8392c456da56a007ce + sha256sums = c368e7f9d6d1df703619476e0fcf06e841a7ec86a5a7b86dc499821fbb0a137e pkgname = amanda diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 8dd5d1066484..000000000000 --- a/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/src/ -/pkg/ -/amanda-*.tar.gz @@ -1,5 +1,48 @@ -# Maintainer: Phillip Smith <pkgbuild@phs.id.au> -# http://github.com/fukawi2/aur-packages +# Maintainer: Chris Severance aur.severach aATt spamgourmet dott com +# Contributor: Phillip Smith <fukawi2@NO-SPAM.gmail.com> +# https://github.com/fukawi2/aur-packages + +# The Basic and Remote configurations are included. Some folders have been changed to +# align with current methods. +# http://wiki.zmanda.com/index.php/GSWA/Build_a_Basic_Configuration + +# Online guide for a single tape drive. +# http://www.resolveradiologic.com/blog/2017/01/16/how-to-set-up-amanda-to-backup-to-tape-in-ubuntu/ +# Don't add your tape drive to the existing file. An upgrade will overwrite it and disappear. +# Add it to /etc/amanda/TestConfig/tapetypes and add an includefile to amanda.conf + +# If your backup is not working, see if these demos work before reporting. You can also set some +# values back to legacy. + +# If you want to run amanda as a different user and/or group, change these +# variables before running makepkg +# Do not use existing users or groups like daemon or nobody. They will be altered then removed. +# These can be changed between upgrades. You must recompile for the change to take effect. +# Changing while a backup is running will cause problems. +_amandauser='amandabackup' # formerly amanda, too likely to collide with a real Amanda +_amandagroup='amandabackup' +_amandauid='112' +_amandagid='112' + +# Changing this requires a manual change to auth in amanda.conf +_opt_bsd='' # '' for none, 'tcp' or 'udp'. ssh is always available + +# The am helper utilities assume that the home folder is the same on all computers +_amhome='/var/lib/amanda' +#_amhome='/var/amanda' # legacy + +# Don't change any of the following settings between upgrades +_ametc='/etc/amanda' # changing this to /etc will destroy your /etc folder +#_amsecurity="${_ametc}/amanda-security.conf" # legacy, not compatible with amserverconfig +_amsecurity='/etc/amanda-security.conf' + +_amdump='/dumps' # Always in /, or at least outside of any folder you would want to back up. + +_amlibexec='/usr/lib' +#_amlibexec='/usr/libexec' # legacy, not liked by namcap, Arch does not use this folder + +_amlog='/var/log/amanda' +# /var/cache/amanda is only mentioned in help files ### I AM ONLY THE PACKAGER, NOT THE DEVELOPER ### Please ask support questions about this software in one of: @@ -11,106 +54,612 @@ ### If you have found a problem with the package/PKGBUILD (as opposed to ### the software) then please do email me or post an AUR comment. -pkgname=amanda -pkgver=3.3.9 -pkgrel=1 -pkgdesc="Advanced Maryland Automatic Network Disk Archiver" -url="http://www.amanda.org" +set -u +pkgname='amanda' +#pkgver='3.3.9' +pkgver='3.4.5' +pkgrel='1' +pkgdesc='Advanced Maryland Automatic Network Disk Archiver network backup for Linux Windows clients, supports SSH, AES, GPG, encryption, tape, RAIT, mirror, changers, Amazon S3, ipv6, DVD, NDMP, VTL, advanced scripting' arch=('i686' 'x86_64') -license=('custom') -depends=('perl>=5.6.0' 'glib2>=2.2.0' 'gawk' 'gnuplot' 'tar>=1.12' 'xinetd') +url='http://www.amanda.org' +license=('custom' 'GPL') +depends=('perl>=5.6.0' 'glib2>=2.2.0' 'gawk' 'tar>=1.12' 'gzip' 'curl>=7.10' 'openssl' 'openssh' 'cron' 'libarchive' 'readline' 'netcat' 'sudo' 'bash') +# perl-module-scandeps: cd pkg; scandeps.pl $(grep -lR '/usr/bin/perl' .) | sort -u | grep -v "^'Amanda::" +depends+=( + 'perl-encode-locale' + 'perl-io-socket-ssl' + 'perl-json' + 'perl-net-ssleay' + 'perl-uri' + 'perl-xml-namespacesupport' + 'perl-xml-parser' + 'perl-xml-sax' + 'perl-xml-simple' +) optdepends=( - 'dump: for creating backups in dump format' - 'samba: for backing up Windows hosts' - ) -install="$pkgname.install" -source=("http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz" "xinetd.${pkgname}") -sha256sums=('2520b95ca96f1d521d582b7c94bd631486e7029eda1de8e1887d74b323549a41' - 'f872bb0d1e35ecad0c9369b59f7a5061ba2711f8895b2d7a2684cd0079fa0420') - -# if you want to run amanda as a different user and/or group, change these -# variables before running makepkg -_amandauser='amanda' -_amandagroup='amanda' -_amandauid=112 -_amandagid=112 + 'gnuplot: amplot pictures' + 'dump: creating backups in dump format' + 'samba: backing up Windows hosts' + 'bzip2: better compression for dumptype' + 'xz: better compression for dumptype' + 'gnupg: amcrypt encryption' + 'aespipe: amcrypt encryption' + 'sharutils: amcrypt encryption with uuencode' + 'mt-st-git: manual tape drive control for blocksize, testing, and restore' # some tape drive support is built in + 'mtx-svn: advanced tape media changer support' # some changer support is built in + 'cups: printed reports' + 'mailx: email notifications' + 'ncompress: .Z compression' + #'git: taper transfer' # does not seem to be current + #'svn: ' # lots of references but no action + 'xfsdump: direct XFS backup with xfsdump xfsrestore' # This is why amanda needs to be in the disk group + 'dump: direct EXT backup with dump restore' # see sendsize.c for the OS of various dump programs +) +# grep 'checking for' config.log | cut -d' ' -f2- | sort -u | grep -v '\.h$' +makedepends=('swig' 'grep' 'splint' 'gettext' 'sed') +backup=( + "${_amsecurity#/}" + "${_amhome#/}/.amandahosts" + "${_ametc#/}/MyConfig/amanda.conf" # Assume that many users will build from the demo configuration + "${_ametc#/}/MyConfig/disklist" +) +options=('!strip') +install="${pkgname}.install" +_tapetypes=('tapetypes.txt') +_verwatch=('http://www.amanda.org/download.php' '\([0-9\.]\+\)' 't') +_srcdir="${pkgname}-${pkgver}" +source=("https://prdownloads.sourceforge.net/amanda/amanda-${pkgver}.tar.gz" "xinetd.${pkgname}".{udp,tcp} "${_tapetypes[@]}") +sha256sums=('bf05ea512676c7520ccff8d711e17176ea2aec47f7c517669cee02e8ab201343' + '3db294c9d7c610e9c0d531dcc2725dbddf1213fad64f04bc7cf9b1b9c30e9803' + '46446a8dc4ee8ec39ed0a3e2636fb02a198565e8111abe8392c456da56a007ce' + 'c368e7f9d6d1df703619476e0fcf06e841a7ec86a5a7b86dc499821fbb0a137e') -_devgroup='disk' -_amandahosts='var/amanda/.amandahosts' -_amandadates='var/amanda/amandates' -_amandadumpdates='var/amanda/dumpdates' -_amandagnutarlists='var/amanda/gnutar-lists' +if [ ! -z "${_opt_bsd}" ]; then + depends+=('xinetd') + backup+=('etc/xinetd.d/amanda') +fi +# (deprecated) upstream sources require amanda user and group exist at build time +# We capture the chown commands so this is no longer needed. +# This requirement made it hard for noobs with AUR helpers to install. _testAmandaUserGroup() { - if ! getent group $_amandagroup > /dev/null ; then + if ! getent group "${_amandagroup}" > /dev/null ; then error "The amanda group must exist prior to building." - error "Suggested command: groupadd -g $_amandagid $_amandagroup" + error "Suggested command: groupadd -g ${_amandagid} ${_amandagroup}" return 1 fi - if ! getent passwd $_amandauser > /dev/null ; then + if ! getent passwd "${_amandauser}" > /dev/null ; then error "The amanda user must exist prior to building." - error "Suggested command: useradd --system -u $_amandauid -g $_amandagroup -G storage,disk -m -d /var/amanda -s /bin/bash -c 'Amanda Backup Daemon' $_amandauser" + error "Suggested command: useradd --system -u ${_amandauid} -g ${_amandagroup} -G storage,disk -m -d ${_amhome} -s /bin/bash -c 'Amanda Backup Daemon' ${_amandauser}" return 2 fi } +unset -f _testAmandaUserGroup + +_install_check() { + # We can't modify .install but we can stop and force the user to fix it. + if ! grep -q "^_amlibexec='${_amlibexec}'"'$' "${startdir}/${install}"; then + set +u + msg "${install} _amlibexec must be fixed" + echo "_amlibexec='${_amlibexec}'" + false + fi + if ! grep -q "^_amsecurity='${_amsecurity}'"'$' "${startdir}/${install}"; then + set +u + msg "${install} _amsecurity must be fixed" + echo "_amsecurity='${_amsecurity}'" + false + fi + if ! grep -q "^_amhome='${_amhome}'"'$' "${startdir}/${install}"; then + set +u + msg "${install} _amhome must be fixed" + echo "_amhome='${_amhome}'" + false + fi +} + +prepare() { + set -u + cd "${_srcdir}" + _install_check + + if [ "${_amandauid}" -ge 1000 ]; then + echo "This package won't create UID >= 1000" + set +u + false + fi + + # rm -r 'packaging' # cleaner path listings, crashes make + # grep -shroe '/[a-z][a-z/]*/' | grep -e 'etc\|usr\|var' | sort -u + + # Get rid of sbin + sed -e 's:/sbin/:/bin/:g' -i 'example/amanda.conf.in' 'example/template.d/dumptypes' + + # Lots of confusion where the amanda home folder is + if [ "${_amhome}" != '/var/lib/amanda' ]; then + local _amhfiles + readarray -t _amhfiles <<<"$(grep -slire 'LOCALSTATEDIR.*/lib/amanda')" + sed -e '/LOCALSTATEDIR/I s:/lib/amanda:'"${_amhome#/var}:g" -i "${_amhfiles[@]}" + readarray -t _amhfiles <<<"$(grep -sliFre '/var/lib/amanda')" + sed -e "s:/var/lib/amanda:${_amhome}:g" -i "${_amhfiles[@]}" + fi + local _hfiles + readarray -t _hfiles <<<"$(grep -slrFe '/var/amanda/')" + sed -e "s:/usr/local/var/amanda:${_amhome}:g" -e "s:/var/amanda:${_amhome}:g" -i "${_hfiles[@]}" + readarray -t _hfiles <<<"$(grep -slrFe '/usr/local/etc/amanda')" + sed -e "s:/usr/local/etc/amanda:${_ametc}:g" -i "${_hfiles[@]}" + sed -e '/chg-disk/ s:/@prefix@::g' -i 'example/template.d/amanda-harddisk.conf.in' + + # Set the default auth to ssh if bsdtcp is not installed + if [ -z "${_opt_bsd}" ]; then + #cp -p 'server-src/amserverconfig.pl' 'server-src/amserverconfig.Arch.pl' # for diff comparison + sed -e '/print CONF/ s:bsdtcp:ssh:g' -i 'server-src/amserverconfig.pl' + #cp -p 'server-src/amaddclient.pl' 'server-src/amaddclient.Arch.pl' + sed -e '/^\$auth=/ s:bsdtcp:ssh:g' -i 'server-src/amaddclient.pl' + fi + + # Amend the tapetype file. Mark each line to be written with a >. Add a blank line after each entry. + pushd "${srcdir}" > /dev/null + sed -e '1i # Do not modify this file. It is overwritten on every upgrade' -i "${_srcdir}/example/template.d/tapetypes" + echo -e "# Added by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR\n# https://aur.archlinux.org/\n" >> "${_srcdir}/example/template.d/tapetypes" + sed -n -e 's:^>\(.*\)$:\1:p' "${_tapetypes[@]}" >> "${_srcdir}/example/template.d/tapetypes" + popd > /dev/null + + # Fix xinetd files. Our xinetd file is fixed in package() + sed -e "/^\s*user\s\+=/ s:amandabackup:${_amandauser}:g" \ + -e "/^\s*group\s\+=/ s:disk:${_amandagroup}:g" \ + -i 'example/xinetd.'* + set +u +} build() { - # upstream sources require amanda user and group exist at build time - _testAmandaUserGroup - - cd "$srcdir"/$pkgname-$pkgver - - ./configure --prefix=/usr \ - --sbindir=/usr/bin \ - --with-configdir=/etc/amanda \ - --with-gnutar-listdir=/var/amanda/gnutar-lists \ - --mandir=/usr/share/man \ - --with-user=$_amandauser \ - --with-group=$_amandagroup \ - --with-ipv6 \ - --with-ssh-security - - make + set -u + #_testAmandaUserGroup + cd "${_srcdir}" + _install_check + + if [ ! -s 'Makefile' ]; then + local _opts=() + if [ ! -z "${_opt_bsd}" ]; then + _opts+=("--with-bsd${_opt_bsd}-security") + fi + # There are configure flags to install only the client or server, but I don't see any reason to. + # Amanda's handling of /etc is so broken that we must specify it 3 times and fix it in package() + MT='/usr/bin/mt-st' \ + CFLAGS="${CFLAGS} -g -rdynamic" \ + CXXFLAGS="${CXXFLAGS} -g -rdynamic" \ + ./configure "${_opts[@]}" \ + --prefix='/usr' \ + --sbindir='/usr/bin' \ + --libexecdir="${_amlibexec}" \ + --sysconfdir='/etc' \ + --localstatedir='/var' \ + --with-configdir="${_ametc}" \ + --with-security-file="${_amsecurity}" \ + --with-gnutar-listdir="${_amhome}/gnutar-lists" \ + --mandir='/usr/share/man' \ + --with-user="${_amandauser}" \ + --with-group="${_amandagroup}" \ + --with-ipv6 \ + --with-ssh-security \ + --with-amandates="${_amhome}/amandates" \ + --with-tmpdir="/tmp/amandabackup-$$" + ! grep -F $'/usr/var\n/usr/etc' 'config.log' || echo "{}" + fi + + local _nproc="$(nproc)"; _nproc=$((_nproc>8?8:_nproc)) + nice make -j "${_nproc}" # not using -s helps + set +u } package() { - # upstream sources require amanda user and group exist at build time - _testAmandaUserGroup - - cd "$srcdir"/$pkgname-$pkgver - - # Install the compiled output - make DESTDIR="$pkgdir" install - - # symlink example directory - install -d -o root -g root -m 0750 "$pkgdir"/etc/$pkgname/ - ln -sf /usr/share/amanda/example/ "$pkgdir"/etc/$pkgname/example - + set -u + #_testAmandaUserGroup + cd "${_srcdir}" + _install_check + + # Obnoxious installer expects fakeroot. We'll capture chown & chmod commands to place them in .install + # A beneficial side affect is that improper permissions and owership will be fixed on every install/upgrade. + local _aminstall="${pkgdir}${_amlibexec}/amanda/amanda-install.sh" + install -Dpm755 <(cat << EOF +#!/bin/bash + +echo " chown\$(printf ' "%s"' "\${@}")" >> '${_aminstall}' +EOF + ) "${pkgdir}/chown" + + # Capture suid chmod, passthru normal chmod + install -Dpm755 <(cat << EOF +#!/bin/bash + +if [ "\$1" = '644' ] || [ "\$1" = '755' ]; then + # Pass through standard chmod + /usr/bin/chmod "\${@}" +else + echo " chmod\$(printf ' "%s"' "\${@}")" >> '${_aminstall}' +fi +EOF + ) "${pkgdir}/chmod" + + # Capture commands go into this script + install -Dpm744 <(cat << EOF +#!/bin/sh +# Created by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR +# https://aur.archlinux.org/ + +# This is run by the package installer which can't be modified +# to have all the current settings + +set -e +set -u + +# commands captured from Makefile + +_fn_chown_makefile() { +EOF + ) "${_aminstall}" + + # Install the compiled output using the PATH to capture chown/chmod commands + PATH="${pkgdir}:${PATH}" \ + make -j1 DESTDIR="${pkgdir}" install # not using -s helps + + # This file is put in the wrong place + if [ ! -s "${pkgdir}${_amsecurity}" ]; then + mv "${pkgdir}/etc/amanda/${_amsecurity##*/}" "${pkgdir}${_amsecurity}" + fi + + # Clean up capture and scripts + rm "${pkgdir}/chown" "${pkgdir}/chmod" + sed -e '# Trim pkgdir for .install' \ + -e "s:${pkgdir}::g" \ + -e '# Convert amanda group to var' \ + -e 's/"root:'"${_amandagroup}"'"/"root:${_amandagroup}"/g' \ + -i "${_aminstall}" + echo -e '}\n\n# Commands from PKGBUILD\n# must run before makefile above\n\n_fn_chown_PKGBUILD() {' >> "${_aminstall}" + + # Create amanda log dir, not much used + install -dm0770 "${pkgdir}${_amlog}/" + echo ' chmod 770 "${_amlog}"' >> "${_aminstall}" + echo ' chown "root:${_amandagroup}" "${_amlog}"' >> "${_aminstall}" + + # Create amanda home dir + install -dm0700 "${pkgdir}${_amhome}/" + echo ' chmod 700 "${_amhome}"' >> "${_aminstall}" + install -dm0700 "${pkgdir}${_amhome}/.ssh/" + echo ' chmod 700 "${_amhome}/.ssh/"' >> "${_aminstall}" + echo ' find "${_amhome}/.ssh" -type "f" -exec chmod 600 "{}" "+"' >> "${_aminstall}" + + # Set permission on config folders + install -dm0755 "${pkgdir}${_ametc}" + install -dm0750 "${pkgdir}${_ametc}/MyConfig" + if [ "${_ametc}" = '/etc' ] || [ "${_ametc}" = '/etc/' ]; then + echo 'The folder specified for ${_ametc} will destroy the system! Cant build package!' + set +u + false + else + echo ' find "${_ametc}" -mindepth 1 -maxdepth 1 -type "d" -exec chown -R "${_amandauser}:${_amandagroup}" "{}" ";" -exec chmod 750 "{}" ";"' >> "${_aminstall}" + fi + echo ' chown "root:${_amandagroup}" "${_ametc}"' >> "${_aminstall}" + echo ' chown "root:root" "${_amsecurity}"' >> "${_aminstall}" + echo ' chmod 644 "${_amsecurity}"' >> "${_aminstall}" + ln -s '/usr/share/amanda/example/' "${pkgdir}${_ametc}/example" + ln -s '/usr/share/amanda/example/' "${pkgdir}${_amhome}/example" + ln -s '/usr/share/amanda/template.d/' "${pkgdir}${_ametc}/template.d" + ln -s '/usr/share/amanda/template.d/' "${pkgdir}${_amhome}/template.d" + + # If amada-security.conf is placed in /etc/amanda then we must use + # a more restrictive permissions setup and a helper script to create + # the folder. amserverconfig doesn't work. + local _helpertext='' + if [ "${_amsecurity#/etc/amanda/}" != "${_amsecurity}" ]; then + echo ' chmod 755 "${_ametc}"' >> "${_aminstall}" + _helpertext=" with ${_ametc}/mkconfig.sh" + install -Dm755 <(cat << EOF +#!/bin/bash +# Created by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR +# https://aur.archlinux.org/ + +# This file is necessary because there are no permissions that will allow +# Amanda to backup and also allow Amanda to create folders here. + +set -e +set -u + +if [ "\$#" -eq 0 ] || [ "\${EUID}" -ne 0 ]; then + echo "Example: sudo ./mkconfig.sh MyConfig" + echo "This will create or fix the specified config folder with correct permissions" + echo "for the Amanda user" +else + while [ "\$#" -ne 0 ]; do + mkdir "${_ametc}/\$1" || : + chmod 750 "${_ametc}/\$1" + chown -R "${_amandauser}:${_amandagroup}" "${_ametc}/\$1" + shift + done +fi +EOF + ) "${pkgdir}${_ametc}/mkconfig.sh" + else + echo ' chmod 775 "${_ametc}"' >> "${_aminstall}" + chmod 775 "${pkgdir}${_ametc}" + _helpertext=" with amserverconfig" + fi + # Install xinetd configuration - install -D -o root -g root -m 0755 "$srcdir"/xinetd.$pkgname "$pkgdir"/etc/xinetd.d/$pkgname - - # Create some files - install -d -o $_amandauser -g $_devgroup -m 0700 "$pkgdir"/var/$pkgname/ + if [ ! -z "${_opt_bsd}" ]; then + install -Dpm0644 "${srcdir}/xinetd.amanda.${_opt_bsd}" "${pkgdir}/etc/xinetd.d/${pkgname}" + pushd "${srcdir}" >> /dev/null + local _xinetd + for _xinetd in "xinetd.${pkgname}".*; do + install -Dpm0644 "${_xinetd}" "${pkgdir}/etc/xinetd.d/${_xinetd#xinetd\.}" + done + popd > /dev/null + sed -e "/^\s*user\s\+=/ s:amanda:${_amandauser}:g" \ + -e "/^\s*group\s\+=/ s:storage:${_amandagroup}:g" \ + -e "/^\s*server\s\+=/ s:/usr/libexec:${_amlibexec}:g" \ + -i "${pkgdir}/etc/xinetd.d/${pkgname}"* + fi + # Can't put ${pkgver} on this one + install -Dm0600 <(cat << EOT +# Created by ${pkgname} PKGBUILD from Arch Linux AUR +# https://aur.archlinux.org/ + +# http://wiki.zmanda.com/index.php/How_To:Configure_bsdtcp_authentication - install -D -o $_amandauser -g $_devgroup -m 0600 /dev/null "$pkgdir"/$_amandahosts - cat > "$pkgdir"/var/$pkgname/.amandahosts << EOT # This is where amanda works out what remote connections to allow in the format # of <host> <username> <command> # # server1.example.com amanda amdump EOT + ) "${pkgdir}/${_amhome}/.amandahosts" + echo ' chmod 600 "${_amhome}/.amandahosts"' >> "${_aminstall}" # create some of the runtime files amanda requires so they are created with # the correct ownership and permissions. - install -D -o $_amandauser -g $_devgroup -m 0664 /dev/null "$pkgdir"/$_amandadates - install -D -o $_amandauser -g $_devgroup -m 0664 /dev/null "$pkgdir"/$_amandadumpdates - install -d -o $_amandauser -g $_devgroup -m755 "$pkgdir"/$_amandagnutarlists + install -Dm0664 /dev/null "${pkgdir}${_amhome}/amandates" # https://wiki.zmanda.com/index.php/Amanda:What_is_the_%27amandates%27_file_for%3F + #install -Dm0664 /dev/null "${pkgdir}${_amhome}/dumpdates" + install -dm755 "${pkgdir}${_amhome}/gnutar-lists" + echo ' chown -R "${_amandauser}:${_amandagroup}" "${_amhome}"' >> "${_aminstall}" + + # Prevent non amanda users from running these and causing unexpected errors. + # These chmod must be run after the ones from makefile so they take precedence + set +u; msg 'Fixing executable permissions'; set -u + local _amps + pushd "${pkgdir}/usr/bin" > /dev/null + readarray -t _amps <<<"$(find -mindepth 1 -maxdepth 1 -type 'f' -perm /111)" + chmod 754 "${_amps[@]}" + popd > /dev/null + local _amprogs="${_amps[*]#\./}" + echo "${_amprogs}" + _amprogs="${_amprogs// /,}" + echo ' chown "root:${_amandagroup}" "/usr/bin"'"/{${_amprogs}}" >> "${_aminstall}" + echo ' chmod 754 "/usr/bin"'"/{${_amprogs}}" >> "${_aminstall}" + + # Set up Wiki local demo to check with sudo -u 'amandabackup' amcheck 'MyConfig' + install -dm0750 "${pkgdir}${_amdump}" + install -dm0755 "${pkgdir}${_amhome}/holdings/MyConfig" + install -dm0755 "${pkgdir}${_amhome}/vtapes/MyConfig"/slot{1,2,3,4} + install -dm0755 "${pkgdir}${_ametc}/MyConfig"/{curinfo,index} + echo ' chown -R "${_amandauser}:${_amandagroup}" "${_amdump}"' >> "${_aminstall}" + # Using pkgver in files that are backed up would trigger .pacnew constantly + install -Dm0640 <(cat << EOF +# Created by ${pkgname} PKGBUILD from Arch Linux AUR +# https://aur.archlinux.org/ + +# You can extend this to be your backup. +# It would be better to create another backup${_helpertext} +# and let this stay a demo. + +# Local backup demo +# http://wiki.zmanda.com/index.php/GSWA/Build_a_Basic_Configuration + +# The Wiki has old folder names. The folders here match what the amanda programs use. + +# Examples: /usr/share/amanda/template.d/ + +org "MyConfig" +infofile "${_ametc}/MyConfig/curinfo" +logdir "${_ametc}/MyConfig" +indexdir "${_ametc}/MyConfig/index" +dumpuser "${_amandauser}" + +tpchanger "chg-disk:${_amhome}/vtapes/MyConfig" +labelstr "MyData[0-9][0-9]" +autolabel "MyData%%" EMPTY VOLUME_ERROR +tapecycle 4 +dumpcycle 3 days +amrecover_changer "changer" + +tapetype "TEST-TAPE" +define tapetype TEST-TAPE { + length 100 mbytes + filemark 4 kbytes +} + +define dumptype simple-gnutar-local { + auth "local" + compress none + program "GNUTAR" +} + +holdingdisk hd1 { + directory "${_amhome}/holdings/MyConfig" + use 50 mbytes + chunksize 1 mbyte +} + +# Remote backup demo +# This requires some ssh key management. See Wiki. +# http://wiki.zmanda.com/index.php/GSWA/Backing_Up_Other_Systems + +# see disklist for the matching line to enable +#define dumptype simple-gnutar-remote { +# auth "ssh" +# ssh_keys "/etc/amanda/MyConfig/ssh-key" +# compress none +# program "GNUTAR" +#} +EOF + ) "${pkgdir}${_ametc}/MyConfig/amanda.conf" + install -Dm0640 <(cat << EOF +# Created by ${pkgname} PKGBUILD from Arch Linux AUR +# https://aur.archlinux.org/ + +# Local backup demo +# http://wiki.zmanda.com/index.php/GSWA/Build_a_Basic_Configuration + +localhost /etc simple-gnutar-local + +# Remote backup demo +# http://wiki.zmanda.com/index.php/GSWA/Backing_Up_Other_Systems + +# see amanda.conf for the matching lines to enable +# euclid.amanda.org /etc simple-gnutar-remote +EOF + ) "${pkgdir}${_ametc}/MyConfig/disklist" + + # List of backup items for _aminstall + local _pacsavea=("${backup[@]/#/\/}") + _pacsavea=("${_pacsavea[@]/%/.pacsave}") + local _pacsave="$(printf " '%s'" "${_pacsavea[@]}")" + + # Finish _aminstall + cat >> "${_aminstall}" << EOF +} + +_fn_post_install() { + echo "Test the system with" + echo " sudo -u '${_amandauser}' amcheck 'MyConfig'" +} + +_fn_post_upins() { + if [ -z "\$(getent group "\${_amandagroup}")" ]; then + groupadd -g "\${_amandagid}" "\${_amandagroup}" + echo "amanda: Group \${_amandagroup} \${_amandagid} added" + fi + if [ -z "\$(getent passwd "\${_amandauser}")" ]; then + # Amanda is in the disk group so it can image drives using xfsrestore and other tools + useradd -u "\${_amandauid}" -g "\${_amandagroup}" -G "storage,disk" -m -d "\${_amhome}" -s '/bin/bash' -c 'Amanda Backup Daemon' "\${_amandauser}" + echo "amanda: User \${_amandauser} \${_amandauid} created" + fi + if ! grep -q '^[a-z]\+tar:' "\${_amsecurity}"; then + echo "amanda warning: no archivers are enabled in \${_amsecurity}" + fi + rm -f '/usr/bin/amanda-uninstall.sh' +} + +_fn_pre_remove() { + set -u + local _uid + _uid="\$(id -u "\${_amandauser}")" + if [ \$? -eq 0 ]; then + if [ "\${_uid}" -lt 1000 ]; then + userdel "\${_amandauser}" || : + echo "amanda: User \${_amandauser} deleted" + # Mysteriously, userdel also removes the group making groupdel fail + groupdel "\${_amandagroup}" 2>/dev/null || : + echo "amanda: Group \${_amandagroup} deleted" + else + echo "uid of amanda is \${_uid}, >=1000, can't delete" + fi + fi + set +u +} + +_fn_post_remove() { + local _cmd='#!/bin/sh +_true="" +if [ "\${EUID}" -ne 0 ]; then + echo "This must be run as root" + echo "You may want to look through the folders to be deleted for anything valuable" + _true="true" +else + echo "This is likely to destroy backup configurations, encryption keys, and ssh keys." +fi +_delself=1 +' + rm -f '/usr/bin/amanda-uninstall.sh' + # Ask this first since it shows the names of backups + local _file + for _file in${_pacsave}; do + if [ -f "\${_file}" ]; then + echo -n "\${_cmd}" >> '/usr/bin/amanda-uninstall.sh'; _cmd='' + echo "echo rm -f '\${_file}'" >> '/usr/bin/amanda-uninstall.sh' + echo '\${_true} '"rm -i '\${_file}'" >> '/usr/bin/amanda-uninstall.sh' + echo "if [ -f '\${_file}' ]; then" >> '/usr/bin/amanda-uninstall.sh' + echo ' _delself=0' >> '/usr/bin/amanda-uninstall.sh' + echo 'fi' >> '/usr/bin/amanda-uninstall.sh' + fi + done + + local _folder + for _folder in "\${_amhome}" "\${_ametc}" "\${_amdump}" "\${_amlog}"; do + if [ -d "\${_folder}" ]; then + echo -n "\${_cmd}" >> '/usr/bin/amanda-uninstall.sh'; _cmd='' + echo "echo rm -r '\${_folder}'" >> '/usr/bin/amanda-uninstall.sh' + echo '\${_true} '"rm -I -r '\${_folder}'" >> '/usr/bin/amanda-uninstall.sh' + echo "if [ -d '\${_folder}' ]; then" >> '/usr/bin/amanda-uninstall.sh' + echo ' _delself=0' >> '/usr/bin/amanda-uninstall.sh' + echo 'fi' >> '/usr/bin/amanda-uninstall.sh' + fi + done + + if [ -s '/usr/bin/amanda-uninstall.sh' ]; then + chmod 755 '/usr/bin/amanda-uninstall.sh' + echo 'if [ "\${_delself}" -ne 0 ]; then' >> '/usr/bin/amanda-uninstall.sh' + echo ' \${_true} '"echo 'Amanda folders removed'" >> '/usr/bin/amanda-uninstall.sh' + echo ' \${_true} '"echo 'Amanda uninstaller removed'" >> '/usr/bin/amanda-uninstall.sh' + echo ' \${_true} rm -f "\$0"' >> '/usr/bin/amanda-uninstall.sh' + echo 'fi' >> '/usr/bin/amanda-uninstall.sh' + echo "amanda: use '/usr/bin/amanda-uninstall.sh' to remove all Amanda config files and folders" + fi +} + +# Vars from PKGBUILD +# The .install sets a flag to bypass the functions and source the desired variables for upgrades + +if [ ! -z "\${_GetOVars:-}" ]; then + # These variables are from before the upgrade + \${_GetOLocal:=declare} _Oamandauser='${_amandauser}' + \${_GetOLocal} _Oamandagroup='${_amandagroup}' + \${_GetOLocal} _Oamandauid='${_amandauid}' + \${_GetOLocal} _Oamandagid='${_amandagid}' + \${_GetOLocal} _Oamhome='${_amhome}' + \${_GetOLocal} _Oametc='${_ametc}' + \${_GetOLocal} _Oamdump='${_amdump}' + \${_GetOLocal} _Oamsecurity='${_amsecurity}' + \${_GetOLocal} _Oamlog='${_amlog}' +else + # These variables are from after the upgrade + \${_GetOLocal:=declare} _amandauser='${_amandauser}' + \${_GetOLocal} _amandagroup='${_amandagroup}' + \${_GetOLocal} _amandauid='${_amandauid}' + \${_GetOLocal} _amandagid='${_amandagid}' + \${_GetOLocal} _amhome='${_amhome}' + \${_GetOLocal} _ametc='${_ametc}' + \${_GetOLocal} _amdump='${_amdump}' + \${_GetOLocal} _amsecurity='${_amsecurity}' + \${_GetOLocal} _amlog='${_amlog}' + + if [ -z "\${_GetVars:-}" ]; then + if [ "\$#" -eq 0 ]; then + echo 'The package installer runs this, not you!' + echo 'Nothing to see here, Move along!' + exit 0 + fi + + while [ "\$#" -gt 0 ]; do + _fn_\$1 + shift + done + fi +fi +EOF - # Fix permissions - chown -R $_amandauser:$_devgroup "$pkgdir"/etc/$pkgname/ - # Install the licence - install -Dm444 COPYRIGHT "$pkgdir"/usr/share/licences/$pkgname/COPYRIGHT + install -Dpm444 'COPYRIGHT' -t "${pkgdir}/usr/share/licences/${pkgname}/" + set +u } +set +u # vim:set ts=2 sw=2 et: diff --git a/amanda.install b/amanda.install index db0b98d0b164..649bba07e0e1 100644 --- a/amanda.install +++ b/amanda.install @@ -1,29 +1,131 @@ -post_install() { - if [ -z "`getent group amanda`" ]; then - groupadd -g 112 amanda +# Can't customize .install scripts so we use an external script + +# The PKGBUILD will stop if these vars don't match what's in the PKGBUILD + +_amlibexec='/usr/lib' +_amsecurity='/etc/amanda-security.conf' +_amhome='/var/lib/amanda' + +pre_install() { + # During pre_install the settings file amanda-install.sh isn't available yet + # During pre_upgrade the settings file exists with only the old settings. + # During the pre_upgrade from the old package, there are no old settings. + # Here in install we always have the new vars and can guess the old vars. + + # Move file before pacman can remove it + local _amsother='' + case "${_amsecurity}" in + '/etc/amanda-security.conf') _amsother='/etc/amanda/amanda-security.conf';; + '/etc/amanda/amanda-security.conf') _amsother='/etc/amanda-security.conf';; + esac + if [ ! -z "${_amsother}" ] && [ -s "${_amsother}" ] && [ ! -s "${_amsecurity}" ]; then + echo "amanda mv ${_amsother} ${_amsecurity}" + mv "${_amsother}" "${_amsecurity}" fi - if [ -z "`getent passwd amanda`" ]; then - useradd -u 112 -g amanda -G storage,disk -m -d /var/amanda -s /bin/bash -c "Amanda Backup Daemon" amanda + + # Move home folder before pacman can remove it + _amsother='' + case "${_amhome}" in + '/var/lib/amanda') _amsother='/var/amanda';; + '/var/amanda') _amsother='/var/lib/amanda';; + esac + if [ ! -z "${_amsother}" ] && [ -d "${_amsother}" ] && [ ! -d "${_amhome}" ]; then + echo "amanda mv ${_amsother} ${_amhome}" + mv "${_amsother}" "${_amhome}" fi - cat << EOT -amanda: Visit the Amanda wiki to configure your backup sets: -amanda: http://wiki.zmanda.com/index.php/Getting_Started_With_Amanda -amanda: Examples are in /etc/amanda/examples/ +} -amanda: Restart xinetd to start the daemon listening for connections. -EOT +_post_upins() { + _GetOVars= _GetOLocal= bash -e -u "${_amlibexec}/amanda/amanda-install.sh" 'post_upins' 'chown_PKGBUILD' 'chown_makefile' + if [ -s '/etc/xinetd.d/amanda' ]; then + if ! systemctl -q is-enabled 'xinetd.service' || ! systemctl -q is-active 'xinetd.service'; then + echo 'amanda: Service xinetd must be running for bsd support, Try' + if ! systemctl -q is-enabled 'xinetd.service'; then + echo ' sudo systemctl enable xinetd.service' + fi + if ! systemctl -q is-active 'xinetd.service'; then + echo ' sudo systemctl start xinetd.service' + fi + fi + fi } -post_upgrade() { - post_install $1 +post_install() { + _post_upins "$1" + echo 'amanda: Visit the Amanda wiki to configure your backup sets:' + echo 'amanda: http://wiki.zmanda.com/index.php/Getting_Started_With_Amanda' + echo 'amanda: Examples are in /etc/amanda/examples/' + if [ -s '/etc/xinetd.d/amanda' ]; then + echo '' + echo 'amanda: Restart xinetd to start the daemon listening for connections.' + fi + _GetOVars= _GetOLocal= bash -e -u "${_amlibexec}/amanda/amanda-install.sh" 'post_install' +} + +# During an upgrade the new version's pre_upgrade() is run +pre_upgrade() { + pre_install + # Copy the file so we can get to the old vars after the upgrade + if [ -s "${_amlibexec}/amanda/amanda-install.sh" ]; then + (umask 077; cp --remove-destination "${_amlibexec}/amanda/amanda-install.sh" '/tmp/amanda-install.sh') # as close to atomic as I can get. -p not allowed here + fi } pre_remove() { - userdel amanda || true &> /dev/null - groupdel amanda || true &> /dev/null + _GetOVars= _GetOLocal= bash -e -u "${_amlibexec}/amanda/amanda-install.sh" 'pre_remove' + pre_upgrade } -op=$1 -shift +post_upgrade() { + set -u + if [ -s '/tmp/amanda-install.sh' ]; then + local _GetOLocal='local' + local _GetOVars=1 + source '/tmp/amanda-install.sh' + unset _GetOVars + rm '/tmp/amanda-install.sh' + + local _GetVars=1 + source "${_amlibexec}/amanda/amanda-install.sh" + unset _GetVars -$op $* + if [ "${_Oamandauser}" != "${_amandauser}" ]; then + echo 'amanda warning: changing username will likely invalidate all cron jobs and crash running jobs' + fi + # Copy and delete home if not already moved above + if [ "${_Oamhome}" != "${_amhome}" ] && [ -d "${_Oamhome}" ] ; then + if cp --no-target-directory -pr "${_Oamhome}/" "${_amhome}/"; then + rm -rf "${_Oamhome}" + fi + fi + if [ "${_Oamandauser}" != "${_amandauser}" ] || + [ "${_Oamandagroup}" != "${_amandagroup}" ] || + [ "${_Oamandauid}" != "${_amandauid}" ] || + [ "${_Oamandagid}" != "${_amandagid}" ] || + [ "${_Oamhome}" != "${_amhome}" ] || + [ "$(getent passwd "${_amandauser}" | cut -d':' -f6)" != "${_amhome}" ]; then + echo 'amanda: Updating user/group info' + if ! userdel --force "${_Oamandauser}"; then + echo 'amanda: install package again after backup completes to fix' + else + echo "amanda: User ${_Oamandauser} deleted" + fi + groupdel "${_Oamandagroup}" 2>/dev/null || : + echo "amanda: Group ${_Oamandagroup} deleted" + if grep --color=auto -lr "${_Oamhome}" "${_ametc}"; then + echo "amanda warning: Some backups reference the old home dir ${_Oamhome}" + fi + fi + fi + set +u + _post_upins "$1" +} + +post_remove() { + set -u + if [ -s '/tmp/amanda-install.sh' ]; then + _GetOVars= _GetOLocal= bash -e -u '/tmp/amanda-install.sh' 'post_remove' + rm '/tmp/amanda-install.sh' + fi + set +u +} diff --git a/tapetypes.txt b/tapetypes.txt new file mode 100644 index 000000000000..8b3141b158d8 --- /dev/null +++ b/tapetypes.txt @@ -0,0 +1,35 @@ +># Amanda v3.4.5 + +# sudo -u amanda amtapetype -p -f /dev/st0 +#Checking for FSF_AFTER_FILEMARK requirement +>#device-property "FSF_AFTER_FILEMARK" "false" + +# sudo -u amanda amtapetype -p -f /dev/st0 +#Checking for FSF_AFTER_FILEMARK requirement +#device-property "FSF_AFTER_FILEMARK" "false" +# sudo -u amanda amtapetype -f /dev/st0 :( +#Checking for FSF_AFTER_FILEMARK requirement +#Applying heuristic check for compression. +#Wrote random (uncompressible) data at 54993836.0655738 bytes/sec +#Wrote fixed (compressible) data at 95846400 bytes/sec +#Compression: enabled +#Writing one file to fill the volume. +#Wrote 406297739264 bytes at 55860 kb/sec +#Writing smaller files (4062969856 bytes) to determine filemark. +>define tapetype HP-ULTRIUM-920 { +> comment "HP Ultrium 3 920 SAS LTO-3, IBM Tape, compression enabled" +> length 396775136 kbytes +> filemark 682 kbytes +> speed 55860 kps +> blocksize 32 kbytes +>} +># LEOM is not supported for this drive and kernel +> +#sudo -u amanda amtapetype -f /dev/st0 2410.15s user 196.76s system 17% cpu 4:10:07.07 total +# uname -r +#4.9.33-1-lts +# lsscsi | grep Ultrium +#[0:0:4:0] tape HP Ultrium 3-SCSI Q51D /dev/st0 +# lspci | grep Marvell +#04:00.0 RAID bus controller: Marvell Technology Group Ltd. MV64460/64461/64462 System Controller, Revision B (rev 01) + diff --git a/xinetd.amanda b/xinetd.amanda deleted file mode 100644 index 3ee37b5955fd..000000000000 --- a/xinetd.amanda +++ /dev/null @@ -1,13 +0,0 @@ -service amanda -{ - #only_from = amandaserver.example.com amandaclient1.example.com amandaclient2.example.com - socket_type = dgram - protocol = udp - wait = yes - user = amanda - group = storage - groups = yes - server = /usr/libexec/amanda/amandad - server_args = -auth=bsd amdump amindexd amidxtaped - disable = no -} diff --git a/xinetd.amanda.tcp b/xinetd.amanda.tcp new file mode 100644 index 000000000000..7cb7eaeb5dae --- /dev/null +++ b/xinetd.amanda.tcp @@ -0,0 +1,18 @@ +# http://wiki.zmanda.com/index.php/How_To:Configure_bsdtcp_authentication + +# After editing: +# systemctl restart xinetd + +service amanda +{ + #only_from = amandaserver.example.com amandaclient1.example.com amandaclient2.example.com + socket_type = stream + protocol = tcp + wait = no + user = amanda + group = storage + groups = yes + server = /usr/libexec/amanda/amandad + server_args = -auth=bsdtcp amdump amindexd amidxtaped + disable = no +} diff --git a/xinetd.amanda.udp b/xinetd.amanda.udp new file mode 100644 index 000000000000..cf9ffe839cc2 --- /dev/null +++ b/xinetd.amanda.udp @@ -0,0 +1,18 @@ +# https://wiki.zmanda.com/index.php/How_To:Configure_Backward-compatible_Authentication_Methods + +# After editing: +# systemctl restart xinetd + +service amanda +{ + #only_from = amandaserver.example.com amandaclient1.example.com amandaclient2.example.com + socket_type = dgram + protocol = udp + wait = yes + user = amanda + group = storage + groups = yes + server = /usr/libexec/amanda/amandad + server_args = -auth=bsdudp amdump amindexd amidxtaped + disable = no +} |