mirror of
https://github.com/KaringX/karing-ruleset.git
synced 2025-06-13 07:54:14 +08:00
use merge geo script
This commit is contained in:
parent
797af96c15
commit
528dca222d
10
.github/workflows/run.yml
vendored
10
.github/workflows/run.yml
vendored
@ -34,6 +34,7 @@ jobs:
|
|||||||
cp ./workflow/resouces/convert_* ./sing-rule/ACL4SSR/
|
cp ./workflow/resouces/convert_* ./sing-rule/ACL4SSR/
|
||||||
cd sing-rule/ACL4SSR/ || exit 1
|
cd sing-rule/ACL4SSR/ || exit 1
|
||||||
python convert_json.py ../../ACL4SSR/Clash ./
|
python convert_json.py ../../ACL4SSR/Clash ./
|
||||||
|
cp Ruleset/*.srs ./
|
||||||
|
|
||||||
- name: Convert json to srs
|
- name: Convert json to srs
|
||||||
env:
|
env:
|
||||||
@ -64,19 +65,12 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd sing-rule || exit 1
|
cd sing-rule || exit 1
|
||||||
cp -r ../meta-rules-dat/geo ./
|
cp -r ../meta-rules-dat/geo ./
|
||||||
cp -r ../Iran-sing-box-rules/geoip-ir.srs ./geo/geoip/ir.srs
|
bash ../workflow/resouces/merge_geo_ir.sh ./geo ../Iran-sing-box-rules/
|
||||||
cp -r ../Iran-sing-box-rules/geoip-malware.srs ./geo/geoip/malware.srs
|
|
||||||
cp -r ../Iran-sing-box-rules/geoip-phishing.srs ./geo/geoip/phishing.srs
|
|
||||||
cp -r ../Iran-sing-box-rules/geosite*ir.srs ./geo/geosite/
|
|
||||||
cp -r ../Iran-sing-box-rules/geosite-geolocation*.srs ./geo/geosite/
|
|
||||||
cp -r ../Iran-sing-box-rules/geosite-cryptominers.srs ./geo/geosite/
|
|
||||||
cd ./geo/geosite/ && find ./ -type f -name "geosite-*ir.srs" -exec bash -c 'mv "$1" "${1/geosite-/}"' _ {} \;
|
|
||||||
|
|
||||||
- name: Git push assets to "sing-rule" branch
|
- name: Git push assets to "sing-rule" branch
|
||||||
run: |
|
run: |
|
||||||
cd sing-rule || exit 1
|
cd sing-rule || exit 1
|
||||||
cp ../workflow/README.md . && cp -r ../workflow/.github .
|
cp ../workflow/README.md . && cp -r ../workflow/.github .
|
||||||
cp ACL4SSR/Ruleset/*.srs ./ACL4SSR/
|
|
||||||
git init
|
git init
|
||||||
git config --local user.name "github-actions[bot]"
|
git config --local user.name "github-actions[bot]"
|
||||||
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
*.log
|
||||||
|
*.srs
|
||||||
|
*.json
|
||||||
|
tmp/
|
65
resouces/merge_geo_ir.sh
Executable file
65
resouces/merge_geo_ir.sh
Executable file
@ -0,0 +1,65 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
CURRENT_DIR=$(cd $(dirname $0); pwd)
|
||||||
|
SPECIAL_CODES=(ir)
|
||||||
|
LOG_FILE="merge.log"
|
||||||
|
|
||||||
|
target_dir=$1
|
||||||
|
if [ -z "$target_dir" ]; then
|
||||||
|
target_dir=$CURRENT_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
target_dir=$(readlink -f $target_dir)
|
||||||
|
if [ ! -d "$target_dir" ]; then
|
||||||
|
echo "${target_dir} unkown directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
merge_src_dir=$2
|
||||||
|
if [ -z "$merge_src_dir" ]; then
|
||||||
|
echo "ERR: empty merge source!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
merge_src_dir=$(readlink -f $merge_src_dir)
|
||||||
|
|
||||||
|
|
||||||
|
## Begin
|
||||||
|
|
||||||
|
LOG_FILE="${target_dir}/${LOG_FILE}"
|
||||||
|
cat /dev/null > $LOG_FILE
|
||||||
|
|
||||||
|
cd $merge_src_dir
|
||||||
|
echo -e "\n\ttarget>> ${target_dir}\n\tmerging<= ${merge_src_dir}\n\n"
|
||||||
|
|
||||||
|
# Loop through files in folder a
|
||||||
|
for file1 in $(ls *.srs); do
|
||||||
|
# Get the filename without path
|
||||||
|
filename1=${file1##*/}
|
||||||
|
|
||||||
|
fsub=${filename1%%-*}
|
||||||
|
filename2=${filename1#*-}
|
||||||
|
|
||||||
|
# Country code
|
||||||
|
ccode=$(echo "$filename1" |rev | awk -F'[-|.|!]' '{print $2}' | rev | awk -F'@' '{print $1}' )
|
||||||
|
|
||||||
|
# Check if file exists in folder b with the same name
|
||||||
|
file2="$target_dir/$fsub/$filename2"
|
||||||
|
|
||||||
|
# If file not found, print filename
|
||||||
|
if [ ! -f $file2 ]; then
|
||||||
|
cp $file1 $file2
|
||||||
|
echo "${fsub}/${filename2}" >> $LOG_FILE
|
||||||
|
fi
|
||||||
|
if [[ " ${SPECIAL_CODES[@]} " =~ " $ccode " ]]; then
|
||||||
|
cp $file1 $file2
|
||||||
|
echo "${fsub}/${filename2}" >> $LOG_FILE
|
||||||
|
# echo $ccode
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
cat $LOG_FILE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#END FILE
|
Loading…
x
Reference in New Issue
Block a user