Fix Domoticz DB

The FIX::

You need to have sqlite3 installed on your Pi

CODE: SELECT ALL

sudo apt-get install sqlite3 

If you have it you can do the following commands:

CODE: SELECT ALL

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

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

https://www.domoticz.com/forum/viewtopic.php?t=10984

Domoticz Cisco Port on / of switch

Script is created by Johan ven Boomgaard.

#!/bin/bash
# Set-cisco-port.sh
# ==============
# |Author: JvdB|
# ==============
# 
# Find,disable,enable port using SNMP at Cisco switch#
# 
# Usage: cd <directory> ./Set-cisco-port.sh <switch ip-address> <description> <action>
# Example: cd <directory> ./Set-cisco-port.sh 192.168.2.250 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
# =======================================
#
switch_ip=$1;
desc=$(echo $2 | sed 's/://g');
community="private";
operation=$3;
#
2970_get_port(){
# Check for description at port
for i in `snmpwalk -On -v2c -c $community@1 192.168.2.250 .1.3.6.1.4.1.9.9.46.1.3.1.1.2  | sed 's/.1.3.6.1.4.1.9.9.46.1.3.1.1.2.1.//g'  | awk '{print $1}'`; do
        find_mac=`snmpwalk -On -v2c -c  $community@$i 192.168.2.250 .1.3.6.1.2.1.17.4.3.1.1 | 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 .1.3.6.1.2.1.17.4.3.1.1 | sed s/' '//g  | grep -i $desc  | sed 's/.1.3.6.1.2.1.17.4.3.1.1.//g' | sed 's/=.*//g' );
                port_numb=`snmpwalk -v2c -c $community@$i $switch_ip .1.3.6.1.2.1.17.4.3.1.2  | grep -i $point1 | sed 's/^.*INTEGER\: //g'`;
                echo "Description $desc was found at port number #"$port_numb;
        fi
done;
}
disable_port(){
        echo "Going to disable port by Description";
	# Find by port description
        port_to_disable=`snmpwalk -v2c -On -c $community $switch_ip .1.3.6.1.2.1.31.1.1.1.18 | grep -i $desc | sed 's/.1.3.6.1.2.1.31.1.1.1.18.//g' | awk '{print $1}'`;
        # If port was not found
        if [[ $port_to_disable == "" ]]; then
                echo "Port wasn't found by port description. Exiting ...";
                2970_get_port;
                $port_to_disable=$port_numb;
                echo $ $port_to_disable;
                exit;
        fi;
        # Disable port
        snmpset -v2c -c $community $switch_ip .1.3.6.1.2.1.2.2.1.7.$port_to_disable i 2;
        # Save running config of Cisco switch to startup
        save_2970_cfg;
}
enable_port(){
        echo "Going to enable port by Description";
        # Find by port description
        port_to_enable=`snmpwalk -v2c -On -c $community $switch_ip .1.3.6.1.2.1.31.1.1.1.18 | grep -i $desc | sed 's/.1.3.6.1.2.1.31.1.1.1.18.//g' | awk '{print $1}'`;
        # If port was not found
        if [[ $port_to_enable == "" ]]; then
                echo "Port wasn't found by port description. Exiting ...";
                2970_get_port;
                $port_to_enable=$port_numb;
                echo $ $port_to_enable;
                exit;
        fi;
        # Enable port
        snmpset -v2c -c $community $switch_ip .1.3.6.1.2.1.2.2.1.7.$port_to_enable i 1;
        # Save running config of Cisco switch to startup
        save_2970_cfg;
}
save_2970_cfg(){
        echo "Saving Cisco 2970 switch configuration";
         snmpset -t60 -v2c -c $community $switch_ip 1.3.6.1.4.1.9.2.1.54.0 i 1
}
main(){
        if [[ $operation == "f" ]]; then
                echo "Find port operation";
                2970_get_port;
        elif [[ $operation == "d" ]]; then
                echo "Disable port operation";
                disable_port;
        elif [[ $operation == "e" ]]; then
                echo "Enable port operation";
                enable_port;
        else
                echo "Wrong arguments given";
        fi;
}
main;

 

Update Synology Mail Plus spam server more than once a day.

Update Synology Mail Plus spam server more than once a day

Just found the scripts that you can run and schedule to run more often than once a day. And if you run ClaimAV as virusscanner.

Run the following scripts.

bash /volume1/@appstore/MailPlus-Server/scripts/SpamRuleUpdate.sh all
bash /volume1/@appstore/MailPlus-Server/scripts/SpamAutoLearn.sh
bash /volume1/@appstore/AntiVirus/scripts/clamav.sh check_update

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: arpdggefuegr23723n.myfritz.net
  • 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 ….

Installation:

sudo apt-get install vpnc

Create and customize config:

sudo nano /etc/vpnc/fritzbox.conf

IPSec gateway arpdggefuegr23723n.myfritz.net
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

Source: kuemmel.wtf

Raspberry pi cleanup script

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

sudo nano cleanup.sh

Paste below the text and with CTRL + X close nano

#!/bin/bash
 
OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
YELLOW="\033[1;33m"
RED="\033[0;31m"
ENDCOLOR="\033[0m"
 
if [ $USER != root ]; then
echo -e $RED"Error: must be root"
echo -e $YELLOW"Exiting..."$ENDCOLOR
exit 0
fi
 
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 cleanup.sh

Start the cleanup:

Sudo ./cleanup.sh

 

Assign ip to VPN connecton on synology nas

Uitgaande van een standaard installatie van het VPN Server package:

Navigeer naar

/usr/syno/etc/packages/VPNCenter/Maak daarin een map aan met de naam

ccdRechten ccd: 0755
Maak in die map een bestand aan met de naam van de gebruiker die het vaste tunnel IP moet krijgen, b.v.

adminSchrijf in dat bestand

ifconfig-push 10.8.0.6 10.8.0.5Rechten admin: 0644

Navigeer naar

/usr/syno/etc/packages/VPNCenter/openvpnOpen

openvpn.confen voeg de regel

client-config-dir /usr/syno/etc/packages/VPNCenter/ccdtoe.

Navigeer naar

/volume1/@appstore/VPNCenter/etc/openvpnopen

radiusplugin.cnfen wijzig

overwriteccfiles=truein

overwriteccfiles=false
Start/Herstart OpenVPN.

Bron: synology-forum.nl

Install WordPress on raspberry

Login with putty

Go to the directory where you want to install wordpress.

cd /var/recepten.van-daag.nl
sudo chown pi: .
rm *
wget http://wordpress.org/latest.tar.gz
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/recepten.van-daag.nl

Create a new apache config

sudo cp -a /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/recepten.van-daag.nl.conf

Edit the config

sudo nano /etc/apache2/sites-available/recepten.van-daag.nl

Change/add this text.

 ServerAdmin webmaster@localhost
 ServerName recepten.van-daag.nl
 DocumentRoot /var/www/recepten.van-daag.nl

 

Now activate the config

sudo a2ensite recepten.van-daag.nl

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.

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
chroot_local_user=YES

Restart ftp server

sudo service vsftpd restart

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