DEVELOPMENT ENVIRONMENT

~liljamo/robots.txt

ref: 6a060977b27b20fd69912b6a11132b831712016c robots.txt/generate.sh -rwxr-xr-x 610 bytes
6a060977Jonni Liljamo feat: robots.txt generation 27 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash

[ -z "$1" ] && echo "no out file supplied" && exit 1
out="$1"

base="$2"

# check if base was given
if [ ! -z $base ]; then
    # check if base exists
    [ ! -e $base ] && echo "invalid base" && exit 1
    # copy base to out
    cp $base $out
fi

# loop lists
for filename in ./lists/*.txt; do
    # line by line
    while read -r line; do
        # ignore empty
        [ -z "$line" ] && continue
        # ignore comments
        [[ $line =~ ^#.* ]] && continue

        # add to out
        echo "User-agent: $line" >> $out
        echo "Disallow: /" >> $out
    done < $filename
done