virsh cheat sheet

list guests:

virsh list --all

Show guests info:

virsh dominfo $vmname

Start guest:

virsh start $vmname

Shutdown guest:

virsh shutdown $vmname

Poweroff guest:

virsh destroy $vmname

Suspend guest:

virsh suspend $vmname

Resume guest:

virsh resume $vmname

Create guest from XML:

virsh create xml_file.xml

Dump guest XML:

virsh dumpxml $vmname

Modify guest:

virsh edit $vmname

Remove guest definition:

virsh undefine $vmname

Save guest state:

virsh save $vmname $state_file

Restore guest state:

virsh restore $state_file

Create guest:

virt-install --name=$vmname --arch=x86_64 --vcpus=1 --ram=1024 --os-type=linux --os-variant=generic26 --hvm --connect=qemu:///system --network bridge:virbr0 --cdrom=/where/ever/u/store/isos/arch.iso --disk path=/where/ever/u/wish/guest.img,size=20 --accelerate --vnc --noautoconsole --keymap=de

Migrate guest:

virsh migrate --live --copy-storage-inc --verbose $vmname qemu+ssh://destination/system

Linux SSHFS usage in fstab

on e.g. Debian you have to install

aptitude install sshfs

edit /etc/fstab and add the line

sshfs#user@123.123.123.123:/what/ever/remote/	/where/you/wish/local/	fuse	uid=1003,gid=100,umask=0,allow_other,_netdev,ro		0	0

or directly in shell:

sshfs user@123.123.123.123:/what/ever/remote/ /where/you/wish/local/ -o idmap=user -o uid=1000 -o gid=100 -o umask=0 -o allow_other -o ro

Build RetroShare 0.5.4f on Debian 7 Wheezy

install required packages

aptitude install libgpg-error-dev libupnp-dev libssl-dev libgnome-keyring-dev libxss-dev subversion gnupg-agent libupnp3 libqt4-dev g++ libgpgme11-dev
aptitude install g++ libgnome-keyring-dev libqt4-dev libxss-dev libssl-dev libupnp-dev subversion libbz2-dev libprotobuf-dev protobuf-compiler cmake

get latest SVN

svn co svn://svn.code.sf.net/p/retroshare/code/trunk retroshare

Compile/Make RetroShare

cd libbitdht/src && qmake && make clean && make -j2 && cd ../../
cd openpgpsdk/src && qmake && make clean && make -j2 && cd ../../
cd libretroshare/src && qmake && make clean && make -j2 && cd ../../
cd retroshare-gui/src && qmake && make clean && make -j2

Source
http://retroshare.sourceforge.net/wiki/index.php/UnixCompile

PHPInfo in Bootstrap Style

Einfach in den Body der Bootstrap Seite reinkopieren.
<?php
ob_start();
phpinfo();
$phpinfo = ob_get_clean();

# Body-Content rausholen
$phpinfo = preg_replace('#^.*<body>(.*)</body>.*$#s', '$1', $phpinfo);
# XHTML-Fehler korrigieren
$phpinfo = str_replace('module_Zend Optimizer', 'module_Zend_Optimizer', $phpinfo);
# <font> durch <span> ersetzen
$phpinfo = str_replace('<font', '<span', $phpinfo);
$phpinfo = str_replace('</font>', '</span>', $phpinfo);
#Table
$phpinfo = str_replace( 'border="0" cellpadding="3"', 'class="table table-bordered table-striped" style="table-layout: fixed;word-wrap: break-word;"', $phpinfo );
$phpinfo = str_replace('<tr class="h"><th>', '<thead><tr><th>', $phpinfo);
$phpinfo = str_replace('</th></tr>', '</th></tr></thead><tbody>', $phpinfo);
$phpinfo = str_replace('</table>', '</tbody></table>', $phpinfo);
# Schlüsselwörter grün oder rot einfärben
$phpinfo = preg_replace('#>(on|enabled|active)#i', '><span class="text-success">$1</span>', $phpinfo);
$phpinfo = preg_replace('#>(off|disabled)#i', '><span class="text-error">$1</span>', $phpinfo);

echo '<div id="phpinfo">';
echo $phpinfo;
echo '</div>';
?>

Copy Image via netcat

This is for a High-Bandwidth Network. If you have a Low-Bandwidth Network you can try to switch lzo with bzip2.

Target:
nc -v -l -p 19000 | lzop -c -d | pv -s 70G | dd bs=16M of=/root/foo.img

  1. listen on port 19000 for connections.
  2. decompress the datapackages.
  3. pv displays a status bar.
  4. and wirte them into a file.

Source:
dd bs=16M if=/root/bar.img | lzop -3 -c | nc -v 10.0.01 19000

  1. dd reads the file in 16MB Blocks.
  2. each block will be compressed with lzo.
  3. nc connects 10.0.01 on port 19000 and pushes data.

Asterisk under Debian Wheezy with SIP Softphone Ekiga or Jitsi

install asterisk

aptitude install asterisk

edit /etc/asterisk/sip.conf

[general]
context = default
bindport = 5060
bindaddr = 0.0.0.0
tcpbindaddr = 0.0.0.0
tcpenable = yes

[1001]
type = friend
callerid = User 1001 <1001>
secret = 1001
host = dynamic
canreinvite = no
dtmfmode = rfc2833
mailbox = 1001
disallow = all
allow = ulaw
transport = udp

[1002]
type = friend
callerid = User 1002 <1002>
secret = 1002
host = dynamic
canreinvite = no
dtmfmode = rfc2833
mailbox = 1002
disallow = all
allow = ulaw
transport = udp

edit /etc/asterisk/extensions.conf

[general]
static=yes
writeprotect=no

[default]
exten => 1001,1,Answer()
exten => 1001,n,Dial(SIP/1001,20,tr)
exten => 1001,n,Hangup

exten => 1002,1,Answer()
exten => 1002,n,Dial(SIP/1002,20,tr)
exten => 1002,n,Hangup.

Soft Phones e.g. Ekiga or Jitsi

Skipfish on Debian Wheezy

install dependencies

aptitude install libidn11-dev zlib1g-dev libpcre3-dev

download skipfish

wget https://skipfish.googlecode.com/files/skipfish-2.10b.tgz

unpack

tar xvf skipfish-2.10b.tgz

compile

cd skipfish-2.10b
make

run e.g.

./skipfish -W dictionaries/complete.wl -o ../superskipfish/ http://domain.tdl/