Skip to content

prettyleaf/ruleset-fetcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ruleset-fetcher

An interactive script that fetches rule-set files for mihomo.

ruleset-fetcher

Quick Start

wget https://raw.githubusercontent.com/prettyleaf/ruleset-fetcher/main/ruleset-fetcher.sh
chmod +x ruleset-fetcher.sh
sudo ./ruleset-fetcher.sh
curl -fsSL https://raw.githubusercontent.com/prettyleaf/ruleset-fetcher/main/ruleset-fetcher.sh -o /tmp/ruleset-fetcher.sh && sudo bash /tmp/ruleset-fetcher.sh

After installation, you can use either command from anywhere:

ruleset-fetcher
rfetcher

Usage

Running without arguments opens the interactive menu:

ruleset-fetcher

Setup Wizard

The setup wizard guides you through:

  1. Download Directory - Where to save rule-set files (default: /opt/ruleset-fetcher)
  2. URLs - Add multiple URLs to download
  3. GitHub Access - Optional token for private repositories and release assets
  4. Review & Download - Confirm URLs and optionally download immediately
  5. Telegram Notifications - Optional alerts for updates
  6. Update Interval - How often to auto-update (via cron)

Private GitHub Releases

For private repositories, save a GitHub token and add the GitHub release asset API URL to urls.txt or through the interactive menu:

sudo rfetcher --set-github-token

Example URL:

https://api.github.com/repos/<OWNER>/<REPO>/releases/assets/<ASSET_ID>

The script automatically sends:

  • Authorization: Bearer <token>
  • Accept: application/octet-stream

You can also override the saved token with one of these environment variables:

  • RULESET_FETCHER_GITHUB_TOKEN
  • RF_GITHUB_TOKEN
  • GITHUB_TOKEN

Commands

Command Description
--setup, -s Run interactive setup wizard
--update, -u Download/update all files now
--status Show current status and configuration
--add-url Add a new URL to download
--remove-url Remove a URL from the list
--set-github-token Save GitHub token for private repositories
--clear-github-token Remove saved GitHub token
--list, -l List all configured URLs
--test-telegram Send a test Telegram notification
--enable-timer Enable auto-update cron job
--disable-timer Disable auto-update cron job
--check-update Check for script updates
--self-update Update script to latest version
--version, -v Show version information
--uninstall Remove all configuration and cron job
--help, -h Show help message

Nginx Configuration

To serve the downloaded files as a GitHub mirror, add this to your Nginx configuration:

server {
    listen 443;
    server_name your-mirror-domain.com;

    location /rule-sets/ {
        alias /opt/ruleset-fetcher/;
        autoindex on;
        
        # CORS headers for mihomo
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Methods 'GET, OPTIONS';
        
        # Cache control
        expires 1h;
        add_header Cache-Control "public, max-age=3600";
    }
}

Files

File Description
/usr/local/bin/ruleset-fetcher Main script
/usr/local/bin/rfetcher Short alias (symlink)
/opt/ruleset-fetcher/config.conf Configuration file
/opt/ruleset-fetcher/urls.txt List of URLs to download
/opt/ruleset-fetcher/ruleset-fetcher.log Log file

Auto-updates are managed via cron job (viewable with crontab -l).

Check Status

# Show full status
sudo ruleset-fetcher --status

# Check cron job
crontab -l | grep ruleset-fetcher

# Watch logs
tail -f /opt/ruleset-fetcher/ruleset-fetcher.log

Reset Configuration

sudo ruleset-fetcher --uninstall
sudo ruleset-fetcher --setup

License

MIT License - see LICENSE for details.

Contributing

PR welcome.

Donations

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors

Languages