{"id":200328,"date":"2013-11-01T14:01:03","date_gmt":"2013-11-01T10:01:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=200328"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=200328","title":{"rendered":"<span class=\"post_title\">\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0440\u043e\u0443\u0442\u0435\u0440\u0430 CISCO RVS4000<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0422\u0430\u043a \u0443\u0436 \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0434\u043e\u043c\u0430\u0448\u043d\u0438\u0439 \u0440\u043e\u0443\u0442\u0435\u0440 \u043f\u043e\u0441\u043b\u0435 \u0434\u0432\u0443\u0445 \u043b\u0435\u0442 \u0431\u0435\u0437\u0433\u043b\u044e\u0447\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0447\u0430\u043b \u0432\u0440\u0435\u043c\u044f \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e\u0434\u0432\u0438\u0441\u0430\u0442\u044c. \u041f\u0440\u043e\u044f\u0432\u043b\u044f\u043b\u043e\u0441\u044c \u044d\u0442\u043e \u0432 \u043f\u043e\u0434\u0432\u0438\u0441\u0430\u043d\u0438\u0438 WAN \u043f\u043e\u0440\u0442\u0430 \u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0443 \u0432\u0441\u0435\u0439 \u043f\u043e\u0434\u0441\u0435\u0442\u0438, LAN \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435 \u0442\u0430\u043a\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430.<br \/>  <a name=\"habracut\"><\/a><br \/>  <b>\u041f\u0435\u0440\u0435\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u0441\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u0443\u044e \u043a\u043e\u043f\u0438\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0432\u0430\u0448\u0435\u0433\u043e \u0440\u043e\u0443\u0442\u0435\u0440\u0430<\/b><br \/>  \u041f\u043e\u0434\u0431\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043b\u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.<br \/>  \u041f\u0435\u0440\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b\u043b\u043e \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u043e\u0442\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u2014 arduino+ethernet shield\/rapsberry PI + \u0440\u0435\u043b\u0435. \u042d\u0442\u043e \u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0448\u0430\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f. \u041a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u0436\u0434\u0430\u0442\u044c \u043b\u0438\u0431\u043e ethernet shield, \u043b\u0438\u0431\u043e rapsberry PI. \u0410 \u0436\u0434\u0430\u0442\u044c \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c. \u0414\u0430\u043b\u0435\u0435 \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0437 \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e, \u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0440\u043e\u0443\u0442\u0435\u0440 \u043f\u043e\u0434\u0432\u0438\u0441\u0430\u043b \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0432\u043e\u0439\u0442\u0438 \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0443. 5 \u043c\u0438\u043d\u0443\u0442 \u0433\u0443\u0433\u043b\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"bash\">curl -u 'login:password' 'http:\/\/192.168.1.1\/setup.cgi?todo=reboot' <\/code><\/pre>\n<p>  \u0421\u0441\u044b\u043b\u043a\u0430 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u043d\u043e \u0447\u0435\u0440\u0435\u0437 curl \u0440\u0435\u0446\u0435\u043f\u0442 \u0432 \u0443\u043f\u043e\u0440 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u043b.<\/p>\n<pre><code class=\"html\">            &lt;HTML&gt;             &lt;HEAD&gt;&lt;TITLE&gt;401 Unauthorized&lt;\/TITLE&gt;&lt;\/HEAD&gt;             &lt;BODY BGCOLOR=&quot;#cc9999&quot; TEXT=&quot;#000000&quot; LINK=&quot;#2020ff&quot; VLINK=&quot;#4040cc&quot;&gt;             &lt;H4&gt;401 Unauthorized&lt;\/H4&gt; Authorization required.             &lt;HR&gt;             &lt;ADDRESS&gt;&lt;A HREF=&quot;&quot;&gt;&lt;\/A&gt;&lt;\/ADDRESS&gt;             &lt;\/BODY&gt;             &lt;\/HTML&gt; <\/code><\/pre>\n<p>  \u0412\u0430\u0440\u0438\u0430\u0446\u0438\u0438 \u0441 post \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 request \u043d\u0435 \u0434\u0430\u043b\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430, \u043e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432\u0441\u0451 \u0442\u043e\u0442 \u0436\u0435. \u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044f\u0445 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c. \u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0448\u0438\u043d\u0430 + \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 sikuli \u2014 \u0441 \u043f\u0443\u0448\u043a\u0438 \u043f\u043e \u0432\u043e\u0440\u043e\u0431\u044c\u044f\u043c. \u041e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c nodejs+coffeescript+phantomjs. \u0422\u0430\u043a \u0443\u0436 \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438, \u0447\u0442\u043e \u0434\u043e\u043c\u0430\u0448\u043d\u0438\u0439 linux \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432 \u00ab\u0434\u043b\u044f \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u00bb \u0443 \u043c\u0435\u043d\u044f gentoo. \u0414\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0432 gentoo \u0431\u044b\u043b \u0431\u0438\u0442\u044b\u0439 ebuild \u0434\u043b\u044f phantomjs: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0441\u044f, \u0430 \u043f\u043e\u0442\u043e\u043c \u0442\u0430\u043a\u0438 \u0441\u0442\u0430\u043b \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0451-\u0440\u0430\u0432\u043d\u043e \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0441\u044f. \u041e\u0431\u0438\u0434\u043d\u043e, \u043d\u043e \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043d\u0435 \u043f\u044b\u0442\u043a\u0430.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u0435\u043b\u043a\u0438 \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"bash\">mkdir \/opt\/ext\/router_reboot_tool cd \/opt\/ext\/router_reboot_tool npm install -g coffeescript npm install phantomjs phpjs <\/code><\/pre>\n<p>  \u0418 \u0432\u043e\u0442 \u0442\u0443\u0442 \u0432\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0444\u0430\u043a\u0442. \u041f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 phantomjs \u043e\u043d \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a. \u0412\u043e\u0442 \u0447\u0443\u0434\u043e, \u043d\u0435 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043b\u044f\u0441\u0430\u0442\u044c \u0441 \u0431\u0443\u0431\u043d\u043e\u043c. \u0414\u0430\u043b\u044c\u0448\u0435 \u0443\u0436\u0435 \u0434\u0435\u043b\u043e \u0442\u0435\u0445\u043d\u0438\u043a\u0438.<\/p>\n<p>  check.coffee \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u043a\u0430\u043a \u0443\u043c\u0435\u0435\u0442, \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 reboot.sh:<\/p>\n<pre><code class=\"coffeescript\">#!\/usr\/bin\/coffee fs  = require('fs') exec= require('child_process').exec php = require('phpjs')  _old_console_log = console.log console.log = (t)-&gt;     _old_console_log &quot;[#{php.date('d.m.Y H:i:s')}] #{t}&quot; check_internet = (get_result)-&gt;     exec 'ping -c1 8.8.8.8', (_skip,result)-&gt;         get_result \/1 packets transmitted, 1 received\/.test result  if fs.existsSync 'marker'     console.log 'marker detected'     fs.unlinkSync 'marker'     process.exit() fail_count      = 0 max_fail_count  = 10 check_count     = 0 main_loop = setInterval ()-&gt;     check_count++     if check_count &gt; 60*5-10         console.log &quot;wiped (new will started by cron)&quot;         process.exit()     check_internet (r)-&gt;         return if fail_count &gt; max_fail_count # \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430. \u041b\u0435\u043d\u044c \u043f\u043e\u043a\u0430-\u0447\u0442\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u0430         # console.log r         if r             fail_count = 0         else             fail_count++             console.log &quot;fail #{fail_count}&quot;         if fail_count &gt; max_fail_count             console.log &quot;reboot&quot;             clearInterval main_loop # \u043a\u0430\u043a \u043d\u0438 \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u043d\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442             fs.writeFileSync 'marker', ''             exec '.\/reboot.sh', (_skip,result)-&gt;                 console.log result             setTimeout ()-&gt;                 fs.unlinkSync 'phantom_marker'                 process.exit()             , 10000 , 1000 <\/code><\/pre>\n<p>  \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0444\u0430\u0439\u043b\u0430 marker \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043d\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c 2 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u043e\u0434\u0440\u044f\u0434. \u0422\u0430\u043a\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0435\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043f\u0440\u043e\u043f\u0430\u043b \u043a\u0430\u043a \u0440\u0430\u0437 \u043f\u0435\u0440\u0435\u0434 \u043a\u043e\u043d\u0446\u043e\u043c 5-\u043c\u0438\u043d\u0443\u0442\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430. \u0410 \u0442\u0430\u043a \u043c\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0438\u043c\u0435\u0435\u043c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u043a \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c 5 \u043c\u0438\u043d\u0443\u0442 \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u043c\u0438 \u0440\u043e\u0443\u0442\u0435\u0440\u0430.<\/p>\n<p>  <b>\u0421\u044e\u0440\u043f\u0440\u0438\u0437 \u21161<\/b>. clearInterval \u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b \u0443\u0431\u0438\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0438 reboot.sh \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0441\u044f \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u043e 4 \u0440\u0430\u0437\u0430 \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u0443 \u043c\u0435\u043d\u044f \u0441\u043b\u0435\u0442\u0435\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043d\u0430 \u0440\u043e\u0443\u0442\u0435\u0440\u0435. \u0412\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0434\u0432\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b reboot \u043f\u043e\u0434\u0440\u044f\u0434 \u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 hard reset. \u0420\u0435\u0448\u0435\u043d\u0438\u0435-\u043a\u043e\u0441\u0442\u044b\u043b\u044c \u0442\u0430\u043a \u0438 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0432 \u0433\u043e\u0442\u043e\u0432\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438.<\/p>\n<p>  reboot.sh \u0441\u0438\u043b\u044c\u043d\u043e \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0443\u043c\u043e\u043c \u0438 \u0441\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e. \u041f\u0440\u043e\u0441\u0442 \u0438 \u0431\u0430\u043d\u0430\u043b\u0435\u043d. <b>\u041f\u043e\u0442\u043e\u043c \u0435\u0433\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c<\/b>.  <\/p>\n<pre><code class=\"bash\">#!\/bin\/bash coffee -c .\/phantom.coffee .\/node_modules\/phantomjs\/bin\/phantomjs .\/phantom.js <\/code><\/pre>\n<p>  phantom.coffee  <\/p>\n<pre><code class=\"coffeescript\">console.log &quot;start...&quot; # fs = require('fs') # if fs.existsSync 'phantom_marker'     # console.log &quot;phantom_marker&quot;     # phantom.exit() # fs.writeFileSync 'phantom_marker', ''  page = require('webpage').create() page.onConsoleMessage = (msg)-&gt;     console.log msg  url = 'http:\/\/192.168.1.1\/Reboot.htm' page.settings.userName = 'login' page.settings.password = 'password' page.open url, ()-&gt;     page.evaluate ()-&gt;         document.getElementsByName('mtenReboot')[0].click()          console.log 'waiting...'     setTimeout ()-&gt;         console.log 'exit'         # fs.unlinkSync 'phantom_marker'         phantom.exit()     , 10000 <\/code><\/pre>\n<p>  \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0449\u0438\u0442\u0443 \u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 reboot.sh \u0434\u0432\u0430\u0436\u0434\u044b, \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0437\u0430\u043f\u0438\u0441\u044c \u0444\u0430\u0439\u043b\u0430 phantom_marker \u043a\u0430\u043a \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0436\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0438 \u043d\u0435 \u043d\u0430\u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d. \u041d\u043e \u0442\u0443\u0442 \u043c\u0435\u043d\u044f \u0436\u0434\u0430\u043b \u0441\u044e\u0440\u043f\u0440\u0438\u0437 \u21162.<\/p>\n<p>  <b>\u0421\u044e\u0440\u043f\u0440\u0438\u0437 \u21162<\/b>. \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0434\u043b\u044f phantomjs \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u043c\u043e\u0434\u0443\u043b\u0438 \u0434\u043b\u044f nodejs (\u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c fs, \u0438\u043b\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442, \u043d\u043e \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0441\u0442\u0430\u0440\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0438\u043c\u0435\u043b\u043e \u0441\u043c\u044b\u0441\u043b\u0430). \u041e\u0431\u0438\u0434\u043d\u043e, \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c, \u0432\u043d\u043e\u0441\u0438\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0432 reboot.sh, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u0435\u043d\u0435\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u0430, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>  \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 reboot.sh:<\/p>\n<pre><code class=\"bash\">#!\/bin\/bash if [ -a 'phantom_marker' ] then   echo &quot;phantom_marker present&quot;   exit fi touch phantom_marker coffee -c .\/phantom.coffee .\/node_modules\/phantomjs\/bin\/phantomjs .\/phantom.js unlink phantom_marker <\/code><\/pre>\n<p>  \u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0448\u0442\u0440\u0438\u0445\u0438  <\/p>\n<pre><code class=\"bash\">chmod +x check.coffee chmod +x reboot.sh crontab -e *\/5 * * * * cd \/opt\/ext\/router_reboot_tool && .\/check.coffee 2&gt;&1 &gt;&gt; .\/log \/etc\/init.d\/vixie-cron restart <\/code><\/pre>\n<p>  \u0412\u043d\u043e\u0441\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0443\u0436\u0435 \u0440\u0443\u0447\u043a\u0430\u043c\u0438 (\u044f \u0432\u0435\u0440\u044e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u0438, \u043d\u043e \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u0434\u0430\u0447\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u0434\u0435\u043b\u043a\u0438). \u041f\u043e\u0441\u043b\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f crontab \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c cron, \u0438\u043d\u0430\u0447\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<p>  \u041f\u0430\u0440\u0443 \u0442\u0435\u0441\u0442\u043e\u0432 \u0441 \u0440\u0443\u0447\u043d\u044b\u043c \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c WAN \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438, \u0447\u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e. \u0412 \u0441\u0443\u043c\u043c\u0435 \u043d\u0430 \u043f\u043e\u0438\u0441\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u044e\u0440\u043f\u0440\u0438\u0437\u043e\u0432 \u0431\u044b\u043b\u043e \u043f\u043e\u0442\u0440\u0430\u0447\u0435\u043d\u043e 2-4 \u0447\u0430\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443 \u043a\u043e\u0433\u043e-\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0431\u044b\u0442\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0438\u043b \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0431\u0449\u0435\u0435 \u043e\u0431\u043e\u0437\u0440\u0435\u043d\u0438\u0435. \u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u043e\u0443\u0442\u0435\u0440 \u2014 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e, \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 reboot \u0438 \u0441\u0430\u043c\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443.<\/p>\n<p>  \u0427\u0442\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0434\u043e\u0434\u0435\u043b\u0430\u0442\u044c, \u043d\u043e \u043d\u0435 \u0434\u043e\u0448\u043b\u0438 \u0440\u0443\u043a\u0438: \u0443\u0431\u0440\u0430\u0442\u044c \u043a\u043e\u0441\u0442\u044b\u043b\u044c \u0434\u043b\u044f \u043b\u0438\u0448\u043d\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 fail_count. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/200328\/\"> http:\/\/habrahabr.ru\/post\/200328\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0422\u0430\u043a \u0443\u0436 \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0434\u043e\u043c\u0430\u0448\u043d\u0438\u0439 \u0440\u043e\u0443\u0442\u0435\u0440 \u043f\u043e\u0441\u043b\u0435 \u0434\u0432\u0443\u0445 \u043b\u0435\u0442 \u0431\u0435\u0437\u0433\u043b\u044e\u0447\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0447\u0430\u043b \u0432\u0440\u0435\u043c\u044f \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e\u0434\u0432\u0438\u0441\u0430\u0442\u044c. \u041f\u0440\u043e\u044f\u0432\u043b\u044f\u043b\u043e\u0441\u044c \u044d\u0442\u043e \u0432 \u043f\u043e\u0434\u0432\u0438\u0441\u0430\u043d\u0438\u0438 WAN \u043f\u043e\u0440\u0442\u0430 \u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0443 \u0432\u0441\u0435\u0439 \u043f\u043e\u0434\u0441\u0435\u0442\u0438, LAN \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435 \u0442\u0430\u043a\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-200328","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/200328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=200328"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/200328\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=200328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=200328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=200328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}