Compare commits
2 Commits
7becb2450f
...
v2022.08.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
9ba0925b8d
|
|||
|
34d381e7f1
|
@@ -1 +0,0 @@
|
||||
creator/*
|
||||
27
old/Makefile
27
old/Makefile
@@ -1,27 +0,0 @@
|
||||
default: cloner
|
||||
|
||||
GLOBALVOL ?= cloner-global
|
||||
TAGOWNER = valicek1
|
||||
TAGMAIN = repo-cloner
|
||||
TAGBASE= $(TAGOWNER)/$(TAGMAIN)
|
||||
|
||||
cloner:
|
||||
docker build -t $(TAGBASE) .
|
||||
|
||||
run: cloner
|
||||
docker run -v $(GLOBALVOL):/data -it --rm $(TAGBASE)
|
||||
|
||||
once: cloner
|
||||
docker run -v $(GLOBALVOL):/data -it --rm $(TAGBASE) /usr/local/bin/cron-command
|
||||
|
||||
bash: cloner
|
||||
docker run -v $(GLOBALVOL):/data -it --rm $(TAGBASE) /bin/bash
|
||||
|
||||
# wizzard
|
||||
wizzard: cloner
|
||||
docker run -v $(GLOBALVOL):/data -it --rm $(TAGBASE) /usr/local/bin/wizzard
|
||||
|
||||
singleshot: cloner
|
||||
docker run -v $(GLOBALVOL):/data -e BASE=/data/cloner-t456 --user executor -it --rm $(TAGBASE) run-checker
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
# try to include laminar env
|
||||
if [ -f /etc/profile.d/laminar.sh ]
|
||||
then
|
||||
source /etc/profile.d/laminar.sh
|
||||
fi
|
||||
|
||||
# if started as root
|
||||
if [ $UID -eq 0 ]
|
||||
then
|
||||
find /data \! -user executor -exec chown executor:executor {} \;
|
||||
su executor -c cron-command
|
||||
exit $?
|
||||
fi
|
||||
# check lock
|
||||
lock=/var/run/cloner.pid
|
||||
|
||||
dir_prefix=cloner
|
||||
|
||||
max_jobs=${JOBS:-3}
|
||||
|
||||
function die(){
|
||||
echo $@ 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# first, check process
|
||||
if [ -f $lock ]
|
||||
then
|
||||
pid=$(cat $lock)
|
||||
# if it still runs, die not so quietly
|
||||
[ -n "$pid" ] && [ -d /proc/$pid ] && die "Another process running!"
|
||||
fi
|
||||
# else make some mess and setup trap
|
||||
echo $BASHPID > $lock
|
||||
|
||||
find /data -maxdepth 1 -type d -name "${dir_prefix}-*" | \
|
||||
parallel --lb -j $max_jobs -n 1 run-mirror-update
|
||||
|
||||
echo "Cron Finished"
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
i#!/bin/bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
function log(){
|
||||
local title=${raw:-$name}
|
||||
[ -z "$title" ] || title=" [$title]"
|
||||
echo "[$(date +"%X")]$title $@"
|
||||
}
|
||||
|
||||
function die(){
|
||||
log "$@" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
scratch=$(mktemp -d -t tmp.XXXXXXXXXX)
|
||||
function finish {
|
||||
rm -rf "$scratch"
|
||||
}
|
||||
trap finish EXIT
|
||||
|
||||
|
||||
# necessary checks
|
||||
pathto=${1:-}
|
||||
[ -n "$pathto" ] || die "No project specified"
|
||||
|
||||
raw=$(basename $pathto | sed 's/^cloner-//g')
|
||||
|
||||
# is it enabled?
|
||||
[ -f "$pathto/.enabled" ] || die "$raw not enabled!"
|
||||
|
||||
|
||||
env BASE=$pathto run-checker | while read line; do log "$line"; done
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Clone repository from mirror
|
||||
#
|
||||
# Usage:
|
||||
# cclone <main repo url> [ -p <path> ] [ -c <checkout_ref> ]
|
||||
|
||||
# strict mode
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
# include config
|
||||
source $(dirname $(realpath $0))/config
|
||||
source $(dirname $(realpath $0))/gen-mirror-path
|
||||
|
||||
# parse arguments
|
||||
function usage(){
|
||||
echo "Usage: $0 [-p <path>] [-c <checkout_ref>]" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
repo=$1
|
||||
|
||||
if [[ ! "$repo" =~ ^-.* ]]
|
||||
then
|
||||
# check if repo was mirrored
|
||||
if [ ! -d $(getRepoPath $repo) ]
|
||||
then
|
||||
echo "Specified repo wasn't mirrored yes, please do it so!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
# kick args +1
|
||||
shift
|
||||
else
|
||||
usage
|
||||
fi
|
||||
|
||||
# other opts
|
||||
while getopts "c:p:" o; do
|
||||
case "${o}" in
|
||||
c)
|
||||
param_c=${OPTARG}
|
||||
;;
|
||||
p)
|
||||
param_p=${OPTARG}
|
||||
;;
|
||||
\?)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
# Run clone
|
||||
cloneurl=$(getRepoPath $repo)
|
||||
clonepath=${param_p:-}
|
||||
|
||||
echo "Cloning $repo"
|
||||
git clone file://$cloneurl $clonepath
|
||||
|
||||
checkout=${param_c:-}
|
||||
if [ -n "$checkout" ]
|
||||
then
|
||||
chdir=${param_p:-$(getRepoUniq $repo)}
|
||||
echo "Checking out $checkout"
|
||||
oldpwd=$(pwd)
|
||||
cd $chdir
|
||||
# -b just to make git less verbose
|
||||
git checkout $checkout -b _tmp_$checkout
|
||||
cd $oldpwd
|
||||
fi
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Clone repository from mirror - recursively with submodules
|
||||
#
|
||||
# Usage:
|
||||
# sclone <main repo url> [ -p <path> ] [ -c <checkout_ref>
|
||||
|
||||
# strict mode
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
# Scratch - temp
|
||||
tmpdir=$(mktemp -d -t mirror-recursive-XXXXXXX)
|
||||
function finish {
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
trap finish EXIT
|
||||
|
||||
# include config
|
||||
source $(dirname $(realpath $0))/config
|
||||
source $(dirname $(realpath $0))/gen-mirror-path
|
||||
|
||||
# parse arguments
|
||||
function usage(){
|
||||
echo "Usage: $0 [-p <path>] [-c <checkout_ref>]" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ $# -eq 0 ] && usage
|
||||
|
||||
repo=$1
|
||||
|
||||
|
||||
# clone the repo
|
||||
cclone $@ || true
|
||||
# skip url
|
||||
shift
|
||||
|
||||
# parse opts
|
||||
while getopts "c:p:" o; do
|
||||
case "${o}" in
|
||||
c)
|
||||
param_c=${OPTARG}
|
||||
;;
|
||||
p)
|
||||
param_p=${OPTARG}
|
||||
;;
|
||||
\?)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# change dir and examine the commit + submodules
|
||||
oldpwd=$(pwd)
|
||||
submodules=$tmpdir/submodules
|
||||
cd ${param_p:-$(getRepoUniq $repo)}
|
||||
submodule-describe . > $submodules
|
||||
|
||||
while read -r line || [[ -n "$line" ]]
|
||||
do
|
||||
# read -r retypes \t to ' ' (space)
|
||||
commit=$(echo $line | cut -f1 -d' ')
|
||||
directory=$(echo $line | cut -f2 -d' ')
|
||||
url=$(echo $line | cut -f3 -d' ')
|
||||
# recursion ++
|
||||
sclone $url -p $directory -c $commit
|
||||
done < $submodules
|
||||
|
||||
|
||||
|
||||
cd $oldpwd
|
||||
|
||||
Reference in New Issue
Block a user