]> git.hoellein.online Git - skripte/commitdiff
unifi, dovecot, ccu2 backup
authorroot <root@hoellein.at>
Tue, 19 Jun 2018 11:21:32 +0000 (13:21 +0200)
committerroot <root@hoellein.at>
Tue, 19 Jun 2018 11:21:32 +0000 (13:21 +0200)
backup-ccu2.bash [new file with mode: 0755]
cleanMailtrash.sh [new file with mode: 0755]
unifi/collectMessagesFromAPs.sh [new file with mode: 0755]
unifi/upgradeAPs.sh [new file with mode: 0755]

diff --git a/backup-ccu2.bash b/backup-ccu2.bash
new file mode 100755 (executable)
index 0000000..1fe8db3
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/bash
+# http://www.lxccu.com/manuals:manual-ccu2-backup
+# Homematic CCU Backup Script fuer crontab
+# Erstellt am 13.03.11 von Danny B.
+# Angepasst am 05.08.14 von PaulG4H
+
+# Parameter
+backupdir="/home/backup/ccu2"
+host="192.168.178.20"
+user="backup"
+password="XXXYYYZZZ"
+
+# Voraussetzung: Nutzer hinzufügen, Passwort setzen, Typ Administrator
+#
+# crontab Zeile alle 2 Stunden prüfen ob das letzte Backup älter als 2 Tage
+# ist, dann Backup; es werden max 5 Backups aufgehoben:
+# 0 0-23/2 * * * mario [ -z "$(find /home/backup/ -name homematic-ccu2\* -mtime -2)" ] && ping -q -n -c 1 -W 1 192.168.178.20 > /dev/null 2>&1 && bin/backup-ccu2.bash && find /home/backup/ -name homematic-ccu2\* | sort -r | sed -e "1,5d" | xargs -r rm -f ; true
+
+############### Es sind keine weiteren Anpassung ab hier Notwendig
+
+SCRIPTNAME=${0##*/}
+
+[ -d run ] && cd run
+
+run=$SCRIPTNAME.lastrun
+
+# Homematic Login
+wget --post-data '{"method":"Session.login","params":{"username":"'$user'","password":"'$password'"}}' http://$host/api/homematic.cgi -O hm.login.response -q >$run 2>&1
+
+# Login-Pruefung
+loginerror=`cat hm.login.response|cut -d "," -f3|awk '{print $2}'`
+if [ "$loginerror" != "null}" ]; then
+   echo "Fehler beim Homematic-Login !"|tee -a $run
+   cat hm.login.response|grep message|cut -d '"' -f4|tee -a $run
+   exit 1
+fi
+sessionid=`cat hm.login.response|cut -d "," -f2|awk '{print $2}'|cut -d '"' -f2`
+
+# Backupdatei herunterladen
+wget "http://$host/config/cp_security.cgi?sid=@$sessionid@&action=create_backup" -O $backupdir/homematic-ccu2-$host-$(date +%Y%m%d).tar.sbk -q >>$run 2>&1
+
+# Homematic Logout
+wget --post-data '{"method":"Session.logout","params":{"_session_id_":"'$sessionid'"}}' http://$host/api/homematic.cgi -O hm.logout.response -q >>$run 2>&1
+
+# temp. Dateien loeschen
+
+rm hm.login.response hm.logout.response >>$run 2>&1
+
diff --git a/cleanMailtrash.sh b/cleanMailtrash.sh
new file mode 100755 (executable)
index 0000000..c0bc9bd
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+MAILBOX=$1
+STD_MAILBOX=mhoellein@hoellein.at
+
+FROM_MAILS="movedancewear.co.uk lulu@email.lulu.com anja.weber@pearl.de produkte@service.freenet.de news@aktuell.conrad.de info@offer.ef.com no-reply@gutscheinbuch.de daniela.schmitz@news.eaxus.de noreply@geocaching.com paypal@mail.paypal.de maria.kern@pearl.de marketing@ryanairemail.de guggenheim@emails.guggenheim.org"
+
+SUBJECT="Movement Detected"
+
+if [ -z $MAILBOX ]; then
+       MAILBOX=$STD_MAILBOX
+fi
+echo using $MAILBOX 
+
+doFrom() {
+       for from in $FROM_MAILS
+       do
+               doveadm expunge -u $MAILBOX mailbox "INBOX.Trash" from  "$from" before `date -d '40 days ago' '+%Y-%m-%y'`
+       done
+}
+
+doSubject() {
+       for subject in $SUBJECT
+       do
+               doveadm expunge -u $MAILBOX mailbox "INBOX.Trash" subject  "$subject" before `date -d '40 days ago' '+%Y-%m-%y'`
+       done
+}
+
+doveadm expunge -u $MAILBOX mailbox "INBOX.arpwatch" from  "arpwatch" before `date -d '40 days ago' '+%Y-%m-%y'` 
+
+
+doFrom
+doSubject
diff --git a/unifi/collectMessagesFromAPs.sh b/unifi/collectMessagesFromAPs.sh
new file mode 100755 (executable)
index 0000000..677f30b
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+DEST_DIR="/tmp/"
+AP_USER="admin"
+NETZ_AP="192.168.178."
+IP_AP="3 4 5 6 7 8 10"
+
+for i in ${IP_AP}; do
+       scp -i /root/.ssh/unifi ${AP_USER}@${NETZ_AP}${i}:/var/log/messages ${DEST_DIR}/AP_${NETZ_AP}${i}_messages.log
+done
diff --git a/unifi/upgradeAPs.sh b/unifi/upgradeAPs.sh
new file mode 100755 (executable)
index 0000000..c74e482
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+FW=`pwd`/$1
+SSH_KEY="/root/.ssh/unifi"
+DEST_DIR="/tmp/"
+AP_USER="admin"
+NETZ_AP="192.168.178."
+IP_AP="4 6 3 5 7 8 10"
+#copy
+for i in ${IP_AP}; do
+       scp -i $SSH_KEY ${1} ${AP_USER}@${NETZ_AP}${i}:/tmp/fwupdate.bin
+       sleep 3
+done
+#upgrade
+for i in ${IP_AP}; do
+       ssh -i $SSH_KEY ${AP_USER}@${NETZ_AP}${i} 'syswrapper.sh upgrade2 &'
+       sleep 3
+done