Pokazywanie postów oznaczonych etykietą skrypt. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą skrypt. Pokaż wszystkie posty

poniedziałek, 21 maja 2012

Mikrotik scripts for keeping configuration synced between two different Mikrotik routers.

Ten post jest dostępny jedynie w języku angielskim.
I've faced problem how to setup backup router that can be easily (but manually) switched to act as main. I have two routers - RB1000 and RB750. They are different platforms and I can't just backup config on RB1000 and restore it on RB750. Additionally RB750 have one more ethernet interface which I use to detect if router acts as main router. If additional interface (configurable in script) is running (cable is connected) router will act in "backup" mode, otherwise it will be in "running" mode. My solution consists of two separate scripts - 1. mikrotik-sync-config.py 2. set-backup-mode Ad.1 This script cares about config on backup router to be the same (as much as possible) as on main router (RB1000). It's configurable - you can setup what from main router config to omit, while importing on backup router. Ad.2 This script runs on scheduler on backup router. It detects cable at specified interface (SI) and setups router in "backup" or "running" mode. In "backup" mode all interfaces except SI and all schedules are disabled. When cable is removed from SI, script switches router into "running" mode what means it's enabling interfaces and schedules You can find scripts here -> https://github.com/codepill/script-utilities/tree/master/mikrotik

poniedziałek, 16 kwietnia 2012

Mikrotik script for monitoring Internet connection and using backup connection when primary is dead

Ten post jest dostępny jedynie w języku angielskim.
Idea is simple. Script (I run it every 2 minutes via scheduler) sends ping to 3 defined locations. When all 3 locations are dead it supposses that connection is broken somewhere outside. In this case script enables firewall mangle rule that marks packets with 'failover' label. In routing table you have to add routing for 'failover' label using your backup interface. You have to add 'failover' routing for all your local interfaces - otherwise you local routing won't work when main connection will be dead.

You have to setup few variables at the beginning of the script and 'backupinterfacename' in the script body.

You can find script here -> https://github.com/codepill/script-utilities/blob/master/mikrotik/connection-watch

środa, 11 kwietnia 2012

Backuping and restoring repositories in GitHub

If you lack of free private repositories in GitHub you have two options - buy higher plan or delete one of existing repositories. Second option isn't bad (you can reimport repostiory in future from local copy) but you will loose all addtional information - wiki, issues etc. Facing this problem I've written scripts for backup and restore almost all informations from GitHub that can be obtained. Theses scripts use GitHub API v 3 and 'git' command. You can find them here:

https://github.com/codepill/script-utilities/tree/master/github-repository-tools

Please read README file before use.
Jeśli brakuje Ci wolnych prywatnych repozytoriów w Githubie masz dwie możliwości - zakupić wyższy plan lub usunąć jedno z istniejących repozytoriów. Opcja druga nie jest zła (możesz potem zaimportować repozytorium z lokalnej kopii) ale stracisz wtedy wszystkie dodatkowe informacje powiązane z repozytorium - wiki, issues itd. Stojąc przed tym problemem napisałem w Pythonie skrypty do backupowania i przywracania większości informacji o repozytorium z Githuba. Skrypty te korzystają z API w wersji 3 oraz z polecenia 'git'. Skrypty możesz znaleźć tutaj:

https://github.com/codepill/script-utilities/tree/master/github-repository-tools

Przed skorzystaniem przeczytaj plik README.