This commit is contained in:
2025-03-23 20:51:29 +00:00
commit 6ffad7f22a
18 changed files with 258 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
Usefull scripts for linux maintenance
all self build
oh yeah
Executable
+5
View File
@@ -0,0 +1,5 @@
#!/bin/bash
# add an event to the event log
# ./addEvent.sh "ERROR,key,timeout,count, text"
echo "$1" | telnet localhost 1234 >/dev/null 2>&1
Executable
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
rsync -ar /root /var/www/owncloud/data/ignace/files/tmp/backup
rsync -ar /etc /var/www/owncloud/data/ignace/files/tmp/backup
rsync -ar /usr/share/projects /var/www/owncloud/data/ignace/files/tmp/backup
# rsync -ar /home/git/repositories /var/www/owncloud/data/ignace/files/tmp/backup/gitea
# rsync -ar /home/git/data /var/www/owncloud/data/ignace/files/tmp/backup/gitea
rsync -ar /opt /var/www/owncloud/data/ignace/files/tmp/backup
# rsync -ar /var/www /var/www/owncloud/data/ignace/files/tmp/backup
rsync -ar /usr/local/bin /var/www/owncloud/data/ignace/files/tmp/backup/usrlocalbin
mysqldump Flowers >/var/www/owncloud/data/ignace/files/tmp/backup/flowers.sql
sudo -u www-data php /var/www/owncloud/occ files:scan --all
Executable
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
systemctl stop gitea
cd /tmp
su git -c '/usr/local/bin/gitea dump -c /etc/gitea/app.ini'
systemctl start gitea
F=$(ls -1rt /tmp/gitea-dump* | tail -1)
cp ${F} /var/www/owncloud/data/ignace/files/tmp/backup/gitea-dump.zip
+5
View File
@@ -0,0 +1,5 @@
#!/bin/bash
if [ $( ps -e | grep -c eventService ) -lt 1 ]; then
start-stop-daemon -SbCv -x /opt/Monitor/monitor/eventService.py
fi
Executable
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
# check a number of files to see if they have been tampered with, in case of a ransomware attack
# prepare:
# create a gpg private key: gpg --full-generate-key
# create folder /opt/filesOk
# create signature file like: gpg --output file6 --detach-sig /root/plex.README
# verify as in below.
out="/tmp/fileIntegrity.log"
date >>${out}
log="/tmp/filesOk.txt"
cd /opt/filesOk
gpg --verify file1 /media/plex/Photos/2010-07-24\ 14.09.24.jpg >${log} 2>&1
gpg --verify file2 /media/plex/CDs/ABBA/Waterloo/01\ Waterloo.mp3 >>${log} 2>&1
gpg --verify file3 /media/plex/Gelul/Harrie\ Jekkers/Het\ gelijk\ van\ de\ koffietent/01\ De\ wonderen\ zijn\ de\ wereld\ uit.mp3 >>${log} 2>&1
gpg --verify file4 /var/www/owncloud/data/ignace/files/DocumentsSamen/Administration/Huisagendas/huisagenda\ 2019.pdf >>${log} 2>&1
gpg --verify file5 /var/www/owncloud/data/janine/files/2019/Adreswijzigingen.docx >>${log} 2>&1
gpg --verify file6 /root/plex.README >>${log} 2>&1
gpg --verify file7 /root/SAVEIPS >>${log} 2>&1
if [ $(grep -c BAD ${log}) -gt 0 ] ; then
echo "FILE has been changed". >>${out}
/usr/local/bin/addEvent.sh "ERROR,GPG1,1,1,Tampering! A file signature failed. Check integrity of your files."
else
echo "All files unchanged :-) " >>${out}
/usr/local/bin/addEvent.sh "INFO - All pgp file signature checks were fine."
fi
+39
View File
@@ -0,0 +1,39 @@
#!/bin/bash
function set_file_desc {
image="$*"
echo "${image}"
xid=$(exiftool -s -EXIF:ImageDescription "${image}")
if [ ${#xid} -lt 3 ]; then
xdd=$(exiftool -s3 -Description "${image}")
if [ ${#xdd} -gt 2 ]; then
echo " Description -> ${xdd}"
exiftool -P -overwrite_original -EXIF:ImageDescription="${xdd}" "${image}"
else
xti=$(exiftool -s3 -Title "${image}")
if [ ${#xti} -gt 2 ]; then
echo " Title -> ${xti}"
exiftool -P -overwrite_original -EXIF:ImageDescription="${xti}" "${image}"
else
xon=$(exiftool -s3 -IPTC:ObjectName "${image}")
if [ ${#xon} -gt 2 ]; then
echo " ObjectName -> ${xon}"
exiftool -P -overwrite_original -EXIF:ImageDescription="${xon}" "${image}"
fi
fi
fi
fi
echo " Removing ObjectName"
exiftool -P -overwrite_original -IPTC:ObjectName= "${image}"
}
function show_file {
ls -l "$*"
}
find . -type f -iname "*.jpg" -print0 | while IFS= read -r -d '' file; do
# set_file_desc "${file}"
echo $file
done
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
find /media/plex/Photos -type f -iname "*.mp4" -print0 | while IFS= read -r -d '' file; do
# set_file_desc "${file}"
echo $file
done
Executable
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from Naked.app import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
Executable
+3
View File
@@ -0,0 +1,3 @@
#! /bin/bash
cd /var/www/owncloud
sudo -E -u www-data /usr/bin/php /var/www/owncloud/occ "$@"
Executable
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
systemctl restart plexmediaserver
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
python3 /opt/Monitor/monitor/sendAuthMail.py "$1"
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
function set_file_desc {
image="$*"
echo "${image}"
xid=$(exiftool -s -EXIF:ImageDescription "${image}")
if [ ${#xid} -lt 3 ]; then
xdd=$(exiftool -s3 -Description "${image}")
if [ ${#xdd} -gt 2 ]; then
echo " Description -> ${xdd}"
exiftool -P -overwrite_original -EXIF:ImageDescription="${xdd}" "${image}"
else
xti=$(exiftool -s3 -Title "${image}")
if [ ${#xti} -gt 2 ]; then
echo " Title -> ${xti}"
exiftool -P -overwrite_original -EXIF:ImageDescription="${xti}" "${image}"
else
xon=$(exiftool -s3 -IPTC:ObjectName "${image}")
if [ ${#xon} -gt 2 ]; then
echo " ObjectName -> ${xon}"
exiftool -P -overwrite_original -EXIF:ImageDescription="${xon}" "${image}"
fi
fi
fi
fi
echo " Removing ObjectName"
exiftool -P -overwrite_original -IPTC:ObjectName= "${image}"
}
function show_file {
ls -l "$*"
}
find . -name "*.jpg" -type f -print0 | while IFS= read -r -d '' file; do
set_file_desc "${file}"
done
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
systemctl stop plexmediaserver
echo "update metadata_items set title = summary where metadata_type=13 and length(summary)>2;" | /usr/lib/plexmediaserver/Plex\ SQLite "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db"
systemctl start plexmediaserver
Executable
+46
View File
@@ -0,0 +1,46 @@
#!/bin/bash
# check if /tmp/emailcheck.sms exists, if so, send its content to ignace's phone
FILE_ALL='/tmp/emailcheck.*'
FILE_SMS='/tmp/emailcheck.sms'
FILE_WARNING='/tmp/emailcheck.warning'
FILE_ESCALATE='/tmp/emailcheck.ESCALATE'
TEXT=''
echo $(date)
function sendsms {
echo " SMS: $1 $TEXT"
clicksend sms send \
--to "$1" \
--body "$TEXT" \
--csuser 'ignace.suy@gmail.com' \
--cstoken 'BDAED8AF-29CF-F730-145F-0864C7D86813' >/dev/null 2>&1
}
if [ -f "$FILE_SMS" ]; then
echo " sms file found"
TEXT="$(cat $FILE_SMS)"
rm -f $FILE_SMS
sendAlertMail.sh "$TEXT"
if [ -f "$FILE_ESCALATE" ] ; then
# do this, then restart as if it never happened
rm -rf "$FILE_ALL"
echo " sending escalation messages"
sendsms '+31655195180'
# sendsms '+31624276531' # janine
# sendsms '+31624593799' # xander
# sendsms '+31621301914' # querijn
# send emails to all involved
python3 /opt/Monitor/monitor/sendEscalationMail.py
/usr/local/bin/enableKatja
else
if [ -f "$FILE_WARNING" ] ; then
echo " sending warning message"
sendsms '+31655195180'
fi
fi
fi
Executable
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
set -x
clicksend sms send \
--to '+31655195180' \
--body "$*" \
--csuser 'ignace.suy@gmail.com' \
--cstoken 'BDAED8AF-29CF-F730-145F-0864C7D86813' >/tmp/clicksend.log 2>&1
sendAlertMail.sh "SMS sent to your phone: $*"
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
# weekly truncate the below files to a 100 lines
function trunc() {
echo "$(tail -1000 ${1})" > ${1}
}
trunc /tmp/monitor_emails.log
trunc /tmp/sms.log
trunc /tmp/meteoo.err
trunc /tmp/monitor.err
Executable
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'virtualenv==20.4.6','console_scripts','virtualenv'
__requires__ = 'virtualenv==20.4.6'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(
load_entry_point('virtualenv==20.4.6', 'console_scripts', 'virtualenv')()
)