Fix Domoticz DB

The FIX::

You need to have sqlite3 installed on your Pi


sudo apt-get install sqlite3 

If you have it you can do the following commands:


cd ~
cd domoticz
sqlite3 domoticz.db
.mode insert
.output dump.sql

Remove first line of dumped database:
tail dump.sql -n +2 > dump1.sql
# Make back-up of original just in case:
mv domoticz.db domoticz.bak.db
# Import into fresh database:
sqlite3 domoticz.db < dump1.sql
# Clean-up the temporary files:
rm dump*.sql

Domoticz Cisco Port on / of switch

Script is created by Johan ven Boomgaard.

# ==============
# |Author: JvdB|
# ==============
# Find,disable,enable port using SNMP at Cisco switch#
# Usage: cd <directory> ./ <switch ip-address> <description> <action>
# Example: cd <directory> ./ Test-pc e 
# Where:
# - 1st parameter is switch IP address
# - 2nd is Description of NIC/Device
# - 3rd is operation(e - enable port when find description at port, d -disable port when find description at port)
# =======================================
# Start script with setting the variables
# =======================================
desc=$(echo $2 | sed 's/://g');
# Check for description at port
for i in `snmpwalk -On -v2c -c $community@1 .  | sed 's/.'  | awk '{print $1}'`; do
        find_mac=`snmpwalk -On -v2c -c  $community@$i . | sed s/' '//g  | grep -i $desc | sed 's/^.*Hex-STRING\://g'| awk '{print $1}'`;
        if [[ $find_mac != "" ]]; then
                point1=$(snmpwalk -On -v2c -c $community@$i $switch_ip . | sed s/' '//g  | grep -i $desc  | sed 's/.' | sed 's/=.*//g' );
                port_numb=`snmpwalk -v2c -c $community@$i $switch_ip .  | grep -i $point1 | sed 's/^.*INTEGER\: //g'`;
                echo "Description $desc was found at port number #"$port_numb;
        echo "Going to disable port by Description";
	# Find by port description
        port_to_disable=`snmpwalk -v2c -On -c $community $switch_ip . | grep -i $desc | sed 's/.' | awk '{print $1}'`;
        # If port was not found
        if [[ $port_to_disable == "" ]]; then
                echo "Port wasn't found by port description. Exiting ...";
                echo $ $port_to_disable;
        # Disable port
        snmpset -v2c -c $community $switch_ip .$port_to_disable i 2;
        # Save running config of Cisco switch to startup
        echo "Going to enable port by Description";
        # Find by port description
        port_to_enable=`snmpwalk -v2c -On -c $community $switch_ip . | grep -i $desc | sed 's/.' | awk '{print $1}'`;
        # If port was not found
        if [[ $port_to_enable == "" ]]; then
                echo "Port wasn't found by port description. Exiting ...";
                echo $ $port_to_enable;
        # Enable port
        snmpset -v2c -c $community $switch_ip .$port_to_enable i 1;
        # Save running config of Cisco switch to startup
        echo "Saving Cisco 2970 switch configuration";
         snmpset -t60 -v2c -c $community $switch_ip i 1
        if [[ $operation == "f" ]]; then
                echo "Find port operation";
        elif [[ $operation == "d" ]]; then
                echo "Disable port operation";
        elif [[ $operation == "e" ]]; then
                echo "Enable port operation";
                echo "Wrong arguments given";


Raspberry PI as a VPN Client to FRITZBOX with IPSEC

Setup of VPN at the Fritzbox

First, a new user is created under System-> FRITZ! Box user.

Here, the access from the Internet must be granted and VPN (of course, be unlocked, everything else is deselected.

we remember the information from the iphone settings:

  • Description:
  • Server:
  • Account: vpn_user
  • Password: Password of the FRITZ! Box user “vpn_user”
  • Use certificate is disabled
  • Group name: vpn_user
  • Shared Secret: TANrpS1y34hHHJGIS4
 Now it goes on the Raspi ….


sudo apt-get install vpnc

Create and customize config:

sudo nano /etc/vpnc/fritzbox.conf

IPSec gateway
IPSec ID vpn_user
IPSec secret TANrpS1y34hHHJGIS4
IKE Authmode psk
Xauth username vpn_user
Xauth password <passwort>
local port 0
DPD idle timeout (our side) 0

first test of the tunnel:

sudo vpnc fritzbox.conf

Ending the VPn connection:

sudo vpnc-disconnect

I have the start of the script in /etc/rc.local registered so that the VPN connection is established during boot.

vpnc fritzbox.conf

– Update –

Since the VPN connection breaks partially uncontrolled Abdelkader Wahb has made a script that monitors the connection and reboots when needed. I do not want to deprive you of this:

Entry in / etc / crontab so that every 3 minutes is automatically executed on boot:

* / 3 * * * * root /etc/init.d/autovpncscript


Raspberry pi cleanup script

Create with the following command in your raspberry pi the script.

sudo nano

Paste below the text and with CTRL + X close nano

OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
if [ $USER != root ]; then
echo -e $RED"Error: must be root"
echo -e $YELLOW"Exiting..."$ENDCOLOR
exit 0
echo -e $YELLOW"Cleaning apt cache..."$ENDCOLOR
aptitude clean
echo -e $YELLOW"Removing old config files..."$ENDCOLOR
sudo aptitude purge $OLDCONF
echo -e $YELLOW"Removing old kernels..."$ENDCOLOR
sudo aptitude purge $OLDKERNELS
echo -e $YELLOW"Emptying every trashes..."$ENDCOLOR
rm -rf /home/*/.local/share/Trash/*/** &> /dev/null
rm -rf /root/.local/share/Trash/*/** &> /dev/null
echo -e $YELLOW"Script Finished!"$ENDCOLOR

To run the script. First:

sudo chmod 777

Start the cleanup:

Sudo ./


Install WordPress on raspberry

Login with putty

Go to the directory where you want to install wordpress.

cd /var/
sudo chown pi: .
rm *
tar xzf latest.tar.gz
mv wordpress/* .
rm -rf wordpress latest.tar.gz

Now login into MySQL and create database and user.

mysql -uroot -p[Password]
create database recepten;

GRANT ALL PRIVILEGES ON `recepten`.* TO `recepten_user`@`localhost` IDENTIFIED BY '[Password]';

Type Ctrl +D to close

Now browse to the website and run the setup.

Create Subdomains on your raspberry

Login on your raspberry with putty

Create a subdirectory

 sudo mkdir -p /var/www/

Create a new apache config

sudo cp -a /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/

Edit the config

sudo nano /etc/apache2/sites-available/

Change/add this text.

 ServerAdmin webmaster@localhost
 DocumentRoot /var/www/


Now activate the config

sudo a2ensite

Reload the service

sudo service apache2 reload


Install FTP on your Raspberry

Run update

sudo apt-get update

Install ftp

sudo apt-get install vsftpd

You get a message about disk usage enter Yes

Now open up the config file by entering the following command:

sudo nano /etc/vsftpd.conf

In here add or uncomment(Remove the #) for the following settings.


Restart ftp server

sudo service vsftpd restart

And now you can connect with filezilla to the raspberry with SFTP (port 22)

Install webserver on Raspberry Pi

Download Raspbian
Place it on SD card
Start the raspberry.

Login with: pi (root)
Password: raspberry

Type sudo raspi-config to start the config.

Change the password
Change the Hostname
Change Localisation Options -> Change Timezone to Europe, Amsterdam
Change Interfacing Options -> Enable SSH
Update the Raspberry

Exit menu
Reboot the raspberry sudo reboot

Open putty and connect to the raspberry and login

Install Apache webserver on your Raspberry

sudo apt-get install apache2 -y

Install PHP

sudo apt-get install php5 libapache2-mod-php5 -y

sudo apt-get install libapache2-mod-php

Install Mysql

sudo apt-get install mysql-server php5-mysql -y

You get a message to enter MySQL root password. Enter this password and Reenter the password in the next screen

Secure your MySQL

sudo mysql_secure_installation

and enter the MySQL root password

You get the message to change the password. Type No

Now you get some questions. Answer is Yes