<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title><![CDATA[Ashus.ashus.net - Bash scripts]]></title>
		<link>https://ashus.ashus.net/</link>
		<description><![CDATA[Ashus.ashus.net - https://ashus.ashus.net]]></description>
		<pubDate>Wed, 29 Apr 2026 14:29:13 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[OpenWRT static IPv6 DUID auto-assign script]]></title>
			<link>https://ashus.ashus.net/thread-175.html</link>
			<pubDate>Sun, 13 Dec 2015 22:05:08 +0100</pubDate>
			<dc:creator><![CDATA[<a href="https://ashus.ashus.net/member.php?action=profile&uid=2">Ashus</a>]]></dc:creator>
			<guid isPermaLink="false">https://ashus.ashus.net/thread-175.html</guid>
			<description><![CDATA[The script and idea was based on <span style="font-weight: bold;" class="mycode_b">jhnphm</span>'s post <a href="https://forum.openwrt.org/viewtopic.php?pid=236287#p236287" target="_blank" rel="noopener" class="mycode_url">here</a>.<br />
The idea is to assign client's DUID addresses (IPv6) just like MAC addresses for IPv4 to the config file. The prerequisite is to have odhcpd configured and IPv6 prefixes filled for DHCP clients via LuCI. Since the DUID is required for static IPv6 to work and there are no fields in LuCI, you can use the script after the client is seen for the first time (probably configured dynamically).<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#!/bin/sh<br />
<br />
for I in &#36;(uci show dhcp|awk -F '(&#92;&#92;[|&#92;&#92;]|&#92;&#92;.|=)' '{if (&#36;2=="@host" &amp;&amp; &#36;5=="name") print &#36;6}'); do # find existing static host entries and find hostnames<br />
    NAME=&#36;(echo -ne &#36;I | sed -r "s/'//g")<br />
    DUID=&#36;(cat /var/hosts/odhcpd |awk -F ' '  "{if (&#92;&#36;1 == &#92;"#&#92;" &amp;&amp; &#92;&#36;5 == &#92;"&#36;NAME&#92;") print &#92;&#36;3 }"|head -n 1)  # find duid for existing hostname in leases<br />
    ID=&#36;(uci show dhcp|awk -F '(&#92;&#92;[|&#92;&#92;]|&#92;&#92;.|=)' "{if (&#92;&#36;2==&#92;"@host&#92;" &amp;&amp; &#92;&#36;6==&#92;"&#36;I&#92;") print &#92;&#36;3}") # Find placement of host entry<br />
        if [ "&#36;DUID" != "0000000000000000000000000000" ]; then<br />
                echo Found: &#36;NAME = &#36;DUID<br />
                uci set dhcp.@host[&#36;ID].duid=&#36;DUID # Set DUID<br />
        fi<br />
done<br />
echo Commiting changes.<br />
uci commit<br />
killall -HUP odhcpd</code></div></div>]]></description>
			<content:encoded><![CDATA[The script and idea was based on <span style="font-weight: bold;" class="mycode_b">jhnphm</span>'s post <a href="https://forum.openwrt.org/viewtopic.php?pid=236287#p236287" target="_blank" rel="noopener" class="mycode_url">here</a>.<br />
The idea is to assign client's DUID addresses (IPv6) just like MAC addresses for IPv4 to the config file. The prerequisite is to have odhcpd configured and IPv6 prefixes filled for DHCP clients via LuCI. Since the DUID is required for static IPv6 to work and there are no fields in LuCI, you can use the script after the client is seen for the first time (probably configured dynamically).<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#!/bin/sh<br />
<br />
for I in &#36;(uci show dhcp|awk -F '(&#92;&#92;[|&#92;&#92;]|&#92;&#92;.|=)' '{if (&#36;2=="@host" &amp;&amp; &#36;5=="name") print &#36;6}'); do # find existing static host entries and find hostnames<br />
    NAME=&#36;(echo -ne &#36;I | sed -r "s/'//g")<br />
    DUID=&#36;(cat /var/hosts/odhcpd |awk -F ' '  "{if (&#92;&#36;1 == &#92;"#&#92;" &amp;&amp; &#92;&#36;5 == &#92;"&#36;NAME&#92;") print &#92;&#36;3 }"|head -n 1)  # find duid for existing hostname in leases<br />
    ID=&#36;(uci show dhcp|awk -F '(&#92;&#92;[|&#92;&#92;]|&#92;&#92;.|=)' "{if (&#92;&#36;2==&#92;"@host&#92;" &amp;&amp; &#92;&#36;6==&#92;"&#36;I&#92;") print &#92;&#36;3}") # Find placement of host entry<br />
        if [ "&#36;DUID" != "0000000000000000000000000000" ]; then<br />
                echo Found: &#36;NAME = &#36;DUID<br />
                uci set dhcp.@host[&#36;ID].duid=&#36;DUID # Set DUID<br />
        fi<br />
done<br />
echo Commiting changes.<br />
uci commit<br />
killall -HUP odhcpd</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Nastavení minimálních oprávnění v podsložkách]]></title>
			<link>https://ashus.ashus.net/thread-157.html</link>
			<pubDate>Mon, 21 Apr 2014 14:52:41 +0200</pubDate>
			<dc:creator><![CDATA[<a href="https://ashus.ashus.net/member.php?action=profile&uid=2">Ashus</a>]]></dc:creator>
			<guid isPermaLink="false">https://ashus.ashus.net/thread-157.html</guid>
			<description><![CDATA[Rekurzivní nastavení oprávnění souborů na 664 a složek do 10. úrovně na 775 se provádí tímto:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>chown -R www-data:www-data *<br />
chmod -R 640 *<br />
find . -maxdepth 10 -type d -exec chmod 750 {} &#92;;</code></div></div>]]></description>
			<content:encoded><![CDATA[Rekurzivní nastavení oprávnění souborů na 664 a složek do 10. úrovně na 775 se provádí tímto:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>chown -R www-data:www-data *<br />
chmod -R 640 *<br />
find . -maxdepth 10 -type d -exec chmod 750 {} &#92;;</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Nahrazení obsahu souborů pomocí 'sed']]></title>
			<link>https://ashus.ashus.net/thread-140.html</link>
			<pubDate>Mon, 03 Jun 2013 16:25:48 +0200</pubDate>
			<dc:creator><![CDATA[<a href="https://ashus.ashus.net/member.php?action=profile&uid=2">Ashus</a>]]></dc:creator>
			<guid isPermaLink="false">https://ashus.ashus.net/thread-140.html</guid>
			<description><![CDATA[Pro hromadné nahrazení deprecated funkcí použijte toto:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>find . -name "*.php" -exec sed -i "s/mysql_escape_string/mysql_real_escape_string/g" '{}' &#92;;</code></div></div><br />
Tím nahradíme ve všech souborech s příponou php <span style="font-weight: bold;" class="mycode_b">mysql_escape_string</span> za <span style="font-weight: bold;" class="mycode_b">mysql_real_escape_string</span>.]]></description>
			<content:encoded><![CDATA[Pro hromadné nahrazení deprecated funkcí použijte toto:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>find . -name "*.php" -exec sed -i "s/mysql_escape_string/mysql_real_escape_string/g" '{}' &#92;;</code></div></div><br />
Tím nahradíme ve všech souborech s příponou php <span style="font-weight: bold;" class="mycode_b">mysql_escape_string</span> za <span style="font-weight: bold;" class="mycode_b">mysql_real_escape_string</span>.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Delete old uploads]]></title>
			<link>https://ashus.ashus.net/thread-136.html</link>
			<pubDate>Fri, 08 Feb 2013 20:15:05 +0100</pubDate>
			<dc:creator><![CDATA[<a href="https://ashus.ashus.net/member.php?action=profile&uid=2">Ashus</a>]]></dc:creator>
			<guid isPermaLink="false">https://ashus.ashus.net/thread-136.html</guid>
			<description><![CDATA[To automatically delete older uploads, use this and add the script to your cron. +7 means files need to be older than 7 days, files beginning with a dot and a folder "up" is ignored.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#!/bin/sh<br />
<br />
IFS=&#36;'&#92;n'<br />
for s in &#36;(find /var/www/files/upload/ -type f -mtime +7 -exec echo {} &#92;; | egrep -v "/var/www/files/upload/(&#92;.|up/)")<br />
&nbsp;&nbsp;&nbsp;&nbsp;do<br />
&nbsp;&nbsp;&nbsp;&nbsp;rm "&#36;s"<br />
&nbsp;&nbsp;&nbsp;&nbsp;done</code></div></div>]]></description>
			<content:encoded><![CDATA[To automatically delete older uploads, use this and add the script to your cron. +7 means files need to be older than 7 days, files beginning with a dot and a folder "up" is ignored.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#!/bin/sh<br />
<br />
IFS=&#36;'&#92;n'<br />
for s in &#36;(find /var/www/files/upload/ -type f -mtime +7 -exec echo {} &#92;; | egrep -v "/var/www/files/upload/(&#92;.|up/)")<br />
&nbsp;&nbsp;&nbsp;&nbsp;do<br />
&nbsp;&nbsp;&nbsp;&nbsp;rm "&#36;s"<br />
&nbsp;&nbsp;&nbsp;&nbsp;done</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[COD Hammering Protective shaper]]></title>
			<link>https://ashus.ashus.net/thread-87.html</link>
			<pubDate>Thu, 30 Oct 2008 22:37:51 +0100</pubDate>
			<dc:creator><![CDATA[<a href="https://ashus.ashus.net/member.php?action=profile&uid=2">Ashus</a>]]></dc:creator>
			<guid isPermaLink="false">https://ashus.ashus.net/thread-87.html</guid>
			<description><![CDATA[A tool I needed to stop hammering our COD2 gameserver with StatusResponse UDP packets.<br />
The gameserver gets hammered constantly by hundreds of players each second, because they use so-called 'game managers' like HLSW or All Seeing Eye. Programs like this often send hundreds of UDP requests to get the server status - map, gametype and playerlist. That alone would be OK, but they keep refreshing the lists like every 10 seconds! Imagine a thousand of users choosing where to connect. Or even worse, those who left the tool open and leave the computer physically.<br />
<br />
Naturally, our slow network line or weak CPU didn't manage to work it out without problems. The game lagged.<br />
So my aim was to differentiate between gameplay packets and those of HLSW-like tools. It wasn't easy, because the game uses the same UDP port for all communication. I needed to examine the content of packets somehow and filter out the bad guys.<br />
<br />
For this to work, you need a linux kernel with IMQ and U32 support and appropriately patched IPtables.<br />
<br />
<!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=99" target="_blank">hammering-protect.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">741 bytes</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">1025</span></span>
</div>
<!-- end: postbit_attachments_attachment --><br />
<br />
The script I wrote sends all INPUT and OUTPUT game packets [UDP, 28960] to IMQ virtual device. Then TC's plugin U32 scans their content to match specific content. Actually the bad packets contain the words <span style="font-weight: bold;" class="mycode_b">getstatus</span> and <span style="font-weight: bold;" class="mycode_b">statusResponse</span> inside, so finding this was quite easy; maintaining the syntax U32 wanted to hear was a little tricky. Matched packets are redirected to a class, that we designated as shaped. All other packets must come through instantly to keep ping low and minimize lagging.<br />
<br />
So now we have set up a shaper, that shapes packets from HLSW-like tools. And unforutnately also game's own <span style="font-style: italic;" class="mycode_i">serverstatus</span> packets. We wanted to keep <span style="font-style: italic;" class="mycode_i">some</span> data flowing, so users would see the server as <span style="font-weight: bold;" class="mycode_b">online</span> in the game menu. So we need to balance it.<br />
<br />
My first try was to shape it 3/3 kbit/s [down/up]. It seemed successful, becaused the game lagged no more. Another day no players came. I began to think people actually are dependant on those tools, as I saw them thinking the server was offline or that they were banned. They had no idea how to connect to the game, except using HLSW-like tools. Some I've told "use the game menu --&gt; favorites", but the server was more empty each day.<br />
So I raised the limits to 20/20. There still are some lags, but it sure is more playable than without it.<br />
<br />
Now that I think of it, the Upload should be large and we should only limit Download a lot because of UDP <span style="font-style: italic;" class="mycode_i">'deliver now or never'</span> behaviour.<br />
At the time of writing this, I'm testing 10/50 on <a href="https://www.kafemlynek.cz/" target="_blank" rel="noopener" class="mycode_url">Kafemlynek</a>.]]></description>
			<content:encoded><![CDATA[A tool I needed to stop hammering our COD2 gameserver with StatusResponse UDP packets.<br />
The gameserver gets hammered constantly by hundreds of players each second, because they use so-called 'game managers' like HLSW or All Seeing Eye. Programs like this often send hundreds of UDP requests to get the server status - map, gametype and playerlist. That alone would be OK, but they keep refreshing the lists like every 10 seconds! Imagine a thousand of users choosing where to connect. Or even worse, those who left the tool open and leave the computer physically.<br />
<br />
Naturally, our slow network line or weak CPU didn't manage to work it out without problems. The game lagged.<br />
So my aim was to differentiate between gameplay packets and those of HLSW-like tools. It wasn't easy, because the game uses the same UDP port for all communication. I needed to examine the content of packets somehow and filter out the bad guys.<br />
<br />
For this to work, you need a linux kernel with IMQ and U32 support and appropriately patched IPtables.<br />
<br />
<!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=99" target="_blank">hammering-protect.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">741 bytes</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">1025</span></span>
</div>
<!-- end: postbit_attachments_attachment --><br />
<br />
The script I wrote sends all INPUT and OUTPUT game packets [UDP, 28960] to IMQ virtual device. Then TC's plugin U32 scans their content to match specific content. Actually the bad packets contain the words <span style="font-weight: bold;" class="mycode_b">getstatus</span> and <span style="font-weight: bold;" class="mycode_b">statusResponse</span> inside, so finding this was quite easy; maintaining the syntax U32 wanted to hear was a little tricky. Matched packets are redirected to a class, that we designated as shaped. All other packets must come through instantly to keep ping low and minimize lagging.<br />
<br />
So now we have set up a shaper, that shapes packets from HLSW-like tools. And unforutnately also game's own <span style="font-style: italic;" class="mycode_i">serverstatus</span> packets. We wanted to keep <span style="font-style: italic;" class="mycode_i">some</span> data flowing, so users would see the server as <span style="font-weight: bold;" class="mycode_b">online</span> in the game menu. So we need to balance it.<br />
<br />
My first try was to shape it 3/3 kbit/s [down/up]. It seemed successful, becaused the game lagged no more. Another day no players came. I began to think people actually are dependant on those tools, as I saw them thinking the server was offline or that they were banned. They had no idea how to connect to the game, except using HLSW-like tools. Some I've told "use the game menu --&gt; favorites", but the server was more empty each day.<br />
So I raised the limits to 20/20. There still are some lags, but it sure is more playable than without it.<br />
<br />
Now that I think of it, the Upload should be large and we should only limit Download a lot because of UDP <span style="font-style: italic;" class="mycode_i">'deliver now or never'</span> behaviour.<br />
At the time of writing this, I'm testing 10/50 on <a href="https://www.kafemlynek.cz/" target="_blank" rel="noopener" class="mycode_url">Kafemlynek</a>.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[GeoIP updater]]></title>
			<link>https://ashus.ashus.net/thread-73.html</link>
			<pubDate>Sat, 19 Apr 2008 00:54:23 +0200</pubDate>
			<dc:creator><![CDATA[<a href="https://ashus.ashus.net/member.php?action=profile&uid=2">Ashus</a>]]></dc:creator>
			<guid isPermaLink="false">https://ashus.ashus.net/thread-73.html</guid>
			<description><![CDATA[A simple script meant to be launched via crontab once a month to keep your offline GeoIP database up-to-date.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#! /bin/bash<br />
<br />
cd /usr/share/GeoIP<br />
<br />
wget "http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz" -O GeoIP.dat.gz<br />
7z e -y GeoIP.dat.gz<br />
rm GeoIP.dat.gz</code></div></div>]]></description>
			<content:encoded><![CDATA[A simple script meant to be launched via crontab once a month to keep your offline GeoIP database up-to-date.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#! /bin/bash<br />
<br />
cd /usr/share/GeoIP<br />
<br />
wget "http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz" -O GeoIP.dat.gz<br />
7z e -y GeoIP.dat.gz<br />
rm GeoIP.dat.gz</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[NOD32 linux mirror update 1.1]]></title>
			<link>https://ashus.ashus.net/thread-62.html</link>
			<pubDate>Sat, 01 Sep 2007 01:03:18 +0200</pubDate>
			<dc:creator><![CDATA[<a href="https://ashus.ashus.net/member.php?action=profile&uid=2">Ashus</a>]]></dc:creator>
			<guid isPermaLink="false">https://ashus.ashus.net/thread-62.html</guid>
			<description><![CDATA[This is a workaround for linux version of NOD32 mirror update server. You still need to purchase a valid key and password to make updates work though. This version is based on work of someone else. I reworked it and included auto-cleanup feature, so all NUP files under mirror directory are checked and if they are not present in update.ver anymore, they get deleted.<br />
<br />
This version of update tool doesn't require ESET Gateway Security and supports mirroring protocol version 2 and 3. Their update URL must be different - filename of both versions is update.ver, the content is different.<br />
<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Installation:</span><ul class="mycode_list"><li>Download and install linux executable <span style="font-weight: bold;" class="mycode_b">unrar-free</span> (Debian package name is unrar-free; it should be compatible with other distributions as well though).<br />
</li>
<li>Download the script below, modify the settings and test the script.<br />
</li>
<li>Configure the webserver to access the mirror update directory at certain path.<br />
</li>
<li>Add the script execution hourly to crontab (ex. 15 * * * * root /root/scripts/nodupdate.sh &amp;&gt; /dev/null).<br />
</li>
<li>Configure NOD32 update server on client computers to use local mirror.</li>
</ul>
<br />
<br />
<a href="http://ashus.ashus.net/viewtopic.php?f=3&amp;t=153" target="_blank" rel="noopener" class="mycode_url">PHP version</a> is more advanced and faster.<br />
<br />
<br />
<!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=66" target="_blank">unrar-free.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">31,96 KB</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">2030</span></span>
</div>
<!-- end: postbit_attachments_attachment --><br />
<!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=73" target="_blank">nodupdate.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">1,52 KB</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">2828</span></span>
</div>
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[This is a workaround for linux version of NOD32 mirror update server. You still need to purchase a valid key and password to make updates work though. This version is based on work of someone else. I reworked it and included auto-cleanup feature, so all NUP files under mirror directory are checked and if they are not present in update.ver anymore, they get deleted.<br />
<br />
This version of update tool doesn't require ESET Gateway Security and supports mirroring protocol version 2 and 3. Their update URL must be different - filename of both versions is update.ver, the content is different.<br />
<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Installation:</span><ul class="mycode_list"><li>Download and install linux executable <span style="font-weight: bold;" class="mycode_b">unrar-free</span> (Debian package name is unrar-free; it should be compatible with other distributions as well though).<br />
</li>
<li>Download the script below, modify the settings and test the script.<br />
</li>
<li>Configure the webserver to access the mirror update directory at certain path.<br />
</li>
<li>Add the script execution hourly to crontab (ex. 15 * * * * root /root/scripts/nodupdate.sh &amp;&gt; /dev/null).<br />
</li>
<li>Configure NOD32 update server on client computers to use local mirror.</li>
</ul>
<br />
<br />
<a href="http://ashus.ashus.net/viewtopic.php?f=3&amp;t=153" target="_blank" rel="noopener" class="mycode_url">PHP version</a> is more advanced and faster.<br />
<br />
<br />
<!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=66" target="_blank">unrar-free.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">31,96 KB</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">2030</span></span>
</div>
<!-- end: postbit_attachments_attachment --><br />
<!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=73" target="_blank">nodupdate.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">1,52 KB</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">2828</span></span>
</div>
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[IP Accounting 1.1 CZ]]></title>
			<link>https://ashus.ashus.net/thread-60.html</link>
			<pubDate>Fri, 17 Aug 2007 16:03:24 +0200</pubDate>
			<dc:creator><![CDATA[<a href="https://ashus.ashus.net/member.php?action=profile&uid=2">Ashus</a>]]></dc:creator>
			<guid isPermaLink="false">https://ashus.ashus.net/thread-60.html</guid>
			<description><![CDATA[Tahle sada skriptů slouží k monitorování dat klientů sítě na routeru.<br />
Sbírá a odlišuje data: na proxy server (kombinace ip a portu), místní síť (ip/maska), internet (vše ostatní).<br />
Podle toho pak zobrazuje data za posledních 24 hodin a za poslední interval ("aktuální" bitrate).<br />
Generuje barevné grafy podle odlišných dat (RRDtool stack).<br />
<br />
Je potřeba: Apache, PHP5, Cron, RRDtool, MySQL.<br />
<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Část první: instalace</span><br />
Pokud vám chybí některá z aplikací výše, doinstalovat. Do databáze přidat tabulku podle obsahu přiloženého souboru db.sql. Nastavit a ověřit nastavení v hlavičce ipaccounting.sh. Dovytvářet chybějící adresáře. PHP soubory hodit na www stránky, přidat do ip.php a iplist.php hlavičky a patičky, aby se to hodilo do theme vaší stránky. Do cronu přidat spouštění skriptu ipaccounting.sh každé 3 minuty (*/3 * * * *). Pokud se rozhodnete používat část skriptu proti zacyklení, nezapomeňte si přidat do skriptu spouštěného po restartu serveru spouštění "ipaccounting.sh clean" - tím se mimo jiné vymaže soubor, který by mohl zůstat přítomný po pádu systému při spuštěném ipaccountingu a zabraňovat dalšímu spouštění.<br />
<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Část druhá: sběr informací</span><br />
Bash skript IP accounting založený na práci Standuse a Bohdyho<ul class="mycode_list"><li>automaticky označí pakety pomocí iptables v tabulce mangle<br />
</li>
<li>data z bufferů každé tři minuty vybírá a nuluje čítače<br />
</li>
<li>sesbíraná data ukládá pro grafy do rrd databází<br />
</li>
<li>do txt souborů ukládá data přenesená v posledním intervalu (aktuální aktivita klientů)<br />
</li>
<li>vše průběžně ukládá do mysql databáze</li>
</ul>
<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Část třetí: interpretace informací pomocí PHP</span><br />
iplist.php, __mysql_connect.php, bar.gif<ul class="mycode_list"><li>vypíše seznam klientů z aktivních (txt) a živých (sql)<br />
</li>
<li>přepočítá aktivitu za poslední interval na lidské jednotky kB(MB)/s<br />
</li>
<li>z databáze vyčte data za posledních 24 hodin pro každou IP adresu zvlášť (a přepočítá)<br />
</li>
<li>tento výčet je jakž takž optimalizován, síť okolo 60 PC trvá na Athlonu 1300MHz, 560MB RAM do 1s, podruhé stejné data (ve stejném intervalu) mysql optimalizuje na ~200ms <br />
</li>
<li>provede DNS resolve jednotlivých adres na názvy<br />
</li>
<li>je k dispozici filtr aktivity: aktivní (nenulové data v intervalu), neaktivní (nenulové data za 24h), všechny<br />
</li>
<li>data lze seřadit<br />
</li>
<li>parametr pro veřejnost skrytý: last=week, month, year (náročné na sql, month mi trvalo 25s)<br />
</li>
<li>u každého klienta je odkaz na skript ip.php</li>
</ul>
<br />
ip.php, make.php, _resolutions.php<ul class="mycode_list"><li>vygeneruje graf datových toků pomocí RRDtool<br />
</li>
<li>barevně odlišuje tři síťové pásma (proxy, czf-lan, net)<br />
</li>
<li>zapamatuje si pomocí cookies poslední zobrazené časové měřítko (1h, 6h, 12h, 1d, 3d, týden, měsíc, rok)<br />
</li>
<li>šetří CPU - pokud není poslední požadovaný generovaný obrázek starší, než minuta, nebude generovat nový, ale jen vyhodí img src</li>
</ul>
<br /><!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=64" target="_blank">IP-accounting.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">8,2 KB</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">1066</span></span>
</div>
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[Tahle sada skriptů slouží k monitorování dat klientů sítě na routeru.<br />
Sbírá a odlišuje data: na proxy server (kombinace ip a portu), místní síť (ip/maska), internet (vše ostatní).<br />
Podle toho pak zobrazuje data za posledních 24 hodin a za poslední interval ("aktuální" bitrate).<br />
Generuje barevné grafy podle odlišných dat (RRDtool stack).<br />
<br />
Je potřeba: Apache, PHP5, Cron, RRDtool, MySQL.<br />
<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Část první: instalace</span><br />
Pokud vám chybí některá z aplikací výše, doinstalovat. Do databáze přidat tabulku podle obsahu přiloženého souboru db.sql. Nastavit a ověřit nastavení v hlavičce ipaccounting.sh. Dovytvářet chybějící adresáře. PHP soubory hodit na www stránky, přidat do ip.php a iplist.php hlavičky a patičky, aby se to hodilo do theme vaší stránky. Do cronu přidat spouštění skriptu ipaccounting.sh každé 3 minuty (*/3 * * * *). Pokud se rozhodnete používat část skriptu proti zacyklení, nezapomeňte si přidat do skriptu spouštěného po restartu serveru spouštění "ipaccounting.sh clean" - tím se mimo jiné vymaže soubor, který by mohl zůstat přítomný po pádu systému při spuštěném ipaccountingu a zabraňovat dalšímu spouštění.<br />
<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Část druhá: sběr informací</span><br />
Bash skript IP accounting založený na práci Standuse a Bohdyho<ul class="mycode_list"><li>automaticky označí pakety pomocí iptables v tabulce mangle<br />
</li>
<li>data z bufferů každé tři minuty vybírá a nuluje čítače<br />
</li>
<li>sesbíraná data ukládá pro grafy do rrd databází<br />
</li>
<li>do txt souborů ukládá data přenesená v posledním intervalu (aktuální aktivita klientů)<br />
</li>
<li>vše průběžně ukládá do mysql databáze</li>
</ul>
<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Část třetí: interpretace informací pomocí PHP</span><br />
iplist.php, __mysql_connect.php, bar.gif<ul class="mycode_list"><li>vypíše seznam klientů z aktivních (txt) a živých (sql)<br />
</li>
<li>přepočítá aktivitu za poslední interval na lidské jednotky kB(MB)/s<br />
</li>
<li>z databáze vyčte data za posledních 24 hodin pro každou IP adresu zvlášť (a přepočítá)<br />
</li>
<li>tento výčet je jakž takž optimalizován, síť okolo 60 PC trvá na Athlonu 1300MHz, 560MB RAM do 1s, podruhé stejné data (ve stejném intervalu) mysql optimalizuje na ~200ms <br />
</li>
<li>provede DNS resolve jednotlivých adres na názvy<br />
</li>
<li>je k dispozici filtr aktivity: aktivní (nenulové data v intervalu), neaktivní (nenulové data za 24h), všechny<br />
</li>
<li>data lze seřadit<br />
</li>
<li>parametr pro veřejnost skrytý: last=week, month, year (náročné na sql, month mi trvalo 25s)<br />
</li>
<li>u každého klienta je odkaz na skript ip.php</li>
</ul>
<br />
ip.php, make.php, _resolutions.php<ul class="mycode_list"><li>vygeneruje graf datových toků pomocí RRDtool<br />
</li>
<li>barevně odlišuje tři síťové pásma (proxy, czf-lan, net)<br />
</li>
<li>zapamatuje si pomocí cookies poslední zobrazené časové měřítko (1h, 6h, 12h, 1d, 3d, týden, měsíc, rok)<br />
</li>
<li>šetří CPU - pokud není poslední požadovaný generovaný obrázek starší, než minuta, nebude generovat nový, ale jen vyhodí img src</li>
</ul>
<br /><!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=64" target="_blank">IP-accounting.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">8,2 KB</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">1066</span></span>
</div>
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Availability]]></title>
			<link>https://ashus.ashus.net/thread-59.html</link>
			<pubDate>Fri, 17 Aug 2007 14:58:57 +0200</pubDate>
			<dc:creator><![CDATA[<a href="https://ashus.ashus.net/member.php?action=profile&uid=2">Ashus</a>]]></dc:creator>
			<guid isPermaLink="false">https://ashus.ashus.net/thread-59.html</guid>
			<description><![CDATA[Simple script, that pings every 10 minutes a stable internet address. The number of successful pings is added to a new line of a data file.<br />
Included PHP script counts relevant nonzero lines from the end of datafile and equates a percentage of availability last month.<br />
<br />
If results are to be accurate, it is required for the server to run 24/7 and for cron to run the script regularly. If the server freezes and is kept frozen for an hour, the percentage may still output 100% incorrectly. On the other hand, the script doesn't require much resources and is as lightweight as it can be.<br /><!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=63" target="_blank">availability.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">863 bytes</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">1018</span></span>
</div>
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[Simple script, that pings every 10 minutes a stable internet address. The number of successful pings is added to a new line of a data file.<br />
Included PHP script counts relevant nonzero lines from the end of datafile and equates a percentage of availability last month.<br />
<br />
If results are to be accurate, it is required for the server to run 24/7 and for cron to run the script regularly. If the server freezes and is kept frozen for an hour, the percentage may still output 100% incorrectly. On the other hand, the script doesn't require much resources and is as lightweight as it can be.<br /><!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=63" target="_blank">availability.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">863 bytes</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">1018</span></span>
</div>
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[SiteCheck SMS]]></title>
			<link>https://ashus.ashus.net/thread-58.html</link>
			<pubDate>Fri, 17 Aug 2007 14:38:36 +0200</pubDate>
			<dc:creator><![CDATA[<a href="https://ashus.ashus.net/member.php?action=profile&uid=2">Ashus</a>]]></dc:creator>
			<guid isPermaLink="false">https://ashus.ashus.net/thread-58.html</guid>
			<description><![CDATA[Bash script, that checks site availability of a network by pinging a target address (eg. hardware AP).<br />
When state changes, an email is send via <span style="font-weight: bold;" class="mycode_b">sendmail</span>. In Czech republic, only O2 and Vodafone give out free SMS support from internet.<br />
<br />
Names of the sites must be resolvable to IP addresses - they have to be in /etc/hosts or an alternative.<br /><!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=62" target="_blank">sitecheck_sms.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">1,01 KB</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">880</span></span>
</div>
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[Bash script, that checks site availability of a network by pinging a target address (eg. hardware AP).<br />
When state changes, an email is send via <span style="font-weight: bold;" class="mycode_b">sendmail</span>. In Czech republic, only O2 and Vodafone give out free SMS support from internet.<br />
<br />
Names of the sites must be resolvable to IP addresses - they have to be in /etc/hosts or an alternative.<br /><!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=62" target="_blank">sitecheck_sms.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">1,01 KB</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">880</span></span>
</div>
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Proxy Guard]]></title>
			<link>https://ashus.ashus.net/thread-57.html</link>
			<pubDate>Fri, 17 Aug 2007 14:35:13 +0200</pubDate>
			<dc:creator><![CDATA[<a href="https://ashus.ashus.net/member.php?action=profile&uid=2">Ashus</a>]]></dc:creator>
			<guid isPermaLink="false">https://ashus.ashus.net/thread-57.html</guid>
			<description><![CDATA[Bash script, that guards the availability or functionality of more cascaded proxy servers in your network and switches trough them to minimize drop-out times. The result is squid.conf, re-applied immediately after change.<br />
<br />
Use cron to execute this script regularly (each 3-10 minutes, depends on how quickly you want your clients happy).<br />
<br />
Two modes are available: automatic and manual - automatics act according to custom settings and switches the cascaded proxy server by priorities of your servers, if the server above in the list doesn't work. Manual settings blocks the automatics and sets an uplink of your choice.<br />
<br />
Furthermore, to test the functionality of the proxy, the script uses links (text web browser), or availability of the site by pinging. Each has its pros and cons: checking functionality - finds out practical real functionality, but is dependant on a website; availability - lesser data rate, but server can be available without working proxy service.<br /><!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=61" target="_blank">proxy_guard.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">1,52 KB</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">1023</span></span>
</div>
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[Bash script, that guards the availability or functionality of more cascaded proxy servers in your network and switches trough them to minimize drop-out times. The result is squid.conf, re-applied immediately after change.<br />
<br />
Use cron to execute this script regularly (each 3-10 minutes, depends on how quickly you want your clients happy).<br />
<br />
Two modes are available: automatic and manual - automatics act according to custom settings and switches the cascaded proxy server by priorities of your servers, if the server above in the list doesn't work. Manual settings blocks the automatics and sets an uplink of your choice.<br />
<br />
Furthermore, to test the functionality of the proxy, the script uses links (text web browser), or availability of the site by pinging. Each has its pros and cons: checking functionality - finds out practical real functionality, but is dependant on a website; availability - lesser data rate, but server can be available without working proxy service.<br /><!-- start: postbit_attachments_attachment -->
<div style="padding:4px 0px;"><span class="inline-block vmiddle"><!-- start: attachment_icon -->
<img src="https://ashus.ashus.net/images/attachtypes/zip.png" title="RAR" alt=".rar" />
<!-- end: attachment_icon --></span>
<a  class="vmiddle inline-block" href="attachment.php?aid=61" target="_blank">proxy_guard.rar</a> <span class="smalltext float_right">Size: <span class="inline-block vmiddle">1,52 KB</span>&nbsp;&nbsp;Downloads: <span class="inline-block vmiddle">1023</span></span>
</div>
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
	</channel>
</rss>