#!/bin/true # REMOTE SCRIPT (can not interact with user) # {{VAR_NAME}} - template variables CLIENT="{{CLIENT}}" LOCK_FILE="{{LOCK_FILE}}" SVN_BIND_PORT="{{SVN_BIND_PORT}}" REMOTE_HOST="{{REMOTE_HOST}}" REMOTE_WWW_DIR="{{REMOTE_WWW_DIR}}" if [ -f $LOCK_FILE ] ; then echo "> ERROR: Remote Update is locked ($LOCK_FILE)" 1>&2 if [ $(stat -c %s $LOCK_FILE) -le 500 ] ; then echo "> ----------------------------------------" 1>&2 cat $LOCK_FILE >&2 echo "> ----------------------------------------" 1>&2 fi exit 1 fi # port is used # data=$(lsof -i :$SVN_BIND_PORT); code=$? data=$(netstat -tuln | grep -Fq ":$SVN_BIND_PORT"); code=$? if [ $code -eq 0 ] ; then echo "> ERROR: Port ${SVN_BIND_PORT} is used" 1>&2 echo "> ----------------------------------------" 1>&2 echo $data 1>&2 echo "> ----------------------------------------" 1>&2 exit 1 fi # create lock truncate -s 0 $LOCK_FILE echo "Date: $(date +'%Y-%m-%d %H:%M:%S')" >> $LOCK_FILE echo "HOST: $REMOTE_HOST" >> $LOCK_FILE echo "PATH: $REMOTE_WWW_DIR" >> $LOCK_FILE echo "CLIENT: $CLIENT" >> $LOCK_FILE exit 0