removed obsolete script
Warning, cannot access the index:
_darcs/index: opening of '_darcs/index' failed: permission denied (Permission denied)
diff -rN -u old-bii_scripts/bin/rsync-deploy new-bii_scripts/bin/rsync-deploy
--- old-bii_scripts/bin/rsync-deploy 2022-12-09 20:33:25.878097704 +0100
+++ new-bii_scripts/bin/rsync-deploy 1970-01-01 01:00:00.000000000 +0100
@@ -1,355 +0,0 @@
-#!/usr/bin/zsh -f
-
-# Copyright 2015 Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
-# <https://www.helmholtz-berlin.de>
-#
-# Author: Thomas Birke <Thomas.Birke@helmholtz-berlin.de>
-#
-# 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
-
-
-help () {
- cat << EOF
-
-${B}rsync-deploy:${b} deploy, tag or untag a set of files/directories in a top-directory
- to one or more target-locations.
-
-
-${B}VARIABLES:${b} the following variables can be set by environment-variables or
- anywhere on the command-line (var=value)
-
- ${B}RSYNC_TOP_NAME${b} - name of "top-directory"
- e.g. BII-Controls
- ${B}RSYNC_TARGETS${b} - target-location for deployment
- [user@]hostname:directory
- e.g. iocadm@opic1c.ctl.bessy.de:/opt/IOC
- hostname and directory are mandatory!
- ${B}RSYNC_FILES${b} -
- ${B}RSYNC_HEAD${b} - name of default-tag to use (default: HEAD)
- ${B}RSYNC_DATETIME${b} - name of version-tag to use (default: YYYYmmdd-HHMMSS)
- better not set it, except to a string with same pattern
-
- ${B}RSYNC_RSH${b} - see "man rsync" (default: ssh)
-
-
-${B}DEPLOYMENT:${b}
-
- ${B}rsync-deploy [deploy] [-v] [-c] dirs [var=value ...]${b}
-
- 1. DEST=\$RSYNC_TARGETS/\$RSYNC_TOP_NAME
- 2. unless -c : copy* version \$DEST/\$RSYNC_HEAD to \$DEST/$RSYNC_DATETIME
- 3. rsync --link-dest=\$DEST/\$RSYNC_HEAD "dirs" \$DEST/$RSYNC_DATETIME
- 4. create a tag \$RSYNC_HEAD to point to \$DEST/$RSYNC_DATETIME
-
- the optional "-v" is passed to the cp and rsync commands
- *) copy in step 2. means: "cp -al" - hard-link files instead of copying
-
-${B}TAGS:${b}
-
- ${B}rsync-deploy tag tagname [version] [var=value ...]${b}
-
- version is optional and may be a specific verion YYYYmmdd-HHMMSS
- or an existing tag. Defaults to HEAD if HEAD exists or the latest
- available version otherwise
-
- create a tag \$RSYNC_HEAD to point to
- \$RSYNC_TARGETS/\$RSYNC_TOP_NAME/version
-
- ${B}rsync-deploy untag tagname [tagname ...] [var=value ...]${b}
-
- remove all tags "tagname" from \$RSYNC_TARGETS/\$RSYNC_TOP_NAME
-
- ${B}rsync-deploy listtags [var=value ...]${b}
-
- lists all available tags (sym-links) in the target-location
-
- ${B}rsync-deploy listversions [var=value ...]${b}
-
- lists all available versions (directories) in the target-location
-
-${B}SEE ALSO:${b}
- man rsync - for -rclptDHIR --link-dest=... options
- man cp - for -l option
-
-EOF
- exit 0
-}
-
-# bold and normal for xterm/vt100
-B=""
-b=""
-if [[ $TERM == "xterm" ]]; then
- B=""
- b=""
-fi
-
-if [[ $# = 0 ]] ; then
- help
-fi
-
-cmd=deploy
-if [[ $1 = "tag" ]]; then
- # tag-command - create a tag
- # usage:
- # rsync-deploy -tag tagname [version]
- cmd=movetag
- shift
-
-elif [[ $1 = "untag" ]]; then
- # untag-command - remove some tags
- # usage:
- # rsync-deploy -untag tagname [tagname ...]
- cmd=untag
- shift
-
-elif [[ $1 = "deploy" ]]; then
- # deploy-command - rdist files/directories to target-locations
- # usage:
- # rsync-deploy [-v] [-tag version_to_update] dir [dir ...]
- cmd=deploy
- shift
-
-elif [[ $1 = "listtags" ]]; then
- # list available tags (sym-links) at target-location
- # usage:
- # rsync-deploy -listtags
- cmd=listtags
- shift
-
-elif [[ $1 = "listversions" ]]; then
- # list available versions (directories) at target-location
- # usage:
- # rsync-deploy -listversions
- cmd=listversions
- shift
-
-fi
-
-verbose=false
-copy=true
-args=()
-for arg in "$@"
-do
- if [[ $arg = "RSYNC_"*"="* ]]; then
- v=(${(s:=:)arg})
- eval $v[1]=\($v[2]\)
- elif [[ $arg = "-help" || $arg = "--help" || $arg = "-h" || $arg = "-?" ]]; then
- help
- elif [[ $arg = "-v" ]]; then
- verbose=true
- elif [[ $arg = "-c" ]]; then
- copy=false
- else
- args=($args $arg)
- fi
-done
-#set $args
-
-# RSYNC_TOP_NAME is the name of the TOP-Directory, defaults to the name of the current-directory
-RSYNC_TOP_NAME=${RSYNC_TOP_NAME:-$PWD:t}
-# where to deploy files/directories to
-#DEFAULT_TARGETS=(aragon:/projects/ctl/birke/target-area snow:rsynctest/target)
-RSYNC_TARGETS=(${RSYNC_TARGETS:-$DEFAULT_TARGETS})
-RSYNC_FILES=(${RSYNC_FILES:-})
-RSYNC_HEAD=(${RSYNC_HEAD:-HEAD})
-
-export RSYNC_RSH=${RSYNC_SSH:-ssh}
-RSYNC_ARGS=(-rclptDHIR)
-
-if $verbose; then
- RSYNC_ARGS=($RSYNC_ARGS -v)
- shift
-fi
-
-# version-name of target-location
-RSYNC_DATETIME=${RSYNC_DATETIME:-`date '+%Y%m%d-%H%M%S'`}
-# unique date-string for log-files
-VDATE=`date '+%Y-%m-%d %H:%M:%S:'`
-
-# apply a tag (create a symlink) in the specified target-directory
-# usage:
-# movetag remote-host remote-dir tagname [version]
-# args:
-# remote-host hostname or username@hostname
-# remote-dir path of top-directory on remote-machine
-# tagname any name used as a tagname - does not necessarily have to exist
-# version optional, existing version or tag to let the new tag point to
-# defaults to HEAD or the latest existing version
-movetag () {
- RHOST=$1; shift
- TOP=$1; shift
- TAGNAME=$1; shift
- echo -n "moving tag $TAGNAME on $RHOST:$TOP "
- if [[ $# > 0 ]]; then
- VERSION=$1; shift
- echo "to specified version $1"
- # version provided - set tag to point to specified version
- ssh $RHOST "cd $TOP;
- if [ -L $VERSION ]; then
- rm -f $TAGNAME
- ln -s \`readlink $VERSION\` $TAGNAME
- echo $VDATE $USER@$HOST:$PWD movetag $TAGNAME $VERSION \(\`readlink $VERSION\`\) >>.deploy-history
- elif [ -d $VERSION ]; then
- rm -f $TAGNAME
- ln -s $VERSION $TAGNAME
- echo $VDATE $USER@$HOST:$PWD movetag $TAGNAME $VERSION >>.deploy-history
- else
- echo ERROR: not existing version $VERSION, cannot move tag
- exit 10
- fi"
- : $[ rc += $? ]
- else
- echo "to HEAD-version"
- # no version provided - set tag to same version as HEAD-tag or latest if non-existing
- ssh $RHOST "cd $TOP
- version=\`readlink HEAD || ls -d 20??????-??????|tail -1\`
- rm -f $TAGNAME
- ln -s \$version $TAGNAME
- echo $VDATE $USER@$HOST:$PWD movetag $TAGNAME \$version >>.deploy-history"
- : $[ rc += $r? ]
- fi
-}
-
-# remove the given tags (symlinks) from the specified target-directory
-# usage:
-# untag remote-host remote-dir {tagnames}
-# args:
-# remote-host hostname or username@hostname
-# remote-dir path of top-directory on remote-machine
-# tagnames any number of existing tags
-untag () {
- RHOST=$1; shift
- TOP=$1; shift
- foreach TAGNAME ($*)
- echo "removing tag $TAGNAME from $RHOST:$TOP"
- ssh $RHOST "cd $TOP;
- if [ -L $TAGNAME ]; then
- rm -f $TAGNAME
- else
- echo ERROR: not existing tag $TAGNAME, cannot remove
- exit 11
- fi"
- : $[ rc += $? ]
- end
-}
-
-# deploy a set of files/directories to a target-location
-# usage:
-# deploy remote-host remote-dir {dirs}
-# args:
-# remote-host hostname or username@hostname
-# remote-dir path of top-directory on remote-machine
-# dirs any number of existing directories
-deploy () {
- RHOST=$1; shift
- TOP=$1; shift
-
- RSYNC_DIRS=("$@")
-
- ssh $RHOST "test -d $RTOP || (echo creating $RHOST:$RTOP; mkdir $RTOP)"
-
- echo "rsync'ing files/directories {$RSYNC_DIRS} to $RHOST:$RTOP/$RSYNC_DATETIME"
- if $verbose; then cparg=-alv; else cparg=-al; fi
- if $copy; then ssh $RHOST "cd $RTOP; cp $cparg $RSYNC_HEAD/ $RSYNC_DATETIME"; : $[ rc += $? ]; fi
- rsync $RSYNC_ARGS --link-dest=$RTOP/$RSYNC_HEAD $RSYNC_DIRS $RHOST:$RTOP/$RSYNC_DATETIME/; : $[ rc += $? ]
- ssh $RHOST "cd $RTOP;
- echo $VDATE $USER@$HOST:$PWD $cmd $@ >>.deploy-history;
- cd $RSYNC_DATETIME;
- find . -links 1 >/tmp/$$.txt && mv /tmp/$$.txt updated-files.txt;
- rm -f .prev;
- ln -s ../\`readlink ../$RSYNC_HEAD\` .prev"; : $[ rc += $? ]
- movetag $RHOST $RTOP $RSYNC_HEAD $RSYNC_DATETIME
-}
-
-# list available tags (sym-links) in target-location
-# usage:
-# listtags remote-host remote-dir
-# args:
-# remote-host hostname or username@hostname
-# remote-dir path of top-directory on remote-machine
-listtags () {
- RHOST=$1; shift
- TOP=$1; shift
- ssh $RHOST "cd $TOP; ls -l *(@)"
-}
-
-# list available versions (directories) in target-location
-# usage:
-# listversions remote-host remote-dir
-# args:
-# remote-host hostname or username@hostname
-# remote-dir path of top-directory on remote-machine
-listversions () {
- RHOST=$1; shift
- TOP=$1; shift
- ssh $RHOST "cd $TOP; ls -ld *(/)"
-}
-
-# lock the target-directory on a remote-host
-# usage:
-# lock remote-host remote-dir
-# args:
-# remote-host hostname or username@hostname
-# remote-dir path of top-directory on remote-machine
-# ret-value:
-# if numeric, the return-value is the lock-id of the successfully created lock
-# else (contains @), the description of the already existing lock (reason of failure)
-#
-lock () {
- LHOST=$1
- LTOP=$2
- ssh $LHOST "cd $LTOP; ln -s $USER@$HOST:$PWD{$$} .rsync-lock 2>/dev/null && echo $$ || readlink .rsync-lock" | read id
- echo $id
-}
-
-# unlock the specified target-directory on a remote-host
-# usage:
-# lock remote-host remote-dir tag-id
-# args:
-# remote-host hostname or username@hostname
-# remote-dir path of top-directory on remote-machine
-# lock-id lock-id of the lock to remove (return-value of lock-command) {NOT YET CHECKED!}
-unlock () {
- LHOST=$1
- LTOP=$2
- ID=$3
-
- ssh $LHOST "cd $LTOP; rm .rsync-lock"
-}
-
-# finally get into action
-# sequentially process targets and perform the required actions
-rc=0
-
-foreach target ($RSYNC_TARGETS)
- echo TARGET=$target
- t=(${(s;:;)target})
- RHOST=$t[1]
- RTOP=$t[2]/$RSYNC_TOP_NAME
-
- lock_id=$(lock $RHOST $RTOP)
- if [[ $lock_id = *"@"* ]]; then
- echo Failed to lock $RHOST:$RTOP!
- echo Directory is currently locked by $lock_id
- echo Please remove lock manually or try again later.
- : $[ rc += 1 ]
- continue
- fi
-
- $cmd $RHOST $RTOP $args
-
- unlock $RHOST $RTOP $lock_id
-end
-
-exit $rc
patch 6fe34503194838b270dd127a9feffe8e24e53488
Author: Thomas Birke <thomas.birke@helmholtz-berlin.de>
Date: Tue Feb 16 08:30:02 CET 2021
* removed obsolete scrip