{"id":23,"date":"2008-05-26T22:45:47","date_gmt":"2008-05-26T20:45:47","guid":{"rendered":"http:\/\/www.daniel-ritter.de\/blog\/?p=23"},"modified":"2024-05-13T01:15:46","modified_gmt":"2024-05-12T23:15:46","slug":"making-your-server-box-talk-like-in-those-old-movies","status":"publish","type":"post","link":"https:\/\/www.daniel-ritter.de\/blog\/making-your-server-box-talk-like-in-those-old-movies\/","title":{"rendered":"Making your server box talk like in those old movies"},"content":{"rendered":"<p><a href=\"https:\/\/www.daniel-ritter.de\/blog\/wp-content\/uploads\/2008\/05\/image14.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-24\" title=\"Good Old Times\" src=\"https:\/\/www.daniel-ritter.de\/blog\/wp-content\/uploads\/2008\/05\/image14.jpg\" alt=\"\" width=\"500\" height=\"375\" srcset=\"https:\/\/www.daniel-ritter.de\/blog\/wp-content\/uploads\/2008\/05\/image14.jpg 640w, https:\/\/www.daniel-ritter.de\/blog\/wp-content\/uploads\/2008\/05\/image14-300x225.jpg 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p><span style=\"font-family: arial,helvetica;\"><span class=\"edgeatext\">This is a silly geek thing but you might like it. Why not let your penguin-server talk to you when it needs updates or other interesting things happen?<\/span><\/span><\/p>\n<p>Code and config in these examples are tested on a debian box.<\/p>\n<p>\u00a0What we need:<br \/>\n-A software for speech synthesis<br \/>\nespeak is good for this purpose. quiet configurable and the voice quality is OK.<\/p>\n<p><code><span style=\"color: #000000;\"><strong><span style=\"color: #000000;\">apt<\/span><span style=\"color: #000000;\">-<\/span><span style=\"color: #0000bb;\"><span style=\"color: #000000;\">get install espeak<\/span> <\/span><\/strong><\/span><\/code><\/p>\n<p>-A software that can trigger events, when certain log entries appear<br \/>\nswatch is our friend here. it reads logs in realtime and triggers a command if a specific pattern is found.<br \/>\nIn our case it will just trigger espeak to say something.<\/p>\n<p><code><span style=\"color: #000000;\"><strong><span style=\"color: #000000;\">apt<\/span><span style=\"color: #000000;\">-<\/span><\/strong><span style=\"color: #0000bb;\"><span style=\"color: #000000;\"><strong>get install swatch<\/strong><\/span> <\/span><\/span><\/code><\/p>\n<p>Now that we have our tools lets make a sample talker&#8230;<br \/>\nWe want our box to report, if new (no-spam) mail arrived.<\/p>\n<p>I&#8217;m using spamassassin to filter my mail.<br \/>\nI get a line similar to<\/p>\n<p><code><span style=\"color: #000000;\"><strong><em><span style=\"color: #0000bb;\"><span style=\"color: #000000;\">Jul 26 16<\/span><\/span><span style=\"color: #000000;\">:<\/span><span style=\"color: #000000;\">34<\/span><span style=\"color: #000000;\">:<\/span><span style=\"color: #000000;\">04 star spamd<\/span><span style=\"color: #000000;\">[<\/span><span style=\"color: #000000;\">13365<\/span><span style=\"color: #000000;\">]: <\/span><span style=\"color: #000000;\">spamd<\/span><span style=\"color: #000000;\">: <\/span><span style=\"color: #000000;\">clean message <\/span><span style=\"color: #000000;\">(-<\/span><span style=\"color: #000000;\">2.4<\/span><span style=\"color: #000000;\">\/<\/span><span style=\"color: #000000;\">0.5<\/span><span style=\"color: #000000;\">) for <\/span><span style=\"color: #000000;\">mailbox<\/span><span style=\"color: #000000;\">:<\/span><span style=\"color: #000000;\">1001 in 1.9 seconds<\/span><span style=\"color: #000000;\">, <\/span><span style=\"color: #000000;\">7128 bytes<\/span><\/em><span style=\"color: #000000;\"><em>.<\/em><\/span><\/strong><\/span><\/code><\/p>\n<p><code><span style=\"color: #000000;\"><strong><span style=\"color: #000000;\"><em><\/em><br \/>\n<\/span><span style=\"color: #000000;\">in <\/span><span style=\"color: #000000;\">\/var\/<\/span><span style=\"color: #000000;\">log<\/span><span style=\"color: #000000;\">\/<\/span><span style=\"color: #000000;\">mail<\/span><span style=\"color: #000000;\">.<\/span><\/strong><span style=\"color: #0000bb;\"><span style=\"color: #000000;\"><strong>log <\/strong><\/span><\/span><\/span><\/code>everytime a good messages reaches my inbox.<\/p>\n<p>So create a config file for swatch to look out for lines like that<\/p>\n<p>File: \/etc\/swatch\/ham<br \/>\n<code><span style=\"color: #000000;\"><strong><span style=\"color: #0000bb;\"><br \/>\n<span style=\"color: #000000;\">watchfor <\/span><\/span><span style=\"color: #000000;\">\/<\/span><span style=\"color: #000000;\">clean message<\/span><span style=\"color: #000000;\">\/<br \/>\n<\/span><span style=\"color: #000000;\">exec <\/span><\/strong><span style=\"color: #dd0000;\"><span style=\"color: #000000;\"><strong>\"espeak new_mail &amp;\"<\/strong><\/span><br \/>\n<\/span><\/span><\/code><br \/>\nThe only thing left to do now is to start the swatch daemon<\/p>\n<p><code><span style=\"color: #000000;\"><strong><span style=\"color: #000000;\">\/<\/span><span style=\"color: #000000;\">usr<\/span><span style=\"color: #000000;\">\/<\/span><span style=\"color: #000000;\">bin<\/span><span style=\"color: #000000;\">\/<\/span><span style=\"color: #000000;\">swatch <\/span><span style=\"color: #000000;\">--<\/span><span style=\"color: #0000bb;\"><span style=\"color: #000000;\">daemon <\/span><\/span><span style=\"color: #000000;\">--<\/span><span style=\"color: #000000;\">config<\/span><span style=\"color: #000000;\">-<\/span><span style=\"color: #000000;\">file<\/span><span style=\"color: #000000;\">=\/<\/span><span style=\"color: #000000;\">etc<\/span><span style=\"color: #000000;\">\/<\/span><span style=\"color: #000000;\">swatch<\/span><span style=\"color: #000000;\">\/<\/span><span style=\"color: #000000;\">ham <\/span><span style=\"color: #000000;\">--<\/span><span style=\"color: #000000;\">tail<\/span><span style=\"color: #000000;\">-<\/span><span style=\"color: #000000;\">file<\/span><span style=\"color: #000000;\">=\/var\/<\/span><span style=\"color: #000000;\">log<\/span><span style=\"color: #000000;\">\/<\/span><span style=\"color: #000000;\">mail<\/span><span style=\"color: #000000;\">.<\/span><\/strong><span style=\"color: #0000bb;\"><span style=\"color: #000000;\"><strong>log<\/strong><\/span><br \/>\n<\/span><\/span><\/code>I think you got the point. The possibilities are endless. Everything that is logged can be spoken.<\/p>\n<p>But there are other interesting possibilities. Lets say you want your box to report new available updates to you.<br \/>\nThis little script can do it when run from a repeating cron-job:<\/p>\n<p><code><span style=\"color: #000000;\"><span style=\"color: #000000;\"><br \/>\n<\/span><strong><span style=\"color: #ff8000;\"><span style=\"color: #000000;\">#!\/bin\/bash<\/span><br \/>\n<\/span><span style=\"color: #000000;\">apt<\/span><span style=\"color: #000000;\">-<\/span><span style=\"color: #000000;\">get update<br \/>\nUPDATELINE<\/span><span style=\"color: #000000;\">=`<\/span><span style=\"color: #000000;\">apt-get --simulate upgrade | grep remove<\/span><span style=\"color: #000000;\">`<br \/>\n<\/span><span style=\"color: #000000;\">EINS<\/span><span style=\"color: #000000;\">=`<\/span><span style=\"color: #000000;\">echo $UPDATELINE | cut -d \" \" -f 1<\/span><span style=\"color: #000000;\">`<br \/>\n<\/span><span style=\"color: #000000;\">ZWEI<\/span><span style=\"color: #000000;\">=`<\/span><span style=\"color: #000000;\">echo $UPDATELINE | cut -d \" \" -f 3<\/span><span style=\"color: #000000;\">`<br \/>\n<\/span><span style=\"color: #000000;\">DREI<\/span><span style=\"color: #000000;\">=`<\/span><span style=\"color: #000000;\">echo $UPDATELINE | cut -d \" \" -f 6<\/span><span style=\"color: #000000;\">`<br \/>\n<\/span><span style=\"color: #000000;\">VIER<\/span><span style=\"color: #000000;\">=`<\/span><span style=\"color: #000000;\">echo $UPDATELINE | cut -d \" \" -f 10<\/span><span style=\"color: #007700;\"><span style=\"color: #000000;\">`<\/span><br \/>\n<span style=\"color: #000000;\">((<\/span><\/span><span style=\"color: #000000;\">UPDATES<\/span><span style=\"color: #000000;\">=<\/span><span style=\"color: #000000;\">EINS<\/span><span style=\"color: #000000;\">+<\/span><span style=\"color: #000000;\">ZWEI<\/span><span style=\"color: #000000;\">+<\/span><span style=\"color: #000000;\">DREI<\/span><span style=\"color: #000000;\">+<\/span><span style=\"color: #000000;\">VIER<\/span><span style=\"color: #000000;\">))<br \/>\nif [ <\/span><span style=\"color: #000000;\">$UPDATES <\/span><span style=\"color: #000000;\">-<\/span><span style=\"color: #000000;\">gt 0 <\/span><span style=\"color: #000000;\">]; <\/span><span style=\"color: #000000;\">then<br \/>\nespeak <\/span><span style=\"color: #000000;\">\"REPORT: i need $UPDATES updates! please install as soon as possible\"<br \/>\n<\/span><\/strong><span style=\"color: #0000bb;\"><span style=\"color: #000000;\"><strong>fi<\/strong><\/span><br \/>\n<\/span><\/span><\/code><\/p>\n<p>Now you have got all the tools to make your server an absolutely anoying brabbling box.<br \/>\nEnjoy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to make a linux server talk<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[227],"tags":[9],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-linux","tag-sprachausgabe"],"_links":{"self":[{"href":"https:\/\/www.daniel-ritter.de\/blog\/wp-json\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.daniel-ritter.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.daniel-ritter.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.daniel-ritter.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.daniel-ritter.de\/blog\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":1,"href":"https:\/\/www.daniel-ritter.de\/blog\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":1926,"href":"https:\/\/www.daniel-ritter.de\/blog\/wp-json\/wp\/v2\/posts\/23\/revisions\/1926"}],"wp:attachment":[{"href":"https:\/\/www.daniel-ritter.de\/blog\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.daniel-ritter.de\/blog\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.daniel-ritter.de\/blog\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}