git倉庫遠端資料同步,整合禪道指令碼
阿新 • • 發佈:2019-01-07
git倉庫在根目錄,addfile也在根目錄,config.php也在根目錄,cc.txt也在根目錄。
#!/bin/sh
cd /x
nownu=`ls |wc -l`
echo "當下git倉庫專案共有:"$nownu"個"
cd /
oldnu=` cat cc.txt |awk '{print $0}' `
echo "5分鐘之前git倉庫專案共有:"$oldnu"個"
if [ "$nownu" = "$oldnu" ];then
echo "無任何專案增加,it's fine ~~~"
exit 0
fi
if [ "$nownu" > "$oldnu" ];then
cha=$((nownu -oldnu))
echo "5分鐘內有新git專案增加,共"$cha"個"
cd /x
addfile=`ls -t |head -$cha`
echo $addfile > /addfile.txt
cd /
newgit= ;
for add in $addfile
do
# echo "新增git專案為:"$add
newgit+="$add ";
echo -e '$i ++;' >> config.php
echo -e "\$config->git->repos[$i ]['path'] = '/opt/"$add"';" >> config.php
echo -e "\$config->git->repos[$i]['encoding'] = 'utf-8';" >> config.php
echo -e "\n" >> config.php
done
echo "新增git專案為:"$newgit
echo $nownu > /cc.txt
# for i in $(cat)
fi