Kategori Sprachen

Sporadische Seitenladefehler durch Segmentation fault

Dienstag, Februar 21st, 2012

Vergangene Woche war meine Blog immer wieder von ausfällen geplagt. Das komische war das es immer wieder in der gleichen WordPress Funktion call_user_func_array auftauchte.
Bei Debuggen verschob sich aber immer wieder der Ort wo der Fehler auftrat, ähnlich der Heisenbergsche Unschärferelation. Zudem trat der Fehler nur bei jedem vierten seiten Aufruf auf.

[notice] child pid 29729 exit signal Segmentation fault (11)
[notice] child pid 29856 exit signal Segmentation fault (11)
[notice] child pid 29888 exit signal Segmentation fault (11)

Im Endeffekt habe ich jetzt erst mal PHP und Apache ohne -threads* kompeliert.

tail -F color

Mittwoch, Februar 1st, 2012

Heute musste ich den ganzen Tag ein Logfile überwachen. Damit das nicht zu anstrengend wird und man Fehler nicht übersieht, habe ich das Logfile einfach eingefärbt.

tail -F file.log | awk '
/FATAL/ {print "\033[31m" $0 "\033[39m"}
/WARN/ {print "\033[33m" $0 "\033[39m"}
/INFO/ {print "\033[32m" $0 "\033[39m"}
'

Wir lernen Python Teil 1

Freitag, Juli 29th, 2011


$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 0 == None
False
>>> int(None)
Traceback (most recent call last):
File "", line 1, in
TypeError: int() argument must be a string or a number, not 'NoneType'
>>> bool(None)
False
>>> bool(0)
False
>>> bool(1)
True
>>> if None:
... print "is nicht"
...
>>>
>>> if 1:
... print "is nicht"
...
is nicht
>>> if "test" == "test2":
... print "nö"
...
>>> if "test" == "test":
... print "nö"
...

>>> if "test" != "test":
... print "nö"
...
>>> for i in range(0,101)
File "", line 1
for i in range(0,101)
^
SyntaxError: invalid syntax
>>> for i in range(0,101):
... print i,
...
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
>>> range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> g = [7, 90, 23]
>>> for i in g:
... print i,
...
7 90 23
>>> for i in g:
... print i
...
7
90
23
>>> j = {"red": "#f00", "blue": "#00f"}
>>> for i in j:
... print i
...
blue
red
>>> for i in j.items():
... print i
...
('blue', '#00f')
('red', '#f00')
>>> for k,v in j.items():
... print "%s=>%s" % (k,v)
...
blue=>#00f
red=>#f00
>>> for k,v in j.items():
... print k,v
...
blue #00f
red #f00
>>> for k,v in j.items():
... print k + v
...
blue#00f
red#f00
>>> r, d = (9, 90)
>>> r
9
>>>
>>> d
90
>>> r+d
99
>>> for i in range(0,101)
File "", line 1
for i in range(0,101)
^
SyntaxError: invalid syntax
>>> for i in range(0,101):
... print i, i+i
...
0 0
1 2
2 4
3 6
4 8
5 10
6 12
7 14
8 16
9 18
10 20
11 22
12 24
13 26
14 28
15 30
16 32
17 34
18 36
19 38
20 40
21 42
22 44
23 46
24 48
25 50
26 52
27 54
28 56
29 58
30 60
31 62
32 64
33 66
34 68
35 70
36 72
37 74
38 76
39 78
40 80
41 82
42 84
43 86
44 88
45 90
46 92
47 94
48 96
49 98
50 100
51 102
52 104
53 106
54 108
55 110
56 112
57 114
58 116
59 118
60 120
61 122
62 124
63 126
64 128
65 130
66 132
67 134
68 136
69 138
70 140
71 142
72 144
73 146
74 148
75 150
76 152
77 154
78 156
79 158
80 160
81 162
82 164
83 166
84 168
85 170
86 172
87 174
88 176
89 178
90 180
91 182
92 184
93 186
94 188
95 190
96 192
97 194
98 196
99 198
100 200
>>>
>>>
>>> "abc".len()
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'str' object has no attribute 'len'
>>> dir("abc")
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>> "abc".replace("a","b")
'bbc'
>>> dir(0)
['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__format__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__', '__index__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'conjugate', 'denominator', 'imag', 'numerator', 'real']
>>> 0.__type__
File "", line 1
0.__type__
^
SyntaxError: invalid syntax
>>> 0.__class__
File "", line 1
0.__class__
^
SyntaxError: invalid syntax
>>> (0).__class__

>>> (0).__sub__(10)
-10
>>> class Foo(object):
... def __sub__(self, other):
... print "minus", other, "und so"
...
>>> foo = Foo()
>>> foo - 10
minus 10 und so
>>> foo.__sub__(10)
minus 10 und so
>>> class Foo(object):
... def __sub__(self, other):
... print "minus", other, "und so"
... def test(self, blub):
... print "arrghhh", blub
...
>>> foo = Foo()
>>> foo.test(56)
arrghhh 56
>>> foo.test(foo)
arrghhh <__main__.Foo object at 0x7f9bec5e8390>
>>> foo.test
>
>>> u =foo.test
>>> u(78)
arrghhh 78
>>> u.__type__
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'function' object has no attribute '__type__'
>>> u.__class__

>>> Foo.test.__class__

>>>
>>>
>>>
>>> import datetime
>>> datetime

>>> datetime.date

>>> datetime.date.day

>>> d =datetime.date()
Traceback (most recent call last):
File "", line 1, in
TypeError: Required argument 'year' (pos 1) not found
>>> datetime.date.today

>>> datetime.date.today.()
File "", line 1
datetime.date.today.()
^
SyntaxError: invalid syntax
>>> datetime.date.today()
datetime.date(2011, 7, 29)
>>> from datetime import *
>>> date.today()
datetime.date(2011, 7, 29)
>>> from sys import stdout
>>> stdout
', mode 'w' at 0x7f9bec67b150>
>>> stdout.write("dooh")
dooh>>>
>>>
>>> from sys import stdout as ooo
>>> ooo.write("dooh")
doohimport datetime as d
>>> d.date.today()
datetime.date(2011, 7, 29)
>>> d = d.date.today()
>>> dir(d)
['__add__', '__class__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__radd__', '__reduce__', '__reduce_ex__', '__repr__', '__rsub__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', 'ctime', 'day', 'fromordinal', 'fromtimestamp', 'isocalendar', 'isoformat', 'isoweekday', 'max', 'min', 'month', 'replace', 'resolution', 'strftime', 'timetuple', 'today', 'toordinal', 'weekday', 'year']
>>> d.dsay
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'datetime.date' object has no attribute 'dsay'
>>> d.day
29
>>> repr

>>> repr(d)
'datetime.date(2011, 7, 29)'
>>> str(d)
'2011-07-29'
>>> d.__str__()
'2011-07-29'
>>> d.__repr__()
'datetime.date(2011, 7, 29)'
>>> d1 = d+1
Traceback (most recent call last):
File "", line 1, in
TypeError: unsupported operand type(s) for +: 'datetime.date' and 'int'
>>> d1 = d+ datetime.timedelta(1)
Traceback (most recent call last):
File "", line 1, in
AttributeError: type object 'datetime.datetime' has no attribute 'timedelta'
>>> datetime

>>> import datetime
>>> datetime

>>> d1 = d+ datetime.timedelta(1)
>>> d1
datetime.date(2011, 7, 30)
>>> d1 = d + datetime.timedelta(1,12)
>>> d1
datetime.date(2011, 7, 30)
>>> d1 = d + datetime.timedelta(1,12) + datetime.timedelta(1,12)
>>> d1
datetime.date(2011, 7, 31)
>>> d1 = d + datetime.timedelta(1,12) + datetime.timedelta(0,12)
>>> d1
datetime.date(2011, 7, 30)
>>> d = datetime.date.today()
>>> d
datetime.date(2011, 7, 29)
>>> d = datetime.datetime.today()
>>> d
datetime.datetime(2011, 7, 29, 10, 6, 29, 522852)
>>> d1 = d + datetime.timedelta(1,12) + datetime.timedelta(0,12)
>>> d1
datetime.datetime(2011, 7, 30, 10, 6, 53, 522852)
>>> d1 = d + datetime.timedelta(1,12)
>>> d1
datetime.datetime(2011, 7, 30, 10, 6, 41, 522852)
>>> d1 = d + datetime.timedelta(1, hours=12)
>>> d1
datetime.datetime(2011, 7, 30, 22, 6, 29, 522852)
>>> d1 = d + datetime.timedelta(days=1, hours=12)
>>> d - d1
datetime.timedelta(-2, 43200)
>>> d1 - d
datetime.timedelta(1, 43200)
>>> "test" != "test""test" != "test""test" != "test"
False
>>>
>>>
>>>
>>> if 1 or function() :
...
File "", line 2

^
IndentationError: expected an indented block
>>> 1 or 0
1
>>>
>>> 1 or stdout.write("ya")
1
>>> 0 or stdout.write("ya")
ya>>>
>>>
>>>
>>> 3 / 2
1
>>> 3. / 2
1.5
>>> 3 / 2.
1.5
>>> import division from __future__
File "", line 1
import division from __future__
^
SyntaxError: invalid syntax
>>> from __future__ import division
>>>
>>>
>>>
>>> 3 / 2
1.5
>>> 3 // 2
1
>>> 3 / 2
1.5
>>> 3 // 2
1
>>> 3.0 // 2
1.0
>>> 3. // 2
1.0
>>> 3.1 // 2
1.0
>>> 1+2
3
>>> 1+2.0
3.0
>>> i=1+2.0
>>> i
3.0
>>> int(i)
3
>>> str(i)
'3.0'
>>> "tt" + i
Traceback (most recent call last):
File "", line 1, in
TypeError: cannot concatenate 'str' and 'float' objects
>>> "tt"+"i"
'tti'
>>> str(i) + "tt"
'3.0tt'
>>> "t" * 40
'tttttttttttttttttttttttttttttttttttttttt'
>>> ", ".join(["red", "blue", "zoo"])
'red, blue, zoo'
>>> "- ".join(["red", "blue", "zoo"])
'red- blue- zoo'
>>> "".join(["red", "blue", "zoo"])
'redbluezoo'
>>> ", ".join(["red", "blue", "zoo"]).split(", ")
['red', 'blue', 'zoo']
>>> ["red", "blue", "zoo"]
['red', 'blue', 'zoo']
>>> [i[0], i in ["red", "blue", "zoo"]]
Traceback (most recent call last):
File "", line 1, in
TypeError: 'float' object is unsubscriptable
>>> [i[0] where i in ["red", "blue", "zoo"]]
File "", line 1
[i[0] where i in ["red", "blue", "zoo"]]
^
SyntaxError: invalid syntax
>>> [i[0] for i in ["red", "blue", "zoo"]]
['r', 'b', 'z']
>>> [i[0] for i in ["red", "blue", "zoo"]]
['r', 'b', 'z']
>>> "".join([i[0] for i in ["red", "blue", "zoo"]])
'rbz'
>>> [i[0] for i in ["red", "blue", "zoo"]]
['r', 'b', 'z']
>>> map( lambda i: i[0],["red", "blue", "zoo"])
['r', 'b', 'z']
>>> lambda i: i[0]
at 0x7f9bec5ea848>
>>> f = lambda i: i[0]
>>> f("abc")
'a'
>>> def f(i):
... return i[0]
...
>>> f("abc")
'a'
>>> map( f,["red", "blue", "zoo"])
['r', 'b', 'z']
>>> f

>>> del f
>>> f
Traceback (most recent call last):
File "", line 1, in
NameError: name 'f' is not defined
>>> c = [0]
>>> c[0] = 5
>>> c
[5]
>>> d = c
>>> del c
>>> d
[5]
>>> c = [0]
>>> d = c
>>> d is c
True
>>> d is [0]
False
>>> d = [0]
>>> c == d
True
>>> c is d
False
>>> c[0] = 5
>>> c == d
False
>>> c is d
False
>>> # hjhj
...
>>> """sdfsdfs
... sdfsdf
... sdfsdfsd
... """
'sdfsdfs\nsdfsdf\nsdfsdfsd\n'
>>> help
Type help() for interactive help, or help(object) for help about object.
>>> help(map)

>>> def h():
... """hier ist die hilfe"""
... return 0
...
>>> h()
0
>>> help(h)

>>> "ttt
File "", line 1
"ttt
^
SyntaxError: EOL while scanning string literal
>>> print < File "", line 1
print < ^
SyntaxError: invalid syntax
>>>

Leerzeichen im Pfad

Mittwoch, Juli 20th, 2011

Wenn man Dateien mit Leerzeichen in eine Variabel einlesen möchte braucht man ls -b und read -r

ls -b > .tmp
while read -r datei; do
        echo $datei
done < .tmp

rionice

Mittwoch, Juni 15th, 2011

Um rekursiv ionice zu vererben haben wir mal eben ein rionice geschrieben.

#!/bin/bash
 
ionice -c 3 -p $(pstree -p $1 | tr "(" "\n" | cut -d ")" -f 1 | egrep "^[0-9]+\$")
 
exit 0

Um es aufzurufen muss man die PID des Mutterprozesses rionice übergeben. Dies macht man am besten mit ps -xf. Dann übergibt man rionice 1234.

upstart und die fehlende bash tab completion

Montag, Mai 16th, 2011

Was mich an meisten an upsatart, abgesehen davon das es schlecht zu Debuggen ist, gestört hat ist die fehlende bash tab completion.

Auf launchpad.net habe ich aber den passenden Burgreport gefunden und den dazugehörigen Patch, den man folgendermaßen verwenden kann:

sudo wget -O /etc/bash_completion.d/upstart https://launchpadlibrarian.net/40624366/upstart

(weiterlesen …)

imagemagick resizen script

Montag, April 11th, 2011

Da ich mit meiner neuen Kamera derzeit viele Fotos mit 18 Mega Pixeln mache, brauchte ich ein Batch Script das viele Bilder gleichzeitig resizen kann. So bin ich auf das Parkte imagemagick gestoßen.

Mein Script erstellt nun einen Ordner namens Web und erstellt in diesem verkleinerte Bilder mit maximal 800px Länge oder Breite.

#!/bin/bash
mkdir web
 
ls -1 *.JPG *.jpg | while read file;
do {
        echo $file
        convert $file -resize '800x800>' web/$file
}
done
 
exit 0
 

Mehr Infos: wiki.ubuntuusers.de

Langeweile vor der Shell

Samstag, April 2nd, 2011

Hier mal was gegen die Langeweile vor der Shell:
while true; do pwgen -ys $COLUMNS $(($RANDOM % 4 + 1)); sleep 0.2;done

RRD Graphen über SNMP erstellen

Sonntag, Januar 30th, 2011

Hier Dokumentire ich mal wie wir im Wohnheim den Cisco Catalist 4006 über SNMP abfragen um RRD Graphen zu erstellen. Zuerst muss man auf den Cisco natürlich SNMP einschalten und ein Passwort Sätzen.

snmp-server community password RO
snmp-server enable traps tty

Als erstes müssen vollende Pakete installiert werden:
apt-get install php-cli snmp rrdtool

Dann habe ich ein Script geschrieben das die insgesamt 195 Port abfragt.

 
#!/usr/bin/php5
<?
 
//CISCO
for($i=1;$i<=195;$i++)
{
// RRD ERSTELLEN
   //system("rrdtool create bandwidth-". $i .".rrd --start N DS:in:COUNTER:600:U:U
DS:out:COUNTER:600:U:U RRA:AVERAGE:0.5:1:432");
 
// RRD LOGGEN
  system("/usr/bin/rrdupdate /usr/local/rrd/bandwidth-". $i .".rrd N:
`/usr/bin/snmpget -v1 -c password 192.168.1.1 -Oqv IF-MIB::ifInOctets.". $i ."`:
`/usr/bin/snmpget -v1 -c password 192.168.1.1 -Oqv IF-MIB::ifOutOctets.". $i ."`");
 
// RRD GRAPH
  system("/usr/bin/rrdtool graph /usr/local/rrd/img/bandwidth-". $i .".png
-a PNG -w 500 -h 150 -M -s -129600 -v \
`/usr/bin/snmpget -v1 -c password 192.168.1.1 -Oqv IF-MIB::ifDescr.". $i ."` \
    'DEF:in=/usr/local/rrd/bandwidth-". $i .".rrd:in:AVERAGE' \
    'DEF:out=/usr/local/rrd/bandwidth-". $i .".rrd:out:AVERAGE' \
    'CDEF:kbin=in,1024,/' \
    'CDEF:kbout=out,1024,/' \
    'AREA:in#00FF00:Bandwidth In' \
    'LINE1:out#0000FF:Bandwidth Out\j' \
    'GPRINT:kbin:LAST:Last Bandwidth In\:    %3.2lf KBps' \
    'GPRINT:kbout:LAST:Last Bandwidth Out\:   %3.2lf KBps\j' \
    'GPRINT:kbin:AVERAGE:Average Bandwidth In\: %3.2lf KBps' \
    'GPRINT:kbout:AVERAGE:Average Bandwidth Out\:%3.2lf KBps\j'");
}
?>

Das ganze sieht dann so aus, hier ist der Aktelle Graph des Netzwerk Trafik des Wohnheims:
network traffic

sudo für www-data auf ein Programm

Freitag, Januar 28th, 2011

Um für die Internet freischalte Anwendung im Wohnheim dem Apache root Rechte auf ein Programm zu geben, gibt es die Möglichkeit dies mit sudo und nopassword zumachen. Dafür Edition man die /etc/sudoers mit visudo und ergänzt dies mit einer solchen Zeile:

www-data ALL=NOPASSWD:/usr/sbin/arp

So kann der Befehl

$mac = system('sudo arp -a '. $_SERVER['REMOTE_ADDR'] .' | cut -d " " -f4');

instent die MAC Adresse für die IP des Client Rechners ermitteln, obwohl root rechte zum ausführen einer arp anfrage benötige werden.

älter als löschen

Sonntag, Januar 23rd, 2011

Da ich auch hier nach jedes mal wieder suche hier für alle:
Diese Zeile löscht alle Dateien die Älter als 3 Tage sind.
find '/home/user/' -type f -mtime +3 -exec rm {} \;

cron und $var

Freitag, November 26th, 2010

Damit man die bash Umgebungsvariablen wie z.b.:

0 0 * * * /sbin/shutdown -r +$(($RANDOM \% 60))

in crontab nutzen kann, kann man nicht einfach bach "befelh" davor schreiben. Man muss erst die dash konfigurieren:

sudo dpkg-reconfigure dash

Quelle: Shiva6

MediaWiki LDAP benuzer

Freitag, November 19th, 2010

Bei der Installation eines MediaWikis mit LDAP Plugin als Benutzerauthentifizierung bin ich in folgende falle gelaufen. Trotz Debuggen "on" bekam ich nur Folgenden Fehler:

LoginForm::attemptAutoCreate: $wgAuth->authenticate() returned false, aborting

Zuerst mal sollte man überprüfen ob das PHP LDAP Modul aktiviert ist.

Dann müssen folgende Einstellungen in der LocalSettings.php eingetragen werden.

equire_once( "extensions/LdapAuthentication/LdapAuthentication.php" );
$wgAuth = new LdapAuthenticationPlugin();
 
$wgLDAPDomainNames = array( "blog.chr.istoph.de" );
$wgLDAPServerNames = array( "blog.chr.istoph.de" => "ldap.chr.istoph.de" );
$wgLDAPBaseDNs = array( "blog.chr.istoph.de"=>"dc=chr,dc=istoph,dc=de" );
$wgLDAPSearchAttributes = array( "blog.chr.istoph.de" => "uid" );
$wgLDAPSearchStrings = array( "blog.chr.istoph.de" => "uid=USER-NAME,ou=people,dc=chr,dc=istoph,dc=de" );

MySQL Unix Socket weiterleiten

Samstag, November 13th, 2010

Wenn man bei einer LAMP System den Datenbankserver auf eine extra Maschine legen muss, hat man dank PHP etwas Stress mit dem unterschied zwischen localhost und 127.0.0.1 bzw ::1. Das liegt daran der UNIX Socket bei mein match auf localhost fest einkompiliert ist.

Mit socat kann man den Unix Socket zum Glück umleiten:
socat UNIX-LISTEN:/var/lib/mysql/mysql.sock,fork,user=mysql,group=mysql,mode=777 TCP:localhost:3306 2> /dev/null &

Mit rinetd kann man diese dann auf eine IP Weiterleiten.

sun-java6-jdk unter Ubuntu 10.04 Lucid

Donnerstag, Oktober 14th, 2010
echo "deb http://archive.canonical.com/ubuntu lucid partner" | sudo tee /etc/apt/sources.list
sudo apt-get update
apt-get install sun-java6-jdk
 
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=$JAVA_HOME/bin:$PATH
 

Passwort setzen

Mittwoch, Oktober 6th, 2010

Hier habe ich ein Ausschnitt eins Skripts zum setzen eines User Passwortes. Zuerst erzeuge ich ein zufälliges 12 stelliges Passwort mit dem Programm pwgen dann verwende ich mit Hilfe von bash befehlen das Programm passwd um das Passwort zu setzen.

 
#!/bin/bash
PW=$(pwgen -1 12)
passwd user <<EOF
$PW
$PW
EOF
 

rumount

Dienstag, September 7th, 2010

Da es ja ein mount -r gibt habe ich mir mal ein rumount geschrieben.

./rumount pfad

 
#!/bin/bash
cat /proc/mounts | grep $1 | cut -d " " -f2 | tac | xargs -n1 umount
exit 0

mklvm.sh

Samstag, April 3rd, 2010

Zur Doku poste ich mal mein mklvm.sh Skript. Mit dem man Automacht neue LVs erstellen, formatieren und mounten kann.

Abzulegen ist das Skript in: /usr/local/sbin/mklvm.sh

#!/bin/bash
NAME=$1
VOLUMEN=$2
 
lvcreate -n $NAME -L $VOLUMEN vg # vg durch den Volumen Groupe Namen ersetzen!!!
mkfs -t ext3 /dev/$NAME
mkdir /mnt/$NAME
mount /dev/$NAME /mnt/$NAME
echo "/dev/$NAME           /mnt/$NAME         ext3    relatime,errors=remount-ro 0    0" >> /etc/fstab
mount -a
 
exit 0

Dann kann man mit folgenden Befehl LVs anlegen:
mklvm.sh neue_lv_name 25G

Importscript von Drupal nach WordPress

Samstag, März 6th, 2010

Endlich hat der AStA eine neue Webseite. Was auffällt ist vermutlich das Kopfzeilen Hintergründigbild das meinem vielleicht ein bisschen ähnelt. Die Jungs vom AStA haben beim anschauen meines Blogs ein bisschen inspirieren lassen. Toll an dem Bild, das ich von meinem Turm geschossen habe, ist nämlich das es die sich um die Sicht der ganzen FH-Aachen auf Aachen handelt, da alle Standorte sich hinter dem HBF befinden. Ich habe dafür einen Importscript von Drupal nach WordPress geschrieben. Wie immer habe ich es als PHP_CLI Anwendung auf der Konsole gemacht.

(weiterlesen …)

PHP: ldap_sort() case sensitivity

Freitag, November 6th, 2009

Irgend wie ist die PHP Funktion ldap_sort() gaggi, den sie sortiert case sensitivity erst alles was groß ist und dann alles was klein ist. Da das keinen Sinn mach habe ich das mal per Hand geschrieben:

foreach($result as $key => $value)
	if(is_int($key))
		$a[$key] = strtolower($value[GIVENNAME][0]);  //Order By
asort($a);
$b['count'] = $result['count'];
$i=0;
foreach($a as $key => $value)
	$b[$i++] = $result[$key];
//print_r($b)