LD_LIBRARY_PATH annoyances

Hey, mais on n’a pas besoin de ld_library_path ?

pourtant j’avais codé un élégant script :

#reorder front path items matching ie(PATH,/opt:/usr:/sbin:/bin) R_PATH

reorderpath()
{
A_PATH=$1
P_BEFORES=$2
A_PATH=`echo "$A_PATH"|sed -e 's/::/:/g' -e 's/^://' -e 's/:$//'`
if [ "$A_PATH" = "" ];then return;fi
if [ "$P_BEFORES" = "" ];then return;fi
for P_BEFORE in `echo $P_BEFORES|sed -e 's/:/ /g'`;do
R_PATH=""
for I_PATH in `echo $A_PATH|sed -e 's/:/ /g'`;do
J_PATH=`echo $I_PATH|sed -e "s:^$P_BEFORE::"`
if [ "$I_PATH" = "$J_PATH" ];then
R_PATH="$R_PATH:$I_PATH"
else
R_PATH="$I_PATH:$R_PATH"
fi
done
R_PATH=`echo "$R_PATH"|sed -e 's/::/:/g' -e 's/^://' -e 's/:$//'`
A_PATH=$R_PATH
done
}

mais sur AIX, impossible de concilier chef-solo et rpm

reorderpath $LD_LIBRARY_PATH /usr:/lib:/opt/freeware

ça met rpm en premier, rpm marche, mais pas chef-solo qui prend les libs (zlib) de /lib au lieu de /opt/chef/embedded ;

vice versa, rpm a besoin des libs zlib de /lib ;

et comme rpm est lancé par chef, ils devraient partager le même LD_LIBRARY_PATH.

je croyais ça insolube, eh ben non :

dans les fichiers compilés, il y a en dur la localisation de la lib.

Why LD_LIBRARY_PATH is bad says :

  1. Never ever set LD_LIBRARY_PATH globally.
  2. If you must ship binaries that use shared libraries and want to allow your clients to install the program outside a ‘standard’ location, do one of the following:
    • Ship your binaries as .o files, and as part of the install process relink them with the correct installation library path. (like oracle..)
    • Ship executables with a very long “dummy” run-time library path, and as part of the install process use a binary editor to substitute the correct install library path in the executable. (whaou, hacky!+1!)
  3. If you are forced to set LD_LIBRARY_PATH, do so only as part of a wrapper.

 

so (redhat/solaris/aix):

unset LD_LIBRARY_PATH LD_RUN_PATH LIBPATH

 

mysql replication repairing script

mysql replication repairing script

Ah je ne vous ai pas montré le script pour réparer ma réplication mysql  :
à lancer sur le backup qui a foiré.
* copie fichier de la base à froid
* on trouve à quel redo/pos on peut reprendre (c’est là l’astuce)
* après y a plus qu’à refaire la conf de réplication

#####my_repl_bk2rp.sh
 
#!/bin/sh
echo "quand la repl. foire, faire repartir de zero"
echo "copie le bk vers la replication, ok?"
read "ok"
 
/etc/init.d/mysqld stop
 
#merci à www.rsnapshot.org génial
rsync -e ssh -va --delete serveurdesauvegarde:/backup/hourly.0/mysql /home/
#replay, just to be sure...
rsync -e ssh -va --delete serveurdesauvegarde:/backup/hourly.0/mysql /home/
 
/etc/init.d/mysqld start
 
cd /repertoire/mysql
 
lastredo=$(tail -n 1 redo*.index|sed -e 's:^.*/::')
 
lastredopos=$(mysqlbinlog $lastredo|grep end_log_pos|tail -n 1|sed -e 's/^.*end_log_pos *//' -e 's/ .*$//')
 
mysql -pmotdepasseenclair <
CHANGE MASTER TO \
MASTER_HOST='masterserver', \
MASTER_USER='slave', \
MASTER_PASSWORD='passduuserslave', \
MASTER_LOG_FILE='$lastredo', \
MASTER_LOG_POS=$lastredopos;
START SLAVE;
EOT
 
tail /var/log/mysqld.log
sleep 1
echo "my_repl_check.sh"
mysql -u root -pmotdepasse <
 
show slave hosts \G;
show slave status \G;
show master status \G;
EOT

et ça marche !!
quand on perd la réplication, on galère pour retrouver comment on fait pour la rebrancher,
surtout avec le stress, t le risque de perdre encore plus. pff. chouette script, merci moi-même.

désaccentuation

désaccentuation

J’oubliais, ce petit script pour “désaccentuer” du texte : utiliser entity_decode,
puisque é s’écrit &+e+acute; on peut récupérer le ‘e’ après le & :
function f_desaccentuation($v_str)

{
//htmlentities pour les accents !: référence devient reference
$str=f_str2utf8($v_str);
$str=f_str2iso(html_entity_decode($str,ENT_NOQUOTES,”UTF-8″));
$str=preg_replace(“/[\xa0-\xbf\xd7\xf7]/”,” “,$str);
$str=htmlentities(f_str2utf8($str),ENT_NOQUOTES,”UTF-8″);
$str=str_replace(” “,” “,$str);
$str=str_replace(“<“,”<“,$str);
$str=str_replace(“>”,”>”,$str);
$str=str_replace(“&”,”&”,$str);
$str=str_replace(“””,'”‘,$str);
$str=str_replace(“‘”,”‘”,$str);
return(preg_replace(“/\&(.)[^\;]*\;/”,”$1″,$str));
}

pas de table de conversion 🙂

stty: standard input: Inappropriate ioctl for device

stty: standard input: Inappropriate ioctl for device

“stty: standard input: Inappropriate ioctl for device”
est un message systeme sur les redhat 6,
du (dans mon cas) à des combinaisons de su et &
j’ai réduit le test au minimum :

echo “su  root -c ‘ls &’ ”  >  /tmp/a ; sh /tmp/a

modif : dans /etc/sudoers,
changer
Defaults    requiretty

par
Defaults    !requiretty
(ou par utilisateur..)

half-em and dash in Word : why copy paste command line from MS-WORD with dashes fail

half-em and dash in Word : why copy paste command line from MS-WORD with dashes fail

Word evolves , it replaces dash  by typographic characters the picky way. so dashes.
I was copy pasting from word and bang! :
# keytool -list –v -keystore tomcat.jks
Unrecognized command: –v
it is hidden to non hexadecimal reader
[root@h0l1ice11t conf]# echo "keytool -list –v ..."|od -cx
0000000 k e y t o o l   - l i s t   342 200 
      656b 7479 6f6f 206c 6c2d 7369 2074 80e2
0000020 223 v  
      7693 
fiiiix it …..
* in word, deactivate any automatism
menu file / option / verification / option auto-correction ….
uncheck outrageously
* and now replace – by – [sic]there is an option to type “half-em-dash”
the option : “Plus>>” “special” “half-em-dash”
conclusion : use MD (markdown), not MS

poor man’s dyndns

poor man’s dyndns

As many, I committed a low cost dyndns ;

hourly, I call a server’s url. if the server notices a change, it updates a DNS zone :
root@clic12:/etc/cron.hourly# cat wgk
#!/bin/sh
IP=`ifconfig -a|grep 192|head -n 1|sed -e 's/  */|/g'|cut -d\| -f3`
URL="http://www.yoursite.net/zone.php"
wget -o /dev/null -O /dev/null "$URL" 2>&1 >/dev/null
wget -o /dev/null -O /dev/null "$URL?n=guy&ip=$IP" 2>&1 >/dev/null
and the php side (can manage many dyndnses):
//print_r($_SERVER);
 
$n=preg_replace("/[^a-z]/","",$_REQUEST["n"]);
if ($n)
 foreach(explode("\n",file_get_contents("zone.txt")) as $l)
   if (preg_match("/ $n /",$l)) $m=preg_replace("/^.* $n /","",$l);
if ($_REQUEST["a"]) die(file_get_contents("zone.txt"));
if ($_REQUEST["d"])
        die("ok".file_put_contents("zone.txt",strftime("%D %T reset
\n")));
if (!$n) die("list,reset");
$q=strftime("%D %T $n ".$_REQUEST["ip"]." ".$_SERVER["REMOTE_ADDR"]."
");
file_put_contents("zone.txt",$q."\n",FILE_APPEND);
$q=preg_replace("/^.* $n /","",$q);
if ($q == $m) die("ok same ip");
file_put_contents("zone.txt","***********NEWIP*******\n".$q."\n",FILE_APPEND);
if ($n=="guy")
        passthru("sudo /root/scripts/named_dyndns.sh yoursite.net adsl ".$_SERVER["REMOTE_ADDR"]);
?>.
and named_dyndns.sh + domain + subdomain + ip
#!/bin/sh
domain=$1
key=$2
ip=$3
if [ "$ip" = "" ];then echo "$0 domain key ip";exit;fi
dmx=/var/named/chroot//etc/named.xtra
sed -i $dmx -e "s/^$domain:$key IN A .*$/$domain:$key IN A $ip/"
/root/bin/named_make_domxtra2zon.pl $domain
after, this is your own domain/named/zone system,
that recreates a zonefile and reload named