An interactive script that fetches rule-set files for mihomo.
wget https://raw.githubusercontent.com/prettyleaf/ruleset-fetcher/main/ruleset-fetcher.sh
chmod +x ruleset-fetcher.sh
sudo ./ruleset-fetcher.shcurl -fsSL https://raw.githubusercontent.com/prettyleaf/ruleset-fetcher/main/ruleset-fetcher.sh -o /tmp/ruleset-fetcher.sh && sudo bash /tmp/ruleset-fetcher.shAfter installation, you can use either command from anywhere:
ruleset-fetcher
rfetcherRunning without arguments opens the interactive menu:
ruleset-fetcherThe setup wizard guides you through:
- Download Directory - Where to save rule-set files (default:
/opt/ruleset-fetcher) - URLs - Add multiple URLs to download
- Review & Download - Confirm URLs and optionally download immediately
- Telegram Notifications - Optional alerts for updates
- Update Interval - How often to auto-update (via cron)
| 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 |
--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 |
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";
}
}| 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).
# Show full status
sudo ruleset-fetcher --status
# Check cron job
crontab -l | grep ruleset-fetcher
# Watch logs
tail -f /opt/ruleset-fetcher/ruleset-fetcher.logsudo ruleset-fetcher --uninstall
sudo ruleset-fetcher --setupMIT License - see LICENSE for details.
PR welcome.
