RIGO.INFO TechBlog

Eventually I get into producing something I think is useful for others. You'll find random technical knowledge in this Blog so please be patient and use the search function. Some of these software are rather lame and old, the list is ordered by the approximate age (newest first). Unfortunately my older stuff are lost or scattered around my old CDs, not readable anymore 8(.

Proxy local mysql socket over the network

As an user of OpenVZ it's often my task to migrate database driven web applications to separate environments. In recent versions of OpenVZ, bind mounting of sockets between virtual environments is prohibited. I had to find a way to proxy local connections to /var/run/mysqld/mysqld.sock to the remote mysql server.

First I've created a mysql user and group:

addgroup --system mysql
adduser --system --home /var/run/mysqld --ingroup mysql mysql

Then I've installed and configured the excellent socat utility using launchtool.

db.vz is the address remote database host in the following executable launchtool configuration script

#!/usr/bin/launchtool -C
tag = mysql-proxy
daemon = yes
user = mysql
command = socat UNIX-LISTEN:/var/run/mysqld/mysqld.sock,fork,mode=0666 TCP:db.vz:3306,forever
start dir = /var/run/mysqld
wait times = 5
infinite runs = yes
stats = yes
launchtool output = syslog:mysql-proxy,LOG_DAEMON,LOG_INFO
launchtool errors = syslog:mysql-proxy,LOG_DAEMON,LOG_ERR
command output = syslog:mysql-proxy,LOG_DAEMON,LOG_INFO
command errors = syslog:mysql-proxy,LOG_DAEMON,LOG_ERR

Update: this method seems reliable but rather slow when an application continously creates lots of connections - like does PHP

2011-07-15 18:52 · 0 Linkbacks

MySQL dump to tables

A very small GAWK script that splits a mysql text dump to separate table dump files.

#!/bin/sh
# GPLv2 by Erno Rigo <mcree_AT_tricon_DOT_hu>
 
gawk '
 BEGIN { FS=" "; dest="/dev/null" }
 /^(USE)/ { dir=gensub(";","","g",$2) ; dir=gensub("`","","g",dir) ; system("mkdir "dir) }
 /^(CREATE|USE|DROP)/ { fflush(dest); dest="/dev/null" }
 /^CREATE TABLE/ { file=gensub("`","","g",$3) ; fflush(dest); dest=dir"/"file".sql" }
 { print >> dest }
'
2011-07-15 18:52 · 0 Linkbacks

muddleftpd-scripting

MuddleFTPD scripting patch - This is a diff patch for muddleftpd to allow running of external scripts upon ftp events such as finished uploads. The patch has a race condition which has not been fixed. The patch was dropped by the muddleftpd team because it executes external commands (why… that's its purpose anyway). Now I recommend you to use proftpd or pure-ftpd instead…

2011-07-15 18:52 · 0 Linkbacks

freemail

freemail.zip - My old contribution to the web IMAP email gateway scene. Written in an early version of PHP in 2001 and it's still in use somewhere (I won't tell you: use google…).

2011-07-15 18:52 · 0 Linkbacks

Un-accenting text

This PHP code snippet is userful in removing accents from international (latin), especially hungarian texts.

<?PHP
 
function unaccent($txt) {
 
  return strtr(recode("utf8..l1",strtr($txt,"őŐűŰ","oOuU")),
  "\xe1\xc1\xe0\xc0\xe2\xc2\xe4\xc4\xe3\xc3\xe5\xc5".
  "\xaa\xe7\xc7\xe9\xc9\xe8\xc8\xea\xca\xeb\xcb\xed".
  "\xcd\xec\xcc\xee\xce\xef\xcf\xf1\xd1\xf3\xd3\xf2".
  "\xd2\xf4\xd4\xf6\xd6\xf5\xd5\x8\xd8\xba\xf0\xfa\xda".
  "\xf9\xd9\xfb\xdb\xfc\xdc\xfd\xdd\xff\xe6\xc6\xdf\xf8"."őŐűŰ",
  "aAaAaAaAaAaAacCeEeEeEeEiIiIiIiInNo".
  "OoOoOoOoOoOoouUuUuUuUyYyaAso"."oOuU");
 
}
 
function doit($dir) {
  foreach(glob($dir."/*") as $entry) {
    echo $entry." => ".unaccent($entry)."\n";
    rename($entry,unaccent($entry));
    if(is_dir($entry)) doit($entry);
  }
}
 
doit(".");
 
?>
2011-07-15 18:52 · 0 Linkbacks

Linkbacks

Use the following URL for manually sending trackbacks: https://rigo.info/lib/plugins/linkback/exe/trackback.php/en:blog
en/blog.txt · Utolsó módosítás: 2009-05-15 00:00 (külső szerkesztés)
CC Attribution-Noncommercial-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0