tag:blogger.com,1999:blog-56065547029703043612024-03-13T05:20:56.511+02:00Roeften's thoughtsPanoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.comBlogger40125tag:blogger.com,1999:blog-5606554702970304361.post-17472542859161946642019-02-14T01:14:00.001+02:002019-02-26T19:52:32.799+02:00Thermistor calculatorSee:
<ul>
<li><a href="https://www.ametherm.com/blog/inrush-current/inrush-current-protection-led-lighting-retrofits/">Inrush Current Protection for LED Lighting Retrofits</a></li>
<li><a href="https://www.tdk-electronics.tdk.com/en/373562/tech-library/articles/applications---cases/applications---cases/always-on-the-safe-side/761864">
PTC thermistors for inrush current limiting
</a></li>
</ul>
<script async src="//jsfiddle.net/roeften/xs5460wb/57/embed/result/"></script>Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-5201640908030640832017-01-17T22:06:00.001+02:002017-01-17T22:09:38.984+02:00Mask Calculator<div dir="ltr" style="text-align: left;" trbidi="on" style="min-height:400px;height:auto;">
<script async="" src="//jsfiddle.net/hp6dfnvg/13/embed/result/"></script></div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-81936462944960746662016-12-20T18:12:00.000+02:002016-12-22T20:19:15.445+02:00Centos 7 Install Realtime kernel using yum<div dir="ltr" style="text-align: left;" trbidi="on">
Wanted to try out an <a href="https://rt.wiki.kernel.org/index.php/Frequently_Asked_Questions">rt kernel</a> for my asterisk box. One option is to <a href="http://jensd.be/589/linux/complile-and-use-a-realtime-kernel-on-centos-7-or-rhel-7">build a patched kernel.</a>.
The other option I am trying out now is to install using the Cern repo. I am using a plain Centos 7 installation and not the Cern version.
At the time of writing this I had to install an older version of tuned in order to successfully finish the process:
<br />
<blockquote>
yum install http://ftp.ntua.gr/mirror/centos/7.2.1511/updates/x86_64/Packages/tuned-2.5.1-4.el7_2.6.noarch.rpm</blockquote>
Install the repo in /etc/yum.repos.d/Centos-RT.repo:
<br />
<pre>[rt]
name=CentOS-$releasever - RealTime
baseurl=http://linuxsoft.cern.ch/cern/centos/$releasever/rt/$basearch/
gpgcheck=1
enabled=1
protect=1
priority=10
gpgkey=http://linuxsoft.cern.ch/cern/centos/7/os/x86_64/RPM-GPG-KEY-cern
</pre>
Finally <b>yum groupinstall RT</b> should install the rt kernel. Reboot to use.
I am currently trying it on a VM and so far no issues.<br />
<br />
Some initial <a href="http://kb.digium.com/articles/Configuration/How-to-perform-a-system-latency-test">tests</a>:
<br />
<br />
<b>RT Version (VM):</b><br />
<b> </b>
<br />
<pre><b>chrt -f 99 ./cyclictest -t1 -p 80 -i 10000 -n -l 100000</b>
# /dev/cpu_dma_latency set to 0us
policy: fifo: loadavg: 0.12 0.16 0.10 1/120 10969
T: 0 (10960) P:80 I:10000 C: 16390 Min: 6 Act: 20 Avg: 70 Max: 12866
<b>hdparm -t /dev/sda2</b>
/dev/sda2:
Timing buffered disk reads: 976 MB in 3.07 seconds = 317.71 MB/sec
</pre>
<br />
<b>Normal Version (VM):</b><br />
<b> </b>
<br />
<pre><b>chrt -f 99 ./cyclictest -t1 -p 80 -i 10000 -n -l 100000</b>
# /dev/cpu_dma_latency set to 0us
policy: fifo: loadavg: 0.95 0.37 0.14 1/108 10165
T: 0 ( 8828) P:80 I:10000 C: 4838 Min: 5 Act: 413 Avg: 210 Max: 7676
<b>hdparm -t /dev/sda2</b>
Timing buffered disk reads: 1014 MB in 3.01 seconds = 336.37 MB/sec
</pre>
<br />
After repeating the VM tests, I concluded that the VM is not the proper way to test. I will try it on real hardware later and post the results.<br />
<br />
<b>Normal Version (E5140 - 2 Cores):</b><br />
<b> </b>
<br />
<pre><b>chrt -f 99 ./cyclictest -t1 -p 80 -i 10000 -n -l 100000</b>
# /dev/cpu_dma_latency set to 0us
policy: fifo: loadavg: 0.10 0.04 0.05 1/332 9408
T: 0 ( 9339) P:80 I:10000 C: 6901 Min: 3 Act: 3 Avg: 6 Max: 4503
<b>hdparm -t /dev/sda2</b>
Timing buffered disk reads: 526 MB in 3.01 seconds = 175.04 MB/sec
</pre>
</div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-19963002828135527562016-08-02T16:56:00.003+03:002016-08-02T16:56:39.321+03:00Alcatel OneTouch L850V<div dir="ltr" style="text-align: left;" trbidi="on">
This dongle is recognized out of the box under Centos 7. You get a usbX device. You need to run a dhcp client on the device or there is the option to set an address 192.168.2.[2-254] cause the dongle WUI has 192.168.2.1. There is a hidden menu to access and disable the dhcpd server on the dongle so that you won't need to use dhcp client hooks to avoid your rooting table and dns settings getting changed.<br />
<br />
<b>http://192.168.2.1/index.html#settings/routerSetting.html</b><br />
<br />
<b><br /></b>
<br />
<b> </b></div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-17045642212370359202016-02-09T01:29:00.001+02:002017-03-18T20:22:06.166+02:00Compile deluged in Centos 7 x86_64<div dir="ltr" style="text-align: left;" trbidi="on">
In a proper build environment:<br />
<br />
yum install boost-devel <strike>libgeoip (not supported anymore)</strike><br />
<br />
<br />
Get the latest <a href="https://github.com/arvidn/libtorrent/releases">libtorrent </a>(<a href="https://github.com/arvidn/libtorrent/releases/download/libtorrent-1_1_2/libtorrent-rasterbar-1.1.2.tar.gz">1.1.2</a> at the time). To build it use b2. <br />
<br />
cd /usr/local/src/<br />
mkdir deluge<br />
cd deluge <br />
wget https://github.com/arvidn/libtorrent/releases/download/libtorrent-1_1_2/libtorrent-rasterbar-1.1.2.tar.gz<br />
tar -xvf libtorrent-rasterbar-1.1.2.tar.gz<br />
cd libtorrent-rasterbar-1.1.2<br />
<br />
Edit Jamfile and set all TORRENT_USE_ICONV from 0 to 1.<br />
<br />
#build libtorrent<br />
b2 toolset=gcc link=shared variant=release target-os=linux address-model=64 crypto=openssl<br />
# produces bin/gcc-4.8.5/release/address-model-64/crypto-openssl/threading-multi/libtorrent.so.1.1.2<br />
<br />
cp bin/gcc-4.8.5/release/address-model-64/crypto-openssl/threading-multi/libtorrent.so.1.1.2 /usr/local/lib<br />
ldconfig<br />
<br />
cd bindings/python/<br />
<br />
#build python bindings <br />
b2 toolset=gcc link=shared variant=release target-os=linux address-model=64 libtorrent-link=shared <br />
<br />
# produces: bin/gcc-4.8.5/release/address-model-64/libtorrent-python-pic-on/visibility-hidden/libtorrent.so<br />
<br />
# we need to set the this otherwise deluge setup will try to build libtorrent in a way that does not work<br />
PYTHONPATH=/usr/local/src/deluge/libtorrent-rasterbar-1.0.8/bindings/python/bin/gcc-4.8.5/release/address-model-64/libtorrent-python-pic-on/visibility-hidden<br />
<br />
export PYTHONPATH<br />
<br />
<br />
cd /usr/local/src/deluge/<br />
wget http://download.deluge-torrent.org/source/deluge-1.3.12.tar.bz2 # or get from git or whatever<br />
tar -xvf deluge-1.3.12.tar.bz2<br />
<br />
cd deluge-1.3.12<br />
ln -s /usr/local/src/delug/libtorrent-rasterbar-1.0.8 libtorrent<br />
<br />
python setup.py build<br />
python setup.py install # or bdist if you wise and did that in a virtual environment etc<br />
<br />
You need to copy libtorrent python binding somewhere (like under deluge in /usr/lib/python/site-packages/deluge-1.3.12/deluge) or set the PYTHONPATH in order for the module to be found in runtime. <br />
<br />
<br /></div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-1233066900024257652015-05-01T22:44:00.003+03:002015-05-01T22:45:22.080+03:00Cygwin/X forwarding issues after upgrade<div dir="ltr" style="text-align: left;" trbidi="on">
A quick note if you are using Cygwin/X with putty or an ssh client not running within the cygwin environment: <br />
<br />
<blockquote class="tr_bq">
<b><i>Since X server 1.17, by default the server does not listen for TCP/IP
connections, only accepting local connections on a unix domain socket.</i></b></blockquote>
<br />
That's from the <a href="http://x.cygwin.com/docs/faq/cygwin-x-faq.html#q-xserver-nolisten-tcp-default" target="_blank">FAQ.</a><br />
<br />
A solution is to create a shortcut to Xwin.exe (located in the bin directory of cygwin installation path) either to the desktop or task bar and edit the Target in the shortcut's properties to:<br />
<br />
<b>C:\cygwin64\bin\XWin.exe -multiwindow -listen tcp -silent-dup-error</b><br />
<br />
The listen option is the one that resolves errors like "Cannot open display XX:0".<br />
<br />
There is also a script which sets up more stuff, check the FAQ above.</div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-82337302447487711282015-03-09T15:32:00.003+02:002015-03-09T17:56:07.439+02:00Multicast communication between Arduino (Ethernet library W5100) and a Java application<div dir="ltr" style="text-align: left;" trbidi="on">
Multicast is not supported by the Arduino Ethernet library but is supported by the underlying W5100 module. So to start off, this <a href="https://github.com/arduino/Arduino/pull/1531" target="_blank">patch </a>should be applied to the library (usually located in the arduino IDE directory under libraries\Ethernet\src).<br />
<br />
Note that you may want to update the IP ranges below, I have used the 192.168.100.0/24 network for my tests and 239.100.100.100 multicast group. <br />
<br />
Here is a modified version of the UDPSendReceive example:<br />
<pre class="brush: cpp">/*
UDPSendReceive.pde:
This sketch receives Multicast UDP message strings, prints them to the serial port
and sends an "acknowledge" string back to the group.
created 21 Aug 2010
by Michael Margolis
modified 09 Mar 2015
by Panos Gkikakis
This code is in the public domain.
*/
#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
// Arduino's IP
IPAddress ip(192, 168, 100, 177);
// Multicast group IP
IPAddress mip(239, 100, 100, 100);
// Port
unsigned int localPort = 9999; // local port to listen on
// buffers for receiving and sending data
char packetBuffer[50]; //buffer to hold incoming packet,
char ReplyBuffer[] = "acknowledged"; // a string to send back
char hiBuffer[] = "0:Client ready"; // a string to send back
int c = 0;
// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac, ip);
Udp.beginMulti(mip, localPort);
Serial.begin(9600);
}
void loop() {
// if there's data available, read a packet
int packetSize = Udp.parsePacket();
int n = 0;
if (packetSize)
{
Serial.print("Received packet of size ");
Serial.println(packetSize);
Serial.print("From ");
IPAddress remote = Udp.remoteIP();
for (int i = 0; i < 4; i++)
{
Serial.print(remote[i], DEC);
if (i < 3)
{
Serial.print(".");
}
}
Serial.print(", port ");
Serial.println(Udp.remotePort());
// read the packet into packetBufffer
n = Udp.read(packetBuffer, 50);
packetBuffer[n] = 0;
Serial.println("Contents:");
Serial.println(packetBuffer);
// send a reply, to the IP address and port that sent us the packet we received
Udp.beginPacket(mip, Udp.remotePort());
Udp.write(ReplyBuffer, sizeof(ReplyBuffer));
Udp.endPacket();
}
if( c == 0 ) {
hiBuffer[0] = (hiBuffer[0] > 56) ? 48 : (hiBuffer[0] + 1);
Udp.beginPacket(mip, localPort);
Udp.write(hiBuffer, sizeof(hiBuffer));
Udp.endPacket();
Serial.println(hiBuffer);
c++;
} else if( c > 600) {
c = -1;
}
c++;
delay(10);
}
</pre>
<br />
And here is a corresponding "server" written in java (MLTestServer.java):<br />
<br />
<pre class="brush: cpp">import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MulticastSocket;
import java.net.InetAddress;
import java.net.DatagramPacket;
import java.net.InetSocketAddress;
import java.net.NetworkInterface;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.concurrent.atomic.AtomicReference;
public class MLTestServer {
public static void main(String[] args) {
String msg = "Server online. Keep 'em coming!\0";
String myIP = "192.168.100.1";
String multiAddress = "239.100.100.100";
int port = 9999;
byte[] buf = new byte[100];
ConsoleReader cr = new ConsoleReader();
String ack = "acknowledged";
try {
new Thread(cr).start();
InetAddress group = InetAddress.getByName(multiAddress);
// Q: Why use two sockets one for sending and one for receiving?
// A: There are issues when sending and receiving, namely some messages were not received. If you know why or if that's expected behavior pls let me know.
// Q: Why use the long version of MulticastSocket constructor and joinGroup?
// A: We need to specify the Network interface to get reliable results on multihomed hosts.
MulticastSocket s = new MulticastSocket(new InetSocketAddress(InetAddress.getByName(myIP),port));
MulticastSocket r = new MulticastSocket(new InetSocketAddress(InetAddress.getByName(myIP),port));
s.joinGroup(new InetSocketAddress(group,port), NetworkInterface.getByInetAddress(InetAddress.getByName(myIP)));
r.joinGroup(new InetSocketAddress(group,port), NetworkInterface.getByInetAddress(InetAddress.getByName(myIP)));
// say hello
DatagramPacket hi = new DatagramPacket(msg.getBytes(), msg.length(),group, port);
s.send(hi);
System.out.println("Started server: IP " + s.getLocalAddress() + " port " + s.getLocalPort());
System.out.println("\tMulticast: " + group.getAddress() + " port " + port);
DatagramPacket recv = new DatagramPacket(buf, buf.length);
// server loop
r.setSoTimeout(5);
while(!ConsoleReader.exit) {
try {
java.util.Arrays.fill(buf, (byte) 0);
r.receive(recv);
} catch(SocketTimeoutException te) {
msg = cr.send.get();
if(msg != null && (msg.length() > 0)) {
System.out.println("Sending: " + '"' + msg + '"');
hi = new DatagramPacket(msg.getBytes(), msg.length(),group, port);
cr.send.set("");
s.send(hi);
}
continue;
}
msg = new String(recv.getData());
System.out.println("Message from: " + recv.getAddress() + ":" + recv.getPort() + ":\n" + msg);
}
s.leaveGroup(group);
r.leaveGroup(group);
s.close();
r.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
// thread to read console input
class ConsoleReader implements Runnable {
public static boolean exit = false;
public AtomicReference<String> send = new AtomicReference<String>();
public void run() {
String cmd;
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Commands:\t\nsend msg: sends a message (msg) to clients\t\nexit : end program");
while(true) {
try {
cmd = console.readLine();
if(cmd.compareToIgnoreCase("exit") == 0) {
break;
} else if (cmd.toLowerCase().startsWith("send ")) {
this.send.set(cmd.substring(5) + "\0");
} else {
System.out.println("Unknown command");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
break;
}
}
ConsoleReader.exit = true;
}
}
</pre>
The code should be self explanatory, I have included comments for some gotchas. To compile the java code simply run:<br />
<br />
#compile<br />
<b>javac MLTestServer.java </b><br />
<b>#</b>run <b><br /></b><br />
<b>java -cp . MLTestServer</b><br />
<br />
assuming off course <b>javac </b>and <b>java </b>is in the <b>PATH</b>. </div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-73126843005378994132015-03-03T01:10:00.005+02:002016-10-18T01:07:04.023+03:00Openldap 2.4 on Centos 7 using mdb<div dir="ltr" style="text-align: left;" trbidi="on">
A bit confusing to set up especially for people used to the older slapd.conf. This is not used, do not try to set it, it will be ignored.<br />
<br />
My setup uses the new back-end mdb.<br />
<br />
The very basics is to install the server and client libraries (<b>yum install openldap openldap-clients</b>)<br />
<br />
Configuration is stored under /etc/openldap/slapd.d/. You can view the contents but do not edit the files directly.<br />
<br />
Remove the default configuration <b>rm -rf /etc/openldap/slapd.d/*</b><br />
<br />
Create a file for the initial configuration, let's say main.ldif:<br />
<br />
<pre class="brush: bash">#global configuration
dn: cn=config
objectClass: olcGlobal
cn: config
olcArgsFile: /var/run/openldap/slapd.args
olcPidFile: /var/run/openldap/slapd.pid
olcTLSCACertificatePath: /etc/openldap/certs
olcTLSCertificateFile: "OpenLDAP Server"
olcTLSCertificateKeyFile: /etc/openldap/certs/password
structuralObjectClass: olcGlobal
entryUUID: 0ca4a796-53e8-1034-90ac-5fa43e938d62
creatorsName: cn=config
createTimestamp: 20150228225117Z
entryCSN: 20150228225117.358858Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20150228225117Z
# Load the mdb backend
dn: cn=module,cn=config
objectClass: olcModuleList
cn: module
olcModulepath: /usr/lib64/openldap
olcModuleload: back_mdb
# Load external definitions
dn: cn=schema,cn=config
objectClass: olcSchemaConfig
cn: schema
# You may want to add more, make sure to satisfy any dependencies though
include: file:///etc/openldap/schema/core.ldif
include: file:///etc/openldap/schema/cosine.ldif
include: file:///etc/openldap/schema/nis.ldif
include: file:///etc/openldap/schema/inetorgperson.ldif
include: file:///etc/openldap/schema/openldap.ldif
# front end db
dn: olcDatabase=frontend,cn=config
objectClass: olcDatabaseConfig
objectClass: olcFrontendConfig
olcDatabase: frontend
olcAccess: to * by * read
olcSizelimit: size.soft=10000 size.hard=1000000
olcTimelimit: time.soft=300 time.hard=3600
# configuration db, we define a separate RootDN and passwd, use this one to change the config
dn: olcDatabase=config,cn=config
objectClass: olcDatabaseConfig
olcDatabase: config
olcRootDN: cn=Manager,cn=config
# generate a password by running slappasswd
olcRootPW: {SSHA}XXXXXXXXXXXXXXXXXXXX
olcMonitoring: FALSE
olcAccess: to * by * none
dn: olcDatabase=monitor,cn=config
objectClass: olcDatabaseConfig
olcDatabase: monitor
olcAddContentAcl: FALSE
olcLastMod: TRUE
olcMaxDerefDepth: 15
olcReadOnly: FALSE
olcSyncUseSubentry: FALSE
olcMonitoring: FALSE
olcAccess: to dn.subtree="cn=monitor"
by dn.exact="cn=Manager,cn=config" read
by dn.exact="cn=Manager,dc=example,dc=com" read
by * none
dn: olcDatabase=mdb,cn=config
objectClass: olcDatabaseConfig
objectClass: olcMdbConfig
olcDatabase: mdb
olcMonitoring: TRUE
olcDbMaxSize: 42949672960
olcSuffix: dc=example,dc=com
olcDbDirectory: /var/lib/ldap
olcRootDN: cn=Manager,dc=example,dc=com
# generate a password by running slappasswd
olcRootPW: {SSHA}XXXXXXXXXXXXXXXXXXXX
olcDbIndex: uid pres,eq
olcDbIndex: cn,sn pres,eq,approx,sub
olcDbIndex: mail pres,eq,sub
olcDbIndex: objectClass pres,eq
olcDbIndex: loginShell pres,eq
# Tuning, not sure what these do maybe test them
#olcDbConfig: set_cachesize 0 2097152 0
#olcDbConfig: set_lk_max_objects 1500
#olcDbConfig: set_lk_max_locks 1500
#olcDbConfig: set_lk_max_lockers 1500
#olcLastMod: TRUE
#olcMonitoring: TRUE
#olcDbCheckpoint: 512 30
olcAccess: to attrs=userPassword
by self write
by anonymous auth
by dn.base="cn=Manager,dc=example,dc=com" write
by * none
olcAccess: to attrs=shadowLastChange
by self write
by * read
olcAccess: to *
by dn.exact="cn=Manager,dc=example,dc=com" write
by * read
</pre>
Now add it to the configuration:<br />
<br />
<b>cat main.ldif | slapadd -v -F /etc/openldap/slapd.d -n 0</b><br />
<br />
Start the server:<br />
<br />
<b>systemctl start slapd</b><br />
<br />
Add a root object:<br />
<br />
<pre class="brush: bash">ldapadd -h localhost -D "cn=Manager,dc=example,dc=com" -w YOURPASSWORDHERE <<EOF
dn: dc=example,dc=com
objectClass:top
objectClass:organization
objectClass: dcobject
o: Your organization's name
<<EOF
</pre>
<br />
You should now install <a href="http://phpldapadmin.sourceforge.net/" target="_blank">phpldapadmin </a>or <a href="http://sourceforge.net/projects/jxplorer/" target="_blank">a client of your liking</a> to add more data. A note for phpldapadmin, if you want to connect as the manager you should edit the configuration (/usr/share/phpldapadmin/config/config.php) and make sure<br />
<br />
<b>$servers->setValue('login','attr','dn');</b><br />
<br />
is set. The default seems to be 'uid' which does not work with our manager definition.<br />
<br />
To add to the configuration, for instance to define a custom object, attributes and so on you should use an LDAP client, with the base dn <b>cn=config</b> and the user/pass combination specified for the config database, in our example user name is <b>cn=Manager,cn=config</b>.<br />
<br />
Useful links (somewhat contradicted info though):<br />
<ol style="text-align: left;">
<li><a href="http://www.server-world.info/en/note?os=CentOS_7&p=openldap" target="_blank">http://www.server-world.info/en/note?os=CentOS_7&p=openldap</a> </li>
<li><a href="http://www.nies.ch/doc/openldap-replication.en.php" target="_blank">http://www.nies.ch/doc/openldap-replication.en.php</a> </li>
<li><a href="http://blog.laimbock.com/2013/02/10/fixes-for-the-openldap-example-config-and-deployment-tips/" target="_blank">Fixes for the OpenLDAP example config and deployment tips</a></li>
<li><a href="http://www.openldap.org/doc/admin24/" target="_blank">Admin Guide (clearly not uptodate, still useful though)</a></li>
</ol>
</div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com5tag:blogger.com,1999:blog-5606554702970304361.post-60236689676267754232014-06-18T00:25:00.003+03:002014-06-18T00:26:33.686+03:00Getting Upstart to start services when an interface is up on Centos 6 <div dir="ltr" style="text-align: left;" trbidi="on">
Apparently upstart is not fully integrated to Centos 6.<br />
<br />
For instance having a service like:<br />
<br />
<b>start on (net-device-up INTERFACE=lo)</b><br />
<br />
will not work.<br />
<br />
The solution which maintains compatibility with updates:<br />
<br />
<b><u><i>Create /sbin/ifup-local:</i></u></b><br />
<br />
<blockquote class="tr_bq">
#!/bin/sh<br />
initctl emit --no-wait net-device-up INTERFACE=$1</blockquote>
<br />
and make it executable.<br />
<br />
<br /></div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-11026355125641544452014-04-18T20:06:00.001+03:002014-04-18T20:06:05.364+03:00Arduino ebay clone droubles...<div dir="ltr" style="text-align: left;" trbidi="on">
So wanted to try <a href="http://www.ebay.com/sch/i.html?_trksid=p2047675.m570.l1313.TR0.TRC0.H0&_nkw=Version+Board+ATmega328P+UNO+R3+ATmega16U2&_sacat=0&_from=R40">these </a>arduino clones from ebay and have some feedback.<br />
<br />
The one I got has both male and female connectors for pins. I placed my ethernet shield on top of it and tried to power it up with no luck. Apparently the <a href="http://arduino.cc/en/Reference/SPI">ICSP</a> is up side down! The solution is to either cut the ICSP pins from the controller and the shield and then wire manually to the shield or rotate the shield 180o and wire any additional pins from the controller to the shield. Pins as shown <a href="http://arduino.cc/en/Reference/SPI">here</a> from the shield should be wired to pins 12,VCC,13,11,RESET and GND in order for everything to work that is if you choose the former solution. I haven't tested which pins are required for the other solution. Keep in mind that if you simply rotate the shield (180o) you still may run into trouble because more pins are used by the (W5100) ethernet shield.<br />
<br />
As a last reminder make sure not to use pins 4 and 10 as they are used by the shield as well.<br />
<br />
The error you may get is a 0.0.0.0 address from Ethernet.LocalIP(). </div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-19601397526684440422014-01-19T19:34:00.001+02:002014-01-19T19:43:25.781+02:00ZTE H108NS & telnet <div dir="ltr" style="text-align: left;" trbidi="on">
Some issues you may encounter when trying to telnet<b> ZTE H108NS</b> modem:<br />
<br />
<i><u>1. You cannot connect at all</u></i><br />
<br />
In that case from the Web UI go to <b>Access Management -> ACL </b>and edit or create a rule for the LAN interface which allows telnet connections from your subnet.<br />
<br />
<br />
<i><u>2. Password is not accepted</u></i><br />
<br />
The web ui password may differ from the console password but there is a way... Go to <b>Maintainance -> Firmware</b> and press the <b>ROMFILE BACKUP</b> button to download a copy of the configuration parameters. View the (xml) file with any text editor and locate the admin user entry under Account:<br />
<br />
<br />
<pre>
<account>
<entry0 br="" username="admin" web_passwd="yourwebuipasswd">console_passwd="<b>telnetpasswdhere</b>" display_mask="FF FF FF FF FF FF FF FF FF" /><br /> .......<i> more entries which hopefully are not the same in all modems but I doubt it</i> .......
</entry0>
</account>
</pre>
<br />
The telnet password is stored in the <b>console_passwd</b> attribute.</div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-28978138672835692252014-01-16T23:25:00.001+02:002014-01-23T14:39:40.663+02:00Compiling Grive on Centos with unsupported Boost/CMake version.<div dir="ltr" style="text-align: left;" trbidi="on">
In the absence of a Google Drive client version for linux, I tried to compile grive (0.3.0-pre) which is an open source client using the Google APIs:<br />
<br />
Install all dependencies first, try <i><b>yum install gcc-c++ expat-devel json-c-devel libgcrypt-devel curl-devel</b></i><br />
<br />
If the CMake version is old, get the appropriate version of CMake and do not install it:<br />
<br />
<blockquote class="tr_bq">
<b>#cd /usr/local/src </b></blockquote>
<blockquote class="tr_bq">
<b>#wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2-Linux-i386.sh </b></blockquote>
<blockquote class="tr_bq">
<b>#./cmake-2.8.10.2-Linux-i386.sh .</b></blockquote>
<blockquote class="tr_bq">
<a href="http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz"><u>That's for i386, it seems for x64 you need to compile it from source. </u></a></blockquote>
<br />
If the Boost version is older and cmake complains about it:<br />
<br />
1. <a href="http://sourceforge.net/projects/boost/files/boost/1.55.0/">Download </a>the appropriate version of boost (most current right now is 1.55) and extract it to /usr/local/src:<br />
<blockquote class="tr_bq">
<br />
<b>#tar -xvf boost_1_55_0.tar.bz2</b><br />
<b>#cd boost_1_55_0</b><br />
<b>#./bootstrap.sh --prefix=/usr/local/src/boost_1_55_0/lib/</b><br />
<b>#./b2 --build-dir=/usr/local/src/boost_1_55_0/lib/ --with-system --with-filesystem --with-program_options --with-test</b> </blockquote>
<br />
2. Download and compile <a href="https://github.com/lloyd/yajl">yajl</a>. (<b>./configure && make</b>). Assuming that it's located at <b>/usr/local/src/yajl</b><br />
<br />
3. Back to the Grive directory. I should mention that I removed bgrive from <b>CMakeLists.txt </b>because I did not need it. You must add the following commands in CMakeLists.txt<b> </b><br />
<blockquote class="tr_bq">
</blockquote>
<blockquote class="tr_bq">
<b>INCLUDE_DIRECTORIES(/usr/local/src/boost_1_55_0)</b><br />
<b>INCLUDE_DIRECTORIES(/usr/local/src/yajl/build/yajl-2.0.5/include/)</b><br />
<b>link_directories(/usr/local/src/yajl/build/yajl-2.0.5/lib/)</b><br />
<b>link_directories(/usr/local/src/boost_1_55_0/stage/lib/)</b></blockquote>
Then run:<br />
<blockquote class="tr_bq">
<b>#../cmake-2.8.10.2-Linux-i386/bin/cmake -D BOOST_ROOT:FILEPATH="/usr/local/src/boost_1_55_0" </b><b><b> -D Boost_LIBRARY_DIRS:FILEPATH="/usr/local/src/boost_1_55_0/stage/lib"</b> </b><b>.</b> </blockquote>
(There is a dot as the very last argument). <br />
<br />
Try to run make.<br />
<br />
If you get any errors about ambiguous log entries, do the following:<br />
<br />
Assuming you have vim, edit grive/src/main.cc and type as an editor command<b>: %s/log::/gr::log::/</b><br />
<br />
If you don't have vim what you need to do is to change all instances of <b>log::</b> to<b> gr::log::</b><br />
<br />
Finally if you still get errors like <i>"undefined reference to `gr::Json::Json</i><long><i>(long const&)" </i>make the trivial edits to libgrive/src/drive/State.cc as described <a href="https://github.com/Grive/grive/issues/193">here.</a></long><br />
<br />
<b><i><u><long>After thoughts:</long></u></i></b><br />
<br />
<long>To install to another binary compatible machine without rebuilding, you need to copy the compiled libraries and install the dependencies as well: </long><br />
<long><br /></long>
<long>Install depedencies: <b>#yum install </b></long><b>expat json-c libgcrypt curl</b><br />
<br />
Copy all compiled libraries to /usr/local/lib[64]:<br />
<br />
<ol style="text-align: left;">
<li><i><b> From /usr/local/src/boost_1_55_0/stage/lib/</b></i></li>
<ul>
<li><i><b>All *.so.1.55.0 </b></i></li>
</ul>
<li><i><b> From /usr/local/src/yajl/build/yajl-2.0.5/lib/</b></i></li>
<ul>
<li><i><b> libyajl.so.2.0.5</b></i></li>
</ul>
</ol>
<br />
Create symbolic links for all the libraries you've copies and use the library name without the appended version as the link name, eg:<br />
<br />
<div style="text-align: left;">
<b>#ln -s libboost_filesystem.so.1.55.0 libboost_filesystem.so</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Copy the grive binary to /usr/local/bin or any convenient location<i><b><br /></b></i></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
Finally run <i><b>ldconfig /usr/local/lib[64]</b><b><br /></b></i></div>
</div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-51329268954749732532013-12-14T21:23:00.001+02:002013-12-21T04:18:38.561+02:00Updating Fedora 17 to 20<div dir="ltr" style="text-align: left;" trbidi="on">
To update, the recommended method is using fedup. Pretty straight forward. I was using the LXDE spin.<br />
<br />
The only issue I had is that after the upgrade I got the console login. The runlevel was right though (5 not 3). For some reason there was no display manager in the systemd configuration.<br />
<blockquote class="tr_bq">
<i><b>ln -s /lib/systemd/system/lxdm.service /etc/systemd/system/display-manager.service</b></i></blockquote>
solved the issue.<br />
<br />
* Update *<br />
<br />
A few more issues to be solved:<br />
<br />
1. If you are getting polkit errors uncheck LXPolkit from Preferences -> Desktop Session Settings.<br />
<br />
2. There is a <a href="https://bugzilla.redhat.com/show_bug.cgi?id=753882">bug</a> somewhere causing issues with pulse audio when you switch users. My solution was to edit <b>/usr/bin/startlxde</b> and add <b> </b><br />
<blockquote class="tr_bq">
<b>unset XDG_RUNTIME_DIR</b> </blockquote>
<br />
as the very first command. Logout and in and problems should be gone!</div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-56619398463995131532013-04-08T20:23:00.001+03:002013-04-08T20:27:03.991+03:00Internet offline - captive portal<div dir="ltr" style="text-align: left;" trbidi="on">
A demonstration of redirecting users to an offline page when the internet connection is down. This is done using the ip-up/down scripts of pppd, memcached and iptables.<br />
<br />
Only makes sense to watch in HD and full screen. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/0-GXkf81mWA?feature=player_embedded' frameborder='0'></iframe></div>
</div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com1tag:blogger.com,1999:blog-5606554702970304361.post-86640281192385104632012-11-05T18:15:00.000+02:002012-11-06T02:28:35.653+02:00Adding files to disk images<div dir="ltr" style="text-align: left;" trbidi="on">
Say you have a bootable floppy image for instance from <a href="http://www.fdos.org/bootdisks/">here</a>, but you want to add files to it, like bios flash files before you bake it.<br />
<br />
On linux it's easy:<br />
<br />
<b>losetup -f</b><br />
<br />
will give you the first available loop device, eg. .dev/loop0<br />
<br />
<b>losetup /dev/loop0 fdodin06.img</b><br />
<br />
will setup the loop device with the disk image<br />
<br />
you can now mount /dev/loop0 and add files to it. I suspect you can add files up to the size of the image which is fixed. <br />
<br />
easy.<br />
<br /></div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0Eparchiaki Odos Iou-Ormou Iou, Ios 840 01, Greece36.72725046551043 25.27776002883911136.726454965510428 25.276526028839111 36.728045965510432 25.278994028839112tag:blogger.com,1999:blog-5606554702970304361.post-32398035037757188082012-10-11T19:31:00.001+03:002015-02-22T20:36:14.028+02:00Controlling an A/C unit using LIRC on centos<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
UPDATE 22/2/15: OK apparently the reason for the mess is that lirc_serial needs to be compiled/provided/supported by the kernel and is not included in recent lirc versions. <a href="http://www.elrepo.org/" target="_blank">ELREPO </a>has kmod-lirc for Centos that seems to work out of the box (manually load it after "<b>setserial /dev/ttyS? uart none</b>" for el7 too). So you can install lirc using yum.<br />
<br />
I needed to turn on the AC unit in a small server room. It would go off when a power failure occurred.<br />
<br />
I purchased a <a href="http://iguanaworks.net/products/series-transceiver/">serial transceiver from Iguana works.</a><br />
<br />
Since Centos' (2.6.18-274.7.1.el5) lirc package did not include the default driver and lirc_serial modules, I downloaded <a href="http://prdownloads.sourceforge.net/lirc/lirc-0.8.7.tar.bz2">lirc-0.8.7 </a>(lirc-0.9.0 would not compile).<br />
<br />
Compilation is pretty straight forward:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">./setup.sh</span><br />
<span style="font-family: "Courier New",Courier,monospace;"><br />make</span><br />
<span style="font-family: "Courier New",Courier,monospace;"><br /></span>
<span style="font-family: "Courier New",Courier,monospace;">make install</span><br />
<br />
<span style="font-family: inherit;">During setup I chose the serial port the transceiver was on.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Next steps are:</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Copy the init script from contrib and adjust it to your requirements. Do not start lirc though.</span><br />
<br />
<b><span style="font-family: inherit;">Here is my init script:</span></b><br />
<br />
<pre><span style="font-family: inherit;">
#!/bin/sh
#
# lirc: This is an init script for RedHat distribution.
#
# Author: Denis V. Dmitrienko <denis null.net="null.net">
#
# chkconfig: 345 95 10
# description: lirc is a Linux Infrared Remote Control system.
# Source function library.
. /etc/rc.d/init.d/functions
[ -f /usr/local/sbin/lircd ] || exit 0
[ -f /usr/local/sbin/lircmd ] || exit 0
PATH=/usr/local/sbin:/usr/local/bin:$PATH
LIRC_CONFIG=/etc/lirc/lircd.conf
DRIVER=default
DEVICE=/dev/lirc</denis></span></pre>
<pre><denis null.net="null.net">PORT=/dev/ttyS1</denis></pre>
<pre><denis null.net="null.net"> </denis></pre>
<pre><denis null.net="null.net"># Load LIRC config
[ -f /etc/sysconfig/lirc ] && . /etc/sysconfig/lirc
# See how we were called.
case "$1" in
start)
echo -n "Starting Infrared Remote Control: "
setserial $PORT uart none
if [ "$MODULES" != "" ]; then
IFS=" "
for MODULE in $MODULES
do
modprobe $MODULE
done
fi
daemon lircd --device=$DEVICE --driver=$DRIVER $LIRCD_ARGS $LIRC_CONFIG
daemon lircmd </denis><denis null.net="null.net"><span style="font-family: inherit;">$LIRC_CONFIG</span>
echo
touch /var/lock/subsys/lirc
;;
stop)
echo -n "Shutting down Infrared Remote Control: "
killproc lircmd
killproc lircd
echo
rm -f /var/lock/subsys/lirc
;;
status)
status lircd
status lircmd
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: lirc {start|stop|status|restart}"
exit 1
esac
exit 0
</denis></pre>
</div>
</div>
</div>
</div>
</div>
<b><span style="font-family: inherit;">
Create /etc/sysconfig/lirc file:</span></b><br />
<br />
<pre><span style="font-family: inherit;"># Arguments which will be used when launching lircd
LIRCD_ARGS=""
# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="default"
# Check which the name when lirc_serial is loaded
DEVICE="/dev/lirc0"
# lirc_dev will be loaded automatically
MODULES="lirc_serial"</span></pre>
<pre><span style="font-family: inherit;"> </span></pre>
<pre><span style="font-family: inherit;">#the serial port of your device </span></pre>
<pre><span style="font-family: inherit;">PORT="/dev/ttyS1" </span></pre>
<span style="font-family: inherit;">
</span>
<span style="font-family: inherit;">Try to start lirc now.</span><br />
<span style="font-family: inherit;">Make sure that lirc_serial is loaded i.e. lsmod | grep lirc should produce something similar to:</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">lirc_serial 16980 1<br />lirc_dev 17176 3 lirc_serial</span><br /> </span></span><br />
<br />
<span style="font-family: inherit;">AC remote signals are more like complete status updates than state relative commands. irrecord will not work with that. Use
<b> mode2 -m</b> and for each remote command capture the output in a file. <b>Lircd must be stopped in order for mode2 to work</b> Remove any blank lines and the first line if it only contains one number (leave any 6 columns of numbers). Repeat the process for any other states you wish. Capturing under fluorescent light can cause errors so turn off the lights for better results. <b>When you use mode2 lirc should not be running.</b></span><br />
<span style="font-family: inherit;"><br />Create the /etc/lirc/lircd.conf file and add the data from the previous step inside the raw_codes section. Precede each data block with a name line as shown below.</span>
<br />
<span style="font-family: "Courier New",Courier,monospace;"><br /></span>
<br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: inherit;"></span></span>
<br />
<pre>begin remote
name AC
flags RAW_CODES
frequency 38000
gap 107326
begin raw_codes
name ON_24
9115 4427 698 1594 585 1710
661 460 688 455 585 536
716 429 585 1708 691 1629
617 1675 585 1708 688 1606
689 457 663 455 691 455
666 455 691 1629 592 1700
585 1708 610 1681 719 430
689 429 689 457 666 455
691 455 689 457 689 1603
692 429 716 1576 717 429
589 532 716 430 584 562
591 530 690 456 689 429
691 458 688 430 689 1603
717 432 582 563 590 529
717 429 691 430 716 430
691 430 686 460 688 430
719 429 689 458 663 455
607 514 716 430 585 535
717 1601 690 431 690 455
689 458 665 456 660 458
691 455 608 512 691 455
587 534 691 456 690 455
585 536 691 455 587 531
692 457 589 530 690 456
607 538 591 530 691 455
666 455 691 455 663 456
690 1604 716 431 605 540
590 528 694 453 665 456
690 455 666 455 688 458
665 453 694 455 691 1601
691 455 615 1677 608 513
691 455 589 530 693 455
605 540 610 509 691 456
665 455 691 455 666 455
690 456 665 1627 606 1687
692
name ON_25
9034 4483 663 1629 663 1629
663 483 587 534 663 483
587 534 661 1631 663 1657
663 1629 663 1629 663 1657
636 1656 635 486 661 485
636 482 663 1657 668 1624
587 1708 633 1659 689 457
635 486 661 485 635 483
663 483 663 1632 663 1629
688 458 587 533 687 460
642 476 663 483 587 559
589 532 663 483 591 530
662 484 635 483 663 1632
662 484 607 538 615 506
663 484 589 529 663 483
637 484 688 458 636 484
663 484 662 484 663 457
661 485 636 482 608 513
663 1657 663 455 689 458
665 481 663 457 664 482
638 483 608 510 691 455
587 535 662 483 664 482
585 536 663 483 585 536
689 457 587 531 664 482
608 538 587 534 663 483
592 529 663 483 638 480
666 1629 688 458 608 538
587 534 663 483 589 529
666 480 638 483 663 482
639 483 662 484 663 1629
691 455 614 1678 587 534
663 483 589 531 664 482
608 539 639 1653 608 512
664 483 584 534 665 483
587 532 690 1602 691 1629
663
name OFF
9144 4425 642 1652 583 1710
688 430 693 453 663 458
692 454 607 1685 693 1627
591 1701 584 1708 691 1603
692 1601 693 453 638 482
692 455 605 1687 693 1627
665 1627 665 1627 591 530
693 453 665 453 694 455
605 541 665 453 693 453
668 452 694 452 666 456
691 455 665 453 693 455
692 455 665 452 692 429
694 453 633 487 691 1627
668 452 693 453 691 455
666 456 688 429 694 455
658 461 692 453 608 513
691 455 693 453 605 516
691 455 589 529 693 453
593 1702 606 512 694 452
694 455 605 513 695 451
610 511 693 453 665 455
692 455 605 541 638 480
693 456 665 453 693 453
666 455 691 455 665 455
691 455 691 456 665 453
691 430 693 453 661 459
691 455 606 513 693 455
691 455 606 513 693 452
611 510 694 453 637 483
691 455 633 513 589 1703
634 487 691 1629 665 453
661 460 691 455 633 485
694 453 693 455 606 1686
689 1603 694 1599 693 1601
691 455 605 513 694 1626
666
end raw_codes
end remote </pre>
<br />
The gap value can be any number similar to what I've used, it does not matter since it doesn't apply for AC remotes. If it<span style="font-family: inherit;">'s</span> too big it will block irsend for a significant amount of time though.<br />
<br />
Next step is to try and start lirc. If all goes well you should be able to try sending commands using:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">irsend DIRECTIVE REMOTE_NAME CODE_NAME </span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;">for instance:</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">irsend SEND_ONCE AC ON_24</span><br />
<br />
<br /></div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-82171531124039251782012-09-24T20:27:00.000+03:002012-09-24T20:27:25.209+03:00MSXML 4 SP3 hangs on message “please wait while the installer finishes determining your disk space requirements”<div dir="ltr" style="text-align: left;" trbidi="on">
Secunia PSI warned me about an insecure version of MSXML 4 in my system and suggested windows update. There was no update available to solve the issue though. I removed MSXML 4 SP2 and tried to install MSXML 4 SP3 from <a href="http://www.microsoft.com/en-us/download/details.aspx?id=15697">here</a>. Unfortunatelly the installer was hanging on calculating space requirements with the pop up “please wait while the installer finishes determining your disk space requirements”.<br />
<br />
The only solution I found to work is to run the installer manually using a command prompt:<br />
<br />
<b>msiexec /package msxml.msi /qr</b><br />
<b><br /></b>
which runs the installer with reduced GUI.</div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-14952174458519017802011-02-19T16:57:00.007+02:002011-02-21T06:17:09.113+02:00Multi homed host, arp flux and source base routingIf you have a linux box and multiple interfaces on the same subnet you may notice that all traffic is really going through the first interface. This is not a problem unless if you want to differentiate services per interface. For example I have a host with 2 interfaces on subnet 192.168.1.0:<br />
<br />
eth0 : 192.168.1.1<br />
eth1 : 192.168.1.2<br />
<br />
Now on eth0 I want to run smb and on eth1 Alfresco's smb service.<br />
<br />
After making sure that each service binds on a specific interface:<br />
<br />
i) Alfresco (3.4b):<br />
<br />
File: <b>webapps/alfresco/WEB-INF/classes/alfresc o/subsystems/fileServers/default/file-servers.properties</b><br />
<br />
<b>cifs.enabled=true<br />
cifs.serverName={Your hostname on that interface}<br />
cifs.domain={a workgroup}<br />
cifs.broadcast=192.168.1.255<br />
cifs.bindto=192.168.1.2<br />
cifs.tcpipSMB.port=4450<br />
cifs.netBIOSSMB.sessionPort=1390<br />
cifs.netBIOSSMB.namePort=1370<br />
cifs.netBIOSSMB.datagramPort=1380</b><br />
<br />
Obviously you need to adjust some values to your specific needs. If you like me run tomcat as an unprivileged user you should set higher than 1024 ports and use iptables to redirect:<br />
<br />
<b>iptables -t nat -F PREROUTING<br />
iptables -t nat -A PREROUTING -i eth1 -p tcp -m tcp --dport 445 -j REDIRECT --to-ports 4450<br />
iptables -t nat -A PREROUTING -i eth1 -p tcp -m tcp --dport 139 -j REDIRECT --to-ports 1390<br />
iptables -t nat -A PREROUTING -i eth1 -p udp -m udp --dport 137 -j REDIRECT --to-ports 1370<br />
iptables -t nat -A PREROUTING -i eth1 -p udp -m udp --dport 138 -j REDIRECT --to-ports 1380</b><br />
<br />
(You should also add rules for INPUT if the default policy is not ACCEPT)<br />
<br />
ii) Samba<br />
<br />
File: /etc/samba/smb.conf<br />
<br />
Add to global:<br />
<br />
<b>bind interfaces only = yes<br />
interfaces = lo eth0</b><br />
<br />
Now restarting nmb, smb and tomcat/alfresco will apply all changes. Unfortunately this may not be enough. You have to make sure that traffic for interface eth1 is delivered to it. Or more precisely that outgoing traffic is sent through eth1 when the source is 192.168.1.2<br />
<br />
The solution is source based routing:<br />
<br />
1) Create a table alias, here called surlatable:<br />
<br />
<b>echo 200 surlatable >> /etc/iproute2/rt_tables</b><br />
<br />
2) Traffic with source 192.168.1.2 should be routed according with the newly created table:<br />
<br />
<b>ip rule add from 192.168.1.2 table surelatable</b><br />
<br />
3) Local and (optionally) Default routes <br />
<br />
<b>ip route add 192.168.1.0/24 via 192.168.1.2 dev eth1 table surelatable </b><br />
<b>ip route add default via {GATEWAY} dev eth1 table surelatable</b><br />
<br />
4) Apply changes<br />
<br />
<b>ip route flush cache</b><br />
<br />
You may want to make these changes permanent by adding the commands in /sbin/if-up.local script (for fedora) when eth1 comes up.<br />
<br />
Lastly fix the ARP FLUX issue by editing/adding to /etc/sysctl.conf:<br />
<br />
<b>net.ipv4.conf.default.arp_announce = 2<br />
net.ipv4.conf.default.arp_ignore = 1</b><br />
<br />
Modern kernels support these flags and are compiled with Advanced routing features. You can apply these without rebooting:<br />
<br />
echo 2 > /proc/sys/net/ipv4/conf/default/arp_announce<br />
echo 1 > /proc/sys/net/ipv4/conf/default/arp_ignore<br />
<br />
Now you can verify that everything is working. Make sure to clear the arp cache of the computer you will use as a client. Then ping both interfaces and check the cache. Each address should have the correct MAC address listed.<br />
<br />
For more details on advanced routing and much more, don't miss <a href="http://lartc.org/howto/index.html">Linux Advanced Routing & Traffic Control HOWTO</a>Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-51094028826502483542011-02-17T07:53:00.003+02:002011-02-17T07:55:30.140+02:00I am sorry firefoxI have always been using Firefox for anything that had to do with browsing (apart from some websites that only work with IE). My habit is to leave it running for days and after a point it does become slow. I thought it had to do with its infamous memory leaks and did not believe the official response that caching is raising memory consumption. I was wrong.<br />
<br />
I have started using Chrome which does look fast (reality is, it is faster for the most part) when you are not using it :-) Today I woke up and Chrome was almost unresponsive. Here is a screen shot of task manager:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-px9QJ6BguRY/TVy3vZOpabI/AAAAAAAAABY/lU81zNIJZio/s1600/ps.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" src="http://1.bp.blogspot.com/-px9QJ6BguRY/TVy3vZOpabI/AAAAAAAAABY/lU81zNIJZio/s1600/ps.png" /></a></div><br />
I am really sorry Firefox :-)Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com1tag:blogger.com,1999:blog-5606554702970304361.post-58189900809770225522011-01-27T18:58:00.004+02:002011-01-28T21:47:37.208+02:00ICH5 sound issues with FedoraI had an Albatron mobo running FC10. All was well and it could handle multiple services running headless for years.<br />
<br />
Then I needed to run mpg123 24/7 and I found out how problematic the ICH5 ALC655 chip was with linux. I could get sound however at random instances the audio would go off. At first I though mpg123 was the problem so I ran it under supervise. At a point I came across <a href="http://www.google.com/url?sa=t&source=web&cd=5&sqi=2&ved=0CD8QFjAE&url=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmusicpd%2F&rct=j&q=mpd%20music%20player&ei=Yp1BTbmsDMSohAectcD_AQ&usg=AFQjCNHE-vIHrKMBFLrGAoVn3e59Po47yw&sig2=4ONvt3eGw8JlM5WuBuFlcQ&cad=rja">MPD</a> and I ditched mpg123 for it. I discovered that the same thing happened to mpd. Only I also discovered that audio would come back after a random duration of time.<br />
<br />
To cut a long story short I assumed the alsa driver intel8x0 was responsible. Somewhere in the net a mention of a kernel patch solving the issues on FC12 made me preupgrade to FC12. After a few hours of readjusting everything to work I came to find that the sound issues were still there. I activated <a href="http://www.pulseaudio.org/">PulseAudio</a>, a sound server which uses the Alsa drivers and can sit on top of Alsa. As a side note PulseAudio is the default in FC12 however since I preupgraded from FC10 it was not. Then tried mpd using PulseAudio, Alsa (via PulseAudio) with no luck. Oh linux has a wonderful world of sound software which takes forever to configure and understand. Then I read someone suggesting (the older and not really open) OSS as a solution to all your problems. I installed it to find out the problem was still there! Only this time the kernel said:<br />
<br />
Jan 26 22:56:12 dryad kernel: irq 17: nobody cared (try booting with the "irqpoll" option)<br />
Jan 26 22:56:12 dryad kernel: Pid: 0, comm: swapper Tainted: P 2.6.32.26-175.fc12.i686 #1<br />
Jan 26 22:56:12 dryad kernel: Call Trace:<br />
Jan 26 22:56:12 dryad kernel: [<c0485714>] __report_bad_irq+0x33/0x74<br />
Jan 26 22:56:12 dryad kernel: [<c048584f>] note_interrupt+0xfa/0x153<br />
Jan 26 22:56:12 dryad kernel: [<c0485e24>] handle_fasteoi_irq+0x83/0xa2<br />
Jan 26 22:56:12 dryad kernel: [<c0405637>] handle_irq+0x40/0x4d<br />
Jan 26 22:56:12 dryad kernel: [<c0404dfd>] do_IRQ+0x46/0x9a<br />
Jan 26 22:56:12 dryad kernel: [<c0403c90>] common_interrupt+0x30/0x38<br />
Jan 26 22:56:12 dryad kernel: [<c04096dd>] ? mwait_idle+0x61/0x6c<br />
Jan 26 22:56:12 dryad kernel: [<c0402728>] cpu_idle+0x96/0xb2<br />
Jan 26 22:56:12 dryad kernel: [<c0783f64>] rest_init+0x58/0x5a<br />
Jan 26 22:56:12 dryad kernel: [<c09dc8d6>] start_kernel+0x33c/0x341<br />
Jan 26 22:56:12 dryad kernel: [<c09dc097>] i386_start_kernel+0x97/0x9e<br />
Jan 26 22:56:12 dryad kernel: handlers:<br />
Jan 26 22:56:12 dryad kernel: [<f83d474a>] (osscore_intr+0x0/0x4a [osscore])<br />
Jan 26 22:56:12 dryad kernel: Disabling IRQ #17<br />
Jan 26 22:56:12 dryad kernel: osscore: Output timed out on audio engine 1/'Intel ICH5 (24D5) (vmix)' (count=39919616)<br />
Jan 26 22:56:12 dryad kernel: 157856 fifo errors were detected<br />
Jan 26 23:05:20 dryad kernel: 1401 fifo errors were detected<br />
Jan 26 23:07:22 dryad kernel: usbcore: deregistering interface driver oss_usb<br />
Jan 26 23:07:22 dryad kernel: oss_ich 0000:00:1f.5: PCI INT B disabled<br />
<br />
As I visualize it that means that the driver was eventually waiting for a write, the IRQ was set however somehow was not serviced by the appropriate handler. A kernel issue perhaps. The result was the blocking call was blocking the driver all the way up to the application which initiated the call.<br />
<br />
I did not try the <a href="http://www.linuxtopia.org/online_books/linux_kernel/kernel_configuration/re17.html">irqpoll</a>option yet. I will do so after I try <a href="http://www.linuxtopia.org/online_books/linux_kernel/kernel_configuration/re12.html">noapic</a> first. I did try <a href="http://www.linuxtopia.org/online_books/linux_kernel/kernel_configuration/re18.html">noirqdebug </a>which does not affect the issue. <br />
<br />
In the meantime I am trying one of these super cheap usb sound dongles. It does not work really:<br />
<br />
<b>Bus 002 Device 002: ID 1130:f211 Tenx Technology, Inc. audio headset</b><br />
<br />
Next thing to try is a YMF724 PCI card found on storage.<br />
<br />
UPDATE: YMF724 worked out of the box (mpd cpu dropped around 4% when no streaming). I decided to stop pursuing a solution with the onboard chip. Does not worth it.<br />
<br />
alsa-lib-1.0.23<br />
kernel 2.6.32.26-175Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-53015616668575049142011-01-26T13:10:00.000+02:002011-01-26T13:10:03.391+02:00alternativesThe alternatives utility automates managing multiple programs with the same function.<br />
<br />
For instance if you want to use qmail instead of the default sendmail, install qmail and then issue:<br />
<br />
<b>alternatives --install /usr/sbin/sendmail mta /var/qmail/bin/sendmail 50 --slave /usr/lib/sendmail mta-sendmail /var/qmail/bin/sendmail</b><br />
<br />
There are more slave links to explore, but I think it works for the most part.<br />
<br />
Then run <b>alternatives --config mta</b> to verify that qmail is the preferred choice.<br />
<br />
To go back you can simply run the later command again and make a new choice.Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-9288131113568971292010-10-29T22:19:00.000+03:002010-10-29T22:19:10.795+03:00Android VPN - Want to kill selfAfter days of trying to setup openswan and make it work via IPSec/L2TP with roadwarriors and ultimately make it work with my Nexus One, I now want to kill myself. Setting up openswan is no easy task and requires reading from various sources and skim through outdated posts. <br />
<br />
However I did get it to work as expected with Windows road warriors.<br />
<br />
It appears that racoon (the IKE daemon on Nexus) dies soon after the tunnel is established:<br />
<script type="syntaxhighlighter" class="brush: bash"><![CDATA[
19:34:15.596558 IP (tos 0x0, ttl 64, id 10199, offset 0, flags [DF], proto: TCP (6), length: 52) 192.168.101.104.33631 > 192.168.100.253.80: ., cksum 0x33e4 (correct), ack 2897 win 5816 <nop,nop,timestamp 6479208 266452596>
19:34:15.597558 IP (tos 0x0, ttl 64, id 10200, offset 0, flags [DF], proto: TCP (6), length: 52) 192.168.101.104.33631 > 192.168.100.253.80: ., cksum 0x2894 (correct), ack 4345 win 7264 <nop,nop,timestamp 6479208 266452596>
19:34:15.598307 IP (tos 0x0, ttl 64, id 10201, offset 0, flags [DF], proto: TCP (6), length: 52) 192.168.101.104.33631 > 192.168.100.253.80: F, cksum 0x1e90 (correct), 126:126(0) ack 5459 win 8712 <nop,nop,timestamp 6479209 266452596>
19:34:15.598335 IP (tos 0x0, ttl 64, id 30715, offset 0, flags [DF], proto: TCP (6), length: 52) 192.168.100.253.80 > 192.168.101.104.33631: ., cksum 0x4060 (correct), ack 127 win 46 <nop,nop,timestamp 266452606 6479209>
19:34:19.805698 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto: UDP (17), length: 292) 192.168.101.254.500 > 192.168.101.104.500: isakmp 1.0 msgid 00000000: phase 1 R ident: [|ke]
19:34:19.911801 IP (tos 0xc0, ttl 64, id 15633, offset 0, flags [none], proto: ICMP (1), length: 320) 192.168.101.104 > 192.168.101.254: ICMP 192.168.101.104 udp port 500 unreachable, length 300
IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto: UDP (17), length: 292) 192.168.101.254.500 > 192.168.101.104.500: [|isakmp][|icmp]
19:34:20.665314 IP (tos 0x0, ttl 64, id 54000, offset 0, flags [DF], proto: UDP (17), length: 97) 192.168.101.104.45773 > 192.168.101.254.1701: l2tp:[TLS](0/0)Ns=0,Nr=0 *MSGTYPE(SCCRQ) *PROTO_VER(1.0) *HOST_NAME(anonymous) *FRAMING_CAP(AS) |...
19:34:22.665284 IP (tos 0x0, ttl 64, id 54001, offset 0, flags [DF], proto: UDP (17), length: 97) 192.168.101.104.45773 > 192.168.101.254.1701: l2tp:[TLS](0/0)Ns=0,Nr=0 *MSGTYPE(SCCRQ) *PROTO_VER(1.0) *HOST_NAME(anonymous) *FRAMING_CAP(AS) |...
]]></script><br />
<br />
I think that's why you get all that l2tp traffic on the loose where it isn't supposed to be. I abandon all hope it maybe an openswan | NETKEY issue on CENTOS 5.2.<br />
<br />
I will instead go for the OpenVpn solution which I am already using for my net.Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-68388476638297386062010-10-17T15:56:00.000+03:002010-10-17T15:56:14.822+03:00Prepare HylaFax for email to fax gateway with qmailSo this took me some time (mainly because I forgot all about qmail configuration), hence I thought to make a note. <br />
<br />
We will use virtual domains in qmail to send faxes with Hylafax.<br />
<br />
The default in the hylafax supplied script is to use a 'fax' top level name and send emails of the form <i>user</i>@<i>number</i>.fax. I prefer to use fax.mydomain.com instead. To accomplish this:<br />
<br />
1)Add to (or create) /var/qmail/control/virtualdomains the line:<br />
<b>.fax.mydomain.com:fax</b><br />
<br />
Be careful to include the dot in front of the domain. It simply means that we're catching anything below it. <br />
<br />
2)Add to /var/qmail/control/rcpthosts:<br />
<b>.fax.mydomain.com</b><br />
<br />
Which means that anything below the domain will be served locally.<br />
<br />
3)Create /var/qmail/alias/.qmail-fax-default and add:<br />
<b>| /usr/local/bin/mailfax</b><br />
<br />
4)Copy from hylafax-source-dir/faxmail/mailfax.sh-qmail to /usr/local/bin/mailfax<br />
If you cannot find it, create it empty and read on.<br />
<br />
5) Edit /usr/local/bin/mailfax as:<br />
<script type="syntaxhighlighter" class="brush: bash"><![CDATA[
#!/bin/sh
#
# mailfax - email to fax gateway for qmail.
#
# This file should be installed as /local/etc/mailfax, and the
# following changes made to the qmail configuration:
#
# Add the following to /var/qmail/control/virtualdomains
# .fax:fax
#
# Add the following to /var/qmail/alias/.qmail-fax-default
# | /local/etc/mailfax
#
#roeften edit: altered the script to support user@number.fax.domain.com
# relative files in /var/qmail/control/: virtualdomains and rctphosts
#removes all `
TMPVAR=${SENDER//\`/}
#removes all $(
TMPVAR=${TMPVAR//\$\(/}
#removes all )
SENDER=${TMPVAR//\)/}
/usr/bin/faxmail | /usr/bin/sendfax \
-f "$SENDER" \
-d "$EXT2@`/usr/bin/expr \"$HOST\" : '\(.*\)\.fax.*$'`"
]]></script><br />
<br />
My edits are simply fixing location errors for redhat flavors and add support for emails in the form recipientuser@faxnumber.fax.mydomain.com<br />
<br />
6) Do not forget to send a HUP to qmain-send.Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0tag:blogger.com,1999:blog-5606554702970304361.post-17560144420126333682010-10-17T01:45:00.000+03:002014-09-22T13:31:55.315+03:00Converting text files to fax fails - Hylafax, Ghostscript, FC10<div dir="ltr" style="text-align: left;" trbidi="on">
I have been trying to solve the infamous error:<br />
<br />
/usr/sbin/textfmt: No font metric information found for "Courier-Bold"<br />
<br />
when running sendfax to test asterisk + hylafax.<br />
<br />
This is a bug in ghostscript-8.70-1 & fonts for Fedora Core 10. So if you are not using FC10 this may not be the answer you 're looking for.<br />
<br />
To fix the error:<br />
<br />
1) Download & extract latest ghostscript-fonts http://sourceforge.net/projects/gs-fonts/<br />
2) View the fonts.dir file and locate the file name of the font you wish to use for Courier-Bold, I chose n022004l.pfb <br />
3) Copy n022004l.* (2 files) to /usr/share/fonts/default/ghostscript/<br />
4) Edit /usr/share/ghostscript/8.70/Resource/Init/Fontmap.GS and change:<br />
<br />
/Courier-Bold /NimbusMonL-Bold ;<br />
<br />
to:<br />
<br />
/Courier-Bold (n022004l.pfa) ;<br />
<br />
Try it now and it should work.<br />
<br />
Of course this is just one of many solutions, the main point being that NimbusMonL-Bold cannot be found and causing the issue.</div>
Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com2tag:blogger.com,1999:blog-5606554702970304361.post-74825140134999265582010-03-02T14:38:00.006+02:002010-03-02T15:07:18.253+02:00Getting AOC-E to work in Asterisk 1.6This is my approach to get AOC-E to work under asterisk. <br />
<br />
The problem is when then non AOC receiving channel hangs up first. The call is destroyed, thus when AOC-E is received it cannot be saved. <br />
<br />
A fast solution is to use the manager API and generate events for these situations.<br />
<br />
<i>This is the diff for chan dahdi</i><br />
<br />
<script type="syntaxhighlighter" class="brush: c"><![CDATA[
diff -b /usr/local/src/asterisk-1.6.1.9/channels/chan_dahdi.c /usr/local/src/asterisk-1.6.1.9-aocm/channels/chan_dahdi.c
11765c11765
< if (e->hangup.aoc_units > -1)
---
> if (e->hangup.aoc_units > -1) {
11768a11769,11788
>
> if (pri->pvts[chanpos]->owner) { // this never happens
>
> c = ast_bridged_channel(pri->pvts[chanpos]->owner);
> if(c) {
> char aoc_str[10];
> snprintf(aoc_str, sizeof(aoc_str), "%d", (int) e->hangup.aoc_units);
> ast_mutex_unlock(&pri->pvts[chanpos]->lock);
> pbx_builtin_setvar_helper(c, "AOCE_UNITS", aoc_str);
> ast_mutex_lock(&pri->pvts[chanpos]->lock);
> }
> } else {
> // log with manager
> ast_mutex_unlock(&pri->pvts[chanpos]->lock);
> manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: AOCE\r\nUnits: %d\r\nChannel: %d/%d/%d\r\n",
> (int)e->hangup.aoc_units,pri->span,pri->pvts[chanpos]->logicalspan,pri->pvts[chanpos]->prioffset);
> ast_mutex_lock(&pri->pvts[chanpos]->lock);
> }
> }
11823a11844
>
11834a11856,11867
> if(pri->pvts[chanpos]->owner && e->hangup.aoc_units > -1) {
>
> c = ast_bridged_channel(pri->pvts[chanpos]->owner);
> if(c) {
> char aoc_str[10];
> snprintf(aoc_str, sizeof(aoc_str), "%d", (int) e->hangup.aoc_units);
> ast_mutex_unlock(&pri->pvts[chanpos]->lock);
> pbx_builtin_setvar_helper(c, "AOCE_UNITS", aoc_str);
> ast_mutex_lock(&pri->pvts[chanpos]->lock);
> }
> }
]]></script><br />
<br />
Make sure you save the AOC in your cdr in the cases that is retrieved when call is still there, in your outgoing context you should have something like:<br />
<b>Set(CDR(units)=${AOCE_UNITS});</b><br />
<br />
Now for the other scenario you should have a manager listening to CDR AOC events (user events really). Using the span/logical/offset you can associate the AOC info to a call on your CDR. I am doing this manually having associations in the database like channel DAHDI/100 is at 5/0/1. Then simply finding the last outgoing call which involved that channel and updating the AOC does the trick.<br />
<br />
Lastly note that this can be as precise as it looks. When matching the AOC information to a call's cdr outside asterisk there is always a chance of failing to find the correct one. In my manager app I am taking extra steps to avoid miss-associations using a rate estimator and the disposition of the call. Although it is working perfectly until now, I will need to work a bit more on it before releasing it..<br />
<br />
Finally... If you are using B410P make absolutely sure you apply <a href="https://issues.asterisk.org/view.php?id=16048">this patch</a> otherwise you will loose calls and the changes will not have any effect under certain circumstances.Panoshttp://www.blogger.com/profile/17092487368034284293noreply@blogger.com0