diff --git a/checker/detector-lib-general b/checker/detector-lib-general index b1762cc..4d05cc6 100644 --- a/checker/detector-lib-general +++ b/checker/detector-lib-general @@ -1,5 +1,18 @@ #!/bin/bash +function detectorTryInit(){ + # repo dir + dir=$1 + history=$DET_DIR/detectorExecuted + + if ! [ -f $history ] + then + echo "Initializing detector cache" + # initialize seed + git --git-dir $dir log --all --format="%H" > $history + fi +} + function detectorCheckCommit(){ sha=$1 history=$DET_DIR/detectorExecuted diff --git a/checker/run-checker b/checker/run-checker index 8d1721f..bf4cc2b 100755 --- a/checker/run-checker +++ b/checker/run-checker @@ -68,6 +68,9 @@ then exit 0 fi +# try to init cache +detectorTryInit $repodir + # first, solve commits # branches that were deleted or merged find $DET_BRANCHES -type f | sort | while read branchpath @@ -158,5 +161,5 @@ do done # save hash to keep things clear -#detectorSumPersist $repodir +detectorSumPersist $repodir diff --git a/dockerbin/wizzard b/dockerbin/wizzard index 9f3469e..b2e8087 100755 --- a/dockerbin/wizzard +++ b/dockerbin/wizzard @@ -71,6 +71,21 @@ function createConfigFile(){ EOF } +function createDetectorConfig(){ + # $1 - file + local cfgFile=$1 + + mkdir -p $(dirname $cfgFile) + + if [ $read_detector -eq 1 ] + then + cat > $cfgFile <<-EOF + # this file is config for detector + # now, it is empty - to disable detector, just delete it! + EOF + fi +} + function generateSSHKey(){ # generates ssh key with $1 path and $2 description local keyfile=$1/id_rsa @@ -137,6 +152,19 @@ else read_submodule_limit=N fi + +# determine CI? +echo -n "Do you want to enable CI support? (detector) [Y/n]" +read read_detector +[ -n "$read_detector" ] || read_detector=Y +if ! [[ "$read_detector" =~ ^[Yy]$ ]] +then + read_detector=0 +else + read_detector=1 +fi + + root=/data/$dir_prefix-$read_project_name # start generating config mkdir -p $root/config @@ -166,6 +194,7 @@ then reuseSSHKey $root/config/auth/ssh/id_rsa fi + echo "First run - initialization of repos..." if ! env BASE=$root run-checker then @@ -177,6 +206,7 @@ then rm -Rf $root fi else + createDetectorConfig $root/config/detector.cfg echo "Setup has finished!" touch $root/.enabled fi