All pastes #904144 Raw Edit

Unnamed

public shellscript v1 · immutable
·published 2008-02-14 19:17 UTC
rendered paste body
syncrepo: line 321: unexpected EOF while looking for matching `"'syncrepo: line 332: syntax error: unexpected end of file#!/bin/bash## Syncrepo## Written by: "Andreas Pedersen"## Copyright (C) 2008 by Andreas Pedersen <alofflambas gmail com>.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2, or (at your option)# any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software Foundation,# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## TODO# - Add arguments to this this script# - Add arguments to repo functions to manage version and repository type##set -nSYNCDIR=$(pwd) # or some other data dir.# Warning, do not add --delete!RSYNC="echo rsync -rltuz --delay-updates" # --deleteBASENAME=$(basename $0)VERSION="0.1"# Recomended: ppc ppc64 PS3IGNORE_ARCH="ppc ppc64 PS3" # x86_64 SRPMS i686 i586# i386 fedora and packman only# PS3 SUSE SEPCSUSE_VERSION="10.3"SUSE_REPO="oss non-oss"# debug src-oss src-non-oss"SPLIT=falseDEBUG=falseUPDATE=falseFEDORA_VERSION="7 8"CENTOS_VERSION="5 5.1"function checkArch {   for ARCH in $IGNORE_ARCH    do      if [ "$ARCH" == "$1" ]       then         echo -n "--exclude $2"      fi   done}function createDir {   if $(test -d $1 || mkdir -p $1 2> /dev/null) ; [ "$?" != "0" ]    then      echo "ERROR: Can't create directory. $1" 1>&2      break   fi   if $(test -w $1) ; [ "$?" != "0" ]    then      echo "ERROR: You don't have write permission! $1" 1>&2      break   fi}function print_help {   cat <<EOLUsage: $BASENAME [options]SyncrepoBORING TEXT DESCOptions:  -h, --help          print this help message      --version       print program version  -d, --dist          select dist  -r, --repo          choose repositories  -s, --split         SUSE specific split repo to oss,                       non-oss and etc...  -i, --ignore        ignore arch: x86_64, ppc                       ppc64, SRPM  -d, --debug         debug program  -q, --quiet         quiet output  -v, --verbose       verbose outputExamples:The most common use is to run it like this.  $ $BASENAMEBut sometimes like this.  $ $BASENAME --dist suse --repo ossEOL}function print_version {   echo -e "$BASENAME version $VERSION\nWritten by Andreas Pedersen"}# REPO #######################################################################function suse_repo {   for VER in $SUSE_VERSION    do      DIR="$SYNCDIR/opensuse/$VER/repo"      if [ $SLPIT ]       then         for REPO in $SUSE_REPO          do            createDir $DIR/$REPO         done      else         createDir $DIR         if [[ "$RSYNC" =~ "--delete"  ]]          then            echo -e "ERROR: You need to run with --split argument or remove delete option from rsync" 1>&2            break         fi      fi      for REPO in $SUSE_REPO       do         $RSYNC \         $(checkArch PS3 PS3/) \         $(checkArch ppc boot/ppc/) \         $(checkArch x86_64 boot/x86_64/) \         $(checkArch i586 suse/i586/) \         $(checkArch i686 suse/i686/) \         $(checkArch x86_64 suse/x86_64/) \         $(checkArch ppc suse/ppc/) \         $(checkArch ppc64 suse/ppc64) \         $(checkArch SRPMS suse/src/) \         rsync://ftp5.gwdg.de/pub/opensuse/distribution/$VER/repo/$REPO/ $DIR      done   done}function suse_update {   for VER in $SUSE_VERSION    do      DIR=$SYNCDIR/opensuse/$VER/update      createDir $DIR      $RSYNC \      $(checkArch ppc rpm/ppc/) \      $(checkArch ppc64 rpm/ppc64/) \      $(checkArch SRPMS rpm/src/) \      $(checkArch i586 rpm/i586/) \      $(checkArch i686 rpm/i686) \      $(checkArch x86_64 rpm/x86_64/) \      rsync://ftp5.gwdg.de/pub/opensuse/update/$VER/ $DIR   done}function suse_packman {   for VER in $SUSE_VERSION    do      DIR=$SYNCDIR/opensuse/$VER/packman      createDir $DIR      $RSYNC \      $(checkArch SRPMS SRPMS/) \      $(checkArch ppc ppc/) \      $(checkArch i386 i386/) \      $(checkArch i486 i486/) \      $(checkArch i586 i586/) \      $(checkArch i686 i686/) \      $(checkArch x86_64 x86_64/) \      rsync://ftp.skynet.be/packman/suse/$VER/ $DIR   done}# TODO: Check if its correct #################################################function fedora_repo {   for VER in $FEDORA_VERSION    do      DIR=$SYNCDIR/fedora/$VER/repo      createDir $DIR      $RSYNC \      $(checkArch ppc64 ppc64/) \      $(checkArch x86_64 x86_64/) \      $(checkArch ppc ppc/) \      $(checkArch ppc64 ppc64/) \      $(checkArch i386 i386/) \      $(checkArch SRPMS source/) \      rsync://ftp.crc.dk/Fedora/linux/releases/$VER/Everything/ $DIR   done}# TODO: Check if its correct #################################################function fedora_update {   for VER in $FEDORA_VERSION    do      DIR=$SYNCDIR/fedora/$VER/update      createDir $DIR      $RSYNC \      $(checkArch ppc64 ppc64/) \      $(checkArch x86_64 x86_64/) \      $(checkArch ppc ppc/) \      $(checkArch i386 i386/) \      $(checkArch SRPMS SRPMS/) \      rsync://ftp.crc.dk/Fedora/linux/updates/$VER/ $DIR    done}# TODO: Check if its correct #################################################function centos_repo {   for VER in $CENTOS_VERSION    do      DIR=$SYNCDIR/centos/$VER/os      createDir $DIR      $RSYNC \      $(checkArch x86_64 x86_64/) \      $(checkArch i386 i386/) \      $(checkArch SRPMS SRPMS/) \      rsync://mirror.nsc.liu.se/CentOS/$VER/os/ $DIR#      rsync://eu-msync.centos.org/CentOS/$VER/updates/ $DIR    done}# TODO: Check if its correct #################################################function centos_update {   for VER in $CENTOS_VERSION    do      DIR=$SYNCDIR/centos/$VER/updates      createDir $DIR      $RSYNC \      $(checkArch x86_64 x86_64/) \      $(checkArch i386 i386/) \      $(checkArch SRPMS SRPMS/) \      rsync://mirror.nsc.liu.se/CentOS/$VER/updates/ $DIR#      rsync://eu-msync.centos.org/CentOS/$VER/updates/ $DIR    done}function checkopts {   SHORTOPTS="hr:d:i:s:vq"   LONGOPTS="help,version,repo:,dist:,split:,ignore:,debug,verbose,quiet"   if $(getopt -T >/dev/null 2>&1) ; [ $? = 4 ]    then # New longopts getopt.      OPTS=$(getopt -o $SHORTOPTS --long $LONGOPTS -n "$BASENAME" -- "$@" 2>/dev/null)   else # Old classic getopt.      # Special handling for --help and --version on old getopt.      case $1 in --help) print_help ; exit 0 ;; esac      case $1 in --version) print_version ; exit 0 ;; esac      OPTS=$(getopt $SHORTOPTS "$@")   fi   eval set -- "$OPTS"   DEBUG=false   while [ $# -gt 0 ]    do#      : debug: $1      case $1 in         -h|--help)            print_help            exit 0            ;;         --version)            print_version            exit 0            ;;         -d|--dist)            DIST=$2            shift 2 #NOTE            ;;         -u|--update)            UPDATE=true            shift            ;;         -r|--repo) #TODO Hack this?            REPO=$2            shift 2            ;;         -d|--debug)            DEBUG=true            shift            ;;         -i|--ignore) #TODO Hack this?            IGNORE=$2            shift 2            ;;         -s|--split)            SPLIT=true;            shift            ;;         -v|--verbose)            RSYNC="$RSYNC -v" # -P            shift            ;;         -q|--quiet)            RSYNC="$RSYNC -q"            shift            ;;         --)            shift            break            ;;         *)            echo "Internal Error: option processing error: $1" 1>&2            exit 1            ;;      esac   doneARGV=$@}if [ $# -gt 0 ] then   echo -e "\033[31mWARNING: Development mode\033[39m"   checkopts $@echo "$ARGV"#echo done;exitfisuse_repo#suse_update#suse_packman#fedora_repo#fedora_update#centos_update#centos_repo