Files
sysconfig/seafile-ignore-find2merge.sh
2026-04-27 20:16:56 +08:00

81 lines
2.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
echo ""
echo "Search in [ROOTPATH], Merge [GLOBALPATH/seafile-ignore.global.txt] and [ROOTPATH/*/seafile-ignore.local.txt] files to [seafile-ignore.txt]"
echo ""
if [ -d "$1" ]
then
ROOTPATH=$1
else
echo "::*** Enter [root path] or [leave blank] for default [[`pwd`]] to start tree search for seafile-ignore.txt files"
read -p "***:: " ROOTPATH
if [ "$ROOTPATH" ]
then
ROOTPATH=$(realpath "${ROOTPATH/#\~/$HOME}")
else
ROOTPATH=`pwd`
fi
fi
if [ ! -d "$ROOTPATH" ]
then
echo "××× [[$ROOTPATH]] not exist! Exit now. ***"
exit
else
echo "√√√ ROOTPATH = [[$ROOTPATH]]"
fi
echo ""
echo "::*** Enter [path to seafile-ignore.global.txt] or [leave blank] for default [[https://git.tic.cc/opx/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt]]"
read -p "***:: " GLOBALPATH
if [ "$GLOBALPATH" ]
then
GLOBALPATH=$(realpath "${GLOBALPATH/#\~/$HOME}")
echo $GLOBALPATH
if [ -d "$GLOBALPATH" ]
then
GLOBALPATH="$GLOBALPATH/seafile-ignore.global.txt"
fi
if [ -f "$GLOBALPATH" ]
then
echo "√√√ GLOBALPATH = [[$GLOBALPATH]]"
else
echo "××× Not found [[$GLOBALPATH]]. Exit now..."
exit
fi
else
GLOBALPATH=https://git.tic.cc/opx/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt
fi
echo ""
echo "::*** Enter [y] to start updating, or [anything else] for dry-run"
read -p "***:: " YESNO
cd $ROOTPATH
echo "*** Starting from [[`pwd`]] ***"
echo ""
find . -mindepth 0 -maxdepth 3 -type d -name '[^.]*' | grep -E -v 'node_modules|uni_modules|\.deploy_git|\.git|.svn|\.vscode|\.wrangler|unpackage|_webroot|_logstore|_datasotre|_archive|_filestore|_ssl' | while read repo
do
if [ -f "$repo/seafile-ignore.txt" ] || [ -d "$repo/.git" ]
then
echo "---- updating [[$repo/seafile-ignore.txt]] ----"
if [ "$YESNO" = 'y' ]
then
if [ -f "$GLOBALPATH" ]
then
cat $GLOBALPATH > $repo/seafile-ignore.txt
else
curl -sSL $GLOBALPATH | cat > $repo/seafile-ignore.txt
fi
if [ -f "$repo/seafile-ignore.local.txt" ]
then
cat $repo/seafile-ignore.local.txt 2>/dev/null >> $repo/seafile-ignore.txt
fi
fi
echo ""
fi
done
cd -