Skip to content

Build Hosts File

Build Hosts File #43

Workflow file for this run

name: Build Hosts File
on:
workflow_dispatch:
schedule:
- cron: "0 8 1 * *"
jobs:
build-hosts:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: setup git config
run: |
git config user.name "pantsufan"
git config user.email "joel28@protonmail.com"
- name: Remove old file
run: |
git rm hosts
git commit -m "Removed Host File"
git push origin main
- name: Set up environment
run: |
sudo apt-get update
sudo apt-get install -y php-cli curl
- name: Download converter.php
run: |
curl -o converter.php https://gist.githubusercontent.com/pantsufan/e4b8876154d1436d8b13743bb07f3a8a/raw/converter.php
- name: Run Script
run: |
echo "Project Lite"
php converter.php
sed -i "1,6d" AdguardMobileAds.txt
sed -i "1,6d" OISD.txt
sed -i "1,6d" AdguardMobileSpyware.txt
echo "" >> OISD.txt
cat AdguardMobileSpyware.txt >> OISD.txt
echo "" >> OISD.txt
cat AdguardMobileAds.txt >> OISD.txt
rm AdguardMobileAds.txt
rm AdguardMobileSpyware.txt
mv OISD.txt hosts
awk '!seen[$0]++' hosts > hosts_filter
{
echo "# PROJECT LITE"
echo "# Generated by Kninja"
echo "# Blocked domains: $(cat hosts_filter | wc -l)"
echo "# Date: $(date)"
echo ""
echo "# BEGIN HEADER"
echo "127.0.0.1 localhost"
echo "255.255.255.255 broadcasthost"
echo "::1 localhost"
echo "::1 ip6-localhost ip6-loopback"
echo "fe00::0 ip6-localnet"
echo "ff00::0 ip6-mcastprefix"
echo "ff02::1 ip6-allnodes"
echo "ff02::2 ip6-allrouters"
echo "ff02::3 ip6-allhosts"
echo "# END HEADER"
echo ""
echo "# BEGIN BLOCKLIST"
cat hosts_filter
} > hosts_new
rm hosts
mv hosts_new hosts
rm hosts_filter
echo "Done Building!"
- name: Commit and Push Changes
run: |
git add hosts
git commit -m "Update hosts file"
git push origin main