[bash] Export wordpress posts as pdf without plugin

Install wkhtmltopdf:

apt-get install wkhtmltopdf

From phpmyadmin, export permalinks as CSV, use this SQL query:

SELECT `post_name` FROM `wp_posts` WHERE `post_type` = 'post' AND `post_status` = 'publish';

Copy the script, change filename, wp base url and output directory:


# Input file

# Wordpress base url

# Ouput dir

mkdir -p $directory

while IFS=$'\n\r' read -r permalink
    if [ ! -f $directory$permalink.pdf ]; then

        echo $wp$permalink

        wkhtmltopdf $wp$permalink $directory$permalink.pdf
done < "$filename"

Set permission and execute:

chmod +x wordpress2pdf.sh



If you don’t have access to the mysql database you can crawl the sitemap.xml. See this script: https://github.com/chemel/blog2pdf

[debian] Howto install mini DLNA server

minidlna is a lightware DLNA server allow to stream media files (musics, pictures, and videos) on your Smart TV or Smartphone on a network.

Let’s start:

Install the server with apt:

apt-get install minidlna

Edit config file:

nano /etc/minidlna.conf
# set your media dir

# uncomment log_dir if you want

# uncomment max_connections

Open UDP port 1900 and TCP port 8200 in your firewall, for iptables add the following rules:

iptables -A INPUT -i eth0 -p udp --dport 1900 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 8200 -j ACCEPT

Restart the server:

service minidlna restart

Job done!

Note: to regenerate minidlna’s database type:

minidlnad -R

Note2: to view MiniDLNA status open in your browser

Note3: Working great on Samsung Smart TV

[debian] Installation d’un DNS menteur avec bind9 rpz

Install the server with apt:

apt-get install bind9

Edit config file:

nano /etc/bind/named.conf.options

Add response-policy directive with your zone:

response-policy { zone "loppsi.gouv.fr"; };

Edit config file:

nano /etc/bind/named.conf.local

Create your zone:

zone "loppsi.gouv.fr" {
      type master;
      file "/etc/bind/db.loppsi.gouv.fr";
      allow-query {none;};

Create config file:

nano /etc/bind/db.loppsi.gouv.fr

Add your rules:

; Beginning of the zone, some mandatory values

@   SOA gueant.interieur.gouv.fr. root.elysee.fr (2011031800 2h 30m 30d 1h)
    NS gueant.interieur.gouv.fr.

; Filtering rules
; NXDOMAIN will be sent back
google-analytics.com         CNAME   .
*.google-analytics.com         CNAME   .

; NOERROR, ANSWER=0 will be sent back
enlarge-your-penis.biz           CNAME   *.
*.enlarge-your-penis.biz         CNAME   *.

; Replace the address by ours
; Since we provide only a AAAA, A queries will get NOERROR,ANSWER=0
ads.example.net             AAAA 2001:db8::1

Restart the server:

service bind9 restart

Testing with dig:

# Simple with default dns
dig google-analytics.com

# Choose DNS server
dig @ google-analytics.com

# Choose DNS server and port
dig @ -p 9053 google-analytics.com

Source : http://www.bortzmeyer.org/rpz-faire-mentir-resolveur-dns.html

[debian] How to install and configure ISC DHCP Server

Install the server with apt

apt-get install isc-dhcp-server

Edit config file

nano /etc/default/isc-dhcp-server

Add your network interface, default eth0


Edit dhcpd config file

nano /etc/dhcp/dhcpd.conf



And add at the end of file

subnet netmask { # IP and Netmask
  option routers; # Gateway
  option domain-name-servers; # DNS
  pool {
    range; # IP Range

Restart the server

service isc-dhcp-server restart

Static address reservation

subnet netmask { # IP and Netmask
  option routers; # Gateway
  option domain-name-servers; # DNS
  pool {
    range; # IP Range
  host printer {
    hardware ethernet CA-FC-EB-91-D6-31;

Logging: redirect syslog to dhcpd.log

Edit dhcpd.conf

nano /etc/dhcp/dhcpd.conf


log-facility local7;

Edit rsyslog default.conf

nano /etc/rsyslog.d/50-default.conf

Change “*.*;auth,authpriv.none -/var/log/syslog” to

*.*;auth,authpriv.none,local7.none  -/var/log/syslog

Add following line

local7.*    /var/log/dhcpd.log

Touch dhcpd.log and change owner

touch /var/log/dhcpd.log
chown syslog:adm /var/log/dhcpd.log

Restart syslog and isc-dhcp-server

service syslog restart
service isc-dhcp-server restart

[linux] Create virtual machine from physical disk

Convert directly:

VBoxManage convertfromraw /dev/sda sda.vdi --format vdi

Or Create raw image backup and convert it:

dd if=/dev/sda of=/storage/sda.raw

VBoxManage convertfromraw sda.raw sda.vdi --format vdi

To list all devices, run: