From 5b005ac95d776fd5f662bad24f5a4b4f0dca2d04 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 20 Aug 2022 00:06:22 +0200 Subject: [PATCH] more cleanups in bash scripts --- bash/backup-btrfs.sh | 38 ++++---- bash/backup-mysql.sh | 2 +- bash/backup-remote-restic.sh | 4 +- bash/backup-remote.sh | 13 ++- bash/{backupscript.sh => backup-script.sh} | 104 +++++++++------------ bash/cartodb/import_tcx.sh | 94 +++++++++++++++++++ bash/cartodb/tcx2gpx.sh | 47 ++++++++++ bash/cronic.sh | 0 bash/crop.sh | 17 ++++ bash/{deviantbg.sh => deviant-bg.sh} | 24 +---- bash/dump.sh | 0 bash/dyndns-update.sh | 0 bash/fan-ctl.sh | 52 +++++------ bash/flv2mp4.sh | 2 - bash/geo2gps.sh | 2 - bash/get-panoramas.sh | 27 ++++++ bash/getpanoramas.sh | 41 -------- bash/git-svn-relocate.sh | 7 +- bash/git-svn-relocate2.sh | 72 +++++++------- bash/gps2gpx.sh | 2 - bash/gps2pc.sh | 2 - bash/hetzer_sb_notify.sh | 22 ----- bash/ip-rule-restore.sh | 14 +-- bash/ipodvideo.sh | 2 - bash/luks-open.sh | 0 bash/m4a2mp3.sh | 5 - bash/{mountl2p.sh => mount.l2p.sh} | 22 +---- bash/mount.luks.sh | 20 ++-- bash/mousewheel.sh | 6 -- bash/netdev.sh | 5 - bash/nsupdate-dhclient-exit-hook.sh | 8 +- bash/nsupdate.sh | 7 +- bash/panel.sh | 19 ---- bash/pc2gps.sh | 2 - bash/presentation.sh | 5 - bash/recursive-axfr.sh | 47 ---------- bash/restic-btrfs-snapshots.sh | 0 bash/sep.sh | 8 ++ bash/smart-read.sh | 0 bash/update-roa.sh | 0 bash/update-xmltv.sh | 0 bash/uptime.sh | 11 --- bash/{virsh-start-all.sh => virsh-all.sh} | 8 +- bash/{wakeonlan.sh => wake-on-lan.sh} | 22 +---- bash/zfs-load-keys.sh | 16 ++-- bash/zyxel.sh | 6 +- 46 files changed, 387 insertions(+), 418 deletions(-) mode change 100644 => 100755 bash/backup-remote-restic.sh rename bash/{backupscript.sh => backup-script.sh} (80%) create mode 100755 bash/cartodb/import_tcx.sh create mode 100755 bash/cartodb/tcx2gpx.sh mode change 100644 => 100755 bash/cronic.sh create mode 100755 bash/crop.sh rename bash/{deviantbg.sh => deviant-bg.sh} (60%) mode change 100644 => 100755 bash/dump.sh mode change 100644 => 100755 bash/dyndns-update.sh mode change 100644 => 100755 bash/fan-ctl.sh delete mode 100755 bash/flv2mp4.sh delete mode 100755 bash/geo2gps.sh create mode 100755 bash/get-panoramas.sh delete mode 100755 bash/getpanoramas.sh delete mode 100755 bash/gps2gpx.sh delete mode 100755 bash/gps2pc.sh delete mode 100755 bash/hetzer_sb_notify.sh mode change 100644 => 100755 bash/ip-rule-restore.sh delete mode 100755 bash/ipodvideo.sh mode change 100644 => 100755 bash/luks-open.sh delete mode 100755 bash/m4a2mp3.sh rename bash/{mountl2p.sh => mount.l2p.sh} (68%) delete mode 100755 bash/mousewheel.sh delete mode 100755 bash/netdev.sh delete mode 100755 bash/panel.sh delete mode 100755 bash/pc2gps.sh delete mode 100755 bash/presentation.sh delete mode 100644 bash/recursive-axfr.sh mode change 100644 => 100755 bash/restic-btrfs-snapshots.sh create mode 100755 bash/sep.sh mode change 100644 => 100755 bash/smart-read.sh mode change 100644 => 100755 bash/update-roa.sh mode change 100644 => 100755 bash/update-xmltv.sh delete mode 100755 bash/uptime.sh rename bash/{virsh-start-all.sh => virsh-all.sh} (63%) mode change 100644 => 100755 rename bash/{wakeonlan.sh => wake-on-lan.sh} (52%) mode change 100644 => 100755 bash/zfs-load-keys.sh diff --git a/bash/backup-btrfs.sh b/bash/backup-btrfs.sh index 564ce4f..bf102c8 100755 --- a/bash/backup-btrfs.sh +++ b/bash/backup-btrfs.sh @@ -17,6 +17,8 @@ # TODO: delete old snapshots in source and destination fs +set -e + function usage { echo "Usage: $(basename $0) SOURCE [DEST]" echo @@ -26,53 +28,55 @@ function usage { exit 1 } -set -e - if [ $# -lt 1 ]; then echo -e "missing source" echo usage fi -SRC=$(readlink -f "$1") +SRC=$(readlink -e "$1") +if [ $SRC == "/" ]; then + SRC="" +fi if [ -h "$SRC/.backup/destination" ]; then - DEST=$(readlink -f "$SRC/.backup/destination") + DEST=$(readlink -e "$SRC/.backup/destination") elif [ $# -ne 2 ] ; then echo -e "missing destination" echo usage else - DEST=$(readlink -f $2) - - mkdir -p "$SRC/.backup/" - mkdir -p "$DEST" - - ln -sf "$DEST" "$SRC/.backup/destination" - ln -sf "$SRC" "$DEST/source" + DEST=$(readlink -e $2) fi +# create directories if not existing +mkdir -p "$SRC/.backup/" +mkdir -p "$DEST/" + +# create symbolic links if not existing +ln -snf "$DEST/" "$SRC/.backup/destination" +ln -snf "$SRC/" "$DEST/source" + # name for the new snapshot SNAPSHOT=$(date +%F_%H-%M-%S) LATEST="$SRC/.backup/$SNAPSHOT" # snapshot the current state -btrfs subvolume snapshot -r "$SRC" "$LATEST" +btrfs subvolume snapshot -r "$SRC/" "$LATEST/" # send changes if [ -h "$DEST/latest-source" ]; then - PREVIOUS=$(readlink -f "$DEST/latest-source") - btrfs send -p "$PREVIOUS" "$LATEST" | btrfs receive "$DEST" + PREVIOUS=$(readlink -e "$DEST/latest-source") + btrfs send -p "$PREVIOUS/" "$LATEST/" | pv | btrfs receive "$DEST/" else - btrfs send "$LATEST" | btrfs receive "$DEST" + btrfs send "$LATEST/" | pv | btrfs receive "$DEST/" fi # delete old snapshot in source fs if [ -n "$PREVIOUS" ]; then - btrfs subvolume delete "$PREVIOUS" + btrfs subvolume delete "$PREVIOUS/" fi # update links to last backup ln -rsfT "$DEST/$SNAPSHOT" "$DEST/latest" ln -sfT "$LATEST" "$DEST/latest-source" - diff --git a/bash/backup-mysql.sh b/bash/backup-mysql.sh index 0fadf44..d566c63 100755 --- a/bash/backup-mysql.sh +++ b/bash/backup-mysql.sh @@ -64,7 +64,7 @@ shift $((OPTIND-1)) # parsing backup directory if [ -n "$1" ]; then - DIR=$(readlink -f $1) + DIR=$(readlink -f $1) else DIR=$(pwd) fi diff --git a/bash/backup-remote-restic.sh b/bash/backup-remote-restic.sh old mode 100644 new mode 100755 index 9f4d710..ed27c3a --- a/bash/backup-remote-restic.sh +++ b/bash/backup-remote-restic.sh @@ -11,8 +11,8 @@ set -e if [ $# -ne 2 ]; then - echo "Usage: $(basename $0) SOURCE REPO" - exit 1 + echo "Usage: $(basename $0) SOURCE REPO" + exit 1 fi SRC=$1 diff --git a/bash/backup-remote.sh b/bash/backup-remote.sh index 6922601..8a06af5 100755 --- a/bash/backup-remote.sh +++ b/bash/backup-remote.sh @@ -24,11 +24,11 @@ ## function usage { - echo "Usage: $(basename $0) SOURCE DEST" - echo - echo " SOURCE a path to the subvolume to backup" - echo " DEST a path to the backup destination" - exit 1 + echo "Usage: $(basename $0) SOURCE DEST" + echo + echo " SOURCE a path to the subvolume to backup" + echo " DEST a path to the backup destination" + exit 1 } set -e @@ -36,7 +36,7 @@ set -e if [ $# -ne 2 ]; then echo -e "invalid args!" echo - usage + usage fi DATE=$(date +%F_%H-%M-%S) @@ -75,4 +75,3 @@ btrfs subvolume snapshot -r $DEST/.current $DEST/$DATE # create symlink to latest snapshot ln -rsfT $DEST/$DATE $DEST/latest - diff --git a/bash/backupscript.sh b/bash/backup-script.sh similarity index 80% rename from bash/backupscript.sh rename to bash/backup-script.sh index 3fdf54b..e0a98b7 100755 --- a/bash/backupscript.sh +++ b/bash/backup-script.sh @@ -2,24 +2,10 @@ ## # System Backupscript # - # @copyright 2012 Steffen Vogel - # @license http://www.gnu.org/licenses/gpl.txt GNU Public License - # @author Steffen Vogel - # @link http://www.steffenvogel.de - ## -## - # This script is free software: you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by - # the Free Software Foundation, either version 3 of the License, or - # any later version. - # - # This script is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this script. If not, see . + # @copyright 2021, Steffen Vogel + # @license http://www.gnu.org/licenses/gpl.txt GNU Public License + # @author Steffen Vogel + # @link https://www.steffenvogel.de ## #============================================================= @@ -34,7 +20,7 @@ BACKUPDIR="/backup" MYSQL_BACKUPDIR="/backup/mysql" DATA_BACKUPDIR="/backup/data" -# Wochentag für wöchentliche Backups (1-7; 1 steht für Montag) +# Wochentag f�r w�chentliche Backups (1-7; 1 steht f�r Montag) DOWEEKLY=5 # Kompressionsmethode (gzip oder bzip2) @@ -68,7 +54,7 @@ LOGERR=$BACKUPDIR/ERRORS_$HOST-`date +%N`.log # - quiet : sendet nur Error Logs per Mail MAIL_CONTENT="stdout" -# Maximale Größe des Mail Anhangs +# Maximale Gr��e des Mail Anhangs MAIL_MAXATTSIZE="4000" # Mail Adresse @@ -81,7 +67,7 @@ MAIL_ADDR="admin@localhost" # FTP Benutzer FTP_USERNAME=yourftpusername -# FTP Passwort für $FTP_USERNAME +# FTP Passwort f�r $FTP_USERNAME FTP_PASSWORD=yourftppassword # Hostname oder IP Adresse des FTP Servers @@ -91,10 +77,10 @@ FTP_HOST=yourftpserver # Daten Einstellungen #============================================================= -# Liste der täglichen Backupverzeichnisse (durch " " getrennt) +# Liste der t�glichen Backupverzeichnisse (durch " " getrennt) DATA_DIRNAMES="/home /opt/mails /etc" -# Liste der wöchentlichen Backupverzeichnisse (durch " " getrennt) +# Liste der w�chentlichen Backupverzeichnisse (durch " " getrennt) DATA_WDIRNAMES="/var/www $DATA_DIRNAMES" # Liste der monatlichen Backupverzeichnisse (durch " " getrennt) @@ -114,16 +100,16 @@ TARFLAGS="--create --preserve-permissions --dereference --ignore-failed-read --e # mySQL Benutzer MYSQL_USERNAME=yourmysqlusername -# mySQL Passwort für $MYSQL_USERNAME +# mySQL Passwort f�r $MYSQL_USERNAME MYSQL_PASSWORD=yourmysqlpassword # Hostname oder IP Adresse des mySQL Servers MYSQL_HOST=$HOST -# Liste der täglichen Backupdatenbanken (durch " " getrennt; "all" für alle Datenbanken) +# Liste der t�glichen Backupdatenbanken (durch " " getrennt; "all" f�r alle Datenbanken) MYSQL_DBNAMES="all" -# Liste der wöchentlichen Backupdatenbanken (durch " " getrennt) +# Liste der w�chentlichen Backupdatenbanken (durch " " getrennt) MYSQL_WDBNAMES=$MYSQL_DBNAMES # Liste der monatlichen Backupdatenbanken (durch " " getrennt) @@ -132,13 +118,13 @@ MYSQL_MDBNAMES="$MYSQL_WDBNAMES" # Datenbanken zum Excluden MYSQL_DBEXCLUDE="" -# CREATE DATABASE zu den mySQL Dumps hinzufügen? +# CREATE DATABASE zu den mySQL Dumps hinzuf�gen? MYSQL_CREATE_DATABASE=yes # Komprimierte Verbindung zum mySQL Server MYSQL_COMMCOMP=no -# Maximale Größe des Verbindungspuffer zum mySQL Server (Maximum 1GB) +# Maximale Gr��e des Verbindungspuffer zum mySQL Server (Maximum 1GB) MYSQL_MAX_ALLOWED_PACKET= # Socketadresse des mySQL Server bei localhost Verbindungen @@ -174,13 +160,13 @@ if [ "$MYSQL_COMMCOMP" = "yes" ]; MYSQL_OPT="$OPT --compress" fi -# Maximale Größe des Verbindungspuffer zum mySQL Server (Maximum 1GB) +# Maximale Gr��e des Verbindungspuffer zum mySQL Server (Maximum 1GB) if [ "$MYSQL_MAX_ALLOWED_PACKET" ]; then MYSQL_OPT="$MYSQL_OPT --max_allowed_packet=$MYSQL_MAX_ALLOWED_PACKET" fi -# Benötigte Verzeichnisse erstellen +# Ben�tigte Verzeichnisse erstellen if [ ! -e "$BACKUPDIR" ] then mkdir -p "$BACKUPDIR" @@ -236,7 +222,7 @@ display () { end) echo Backup Ende `date` echo ====================================================================== - echo Benötigter Speicherplatz für Backups: + echo Ben�tigter Speicherplatz f�r Backups: echo Data : `du -hs "$DATA_BACKUPDIR"` echo mySQL: `du -hs "$MYSQL_BACKUPDIR"` echo All : `du -hs "$BACKUPDIR"` @@ -299,33 +285,33 @@ archive () { gzip -l "$1.gz" SUFFIX=".gz" elif [ "$COMP" = "bzip2" ]; then - echo Komprimierungs Informationen für "$1.bz2" + echo Komprimierungs Informationen f�r "$1.bz2" bzip2 -f -v $1 2>&1 SUFFIX=".bz2" else - echo "Keine Kompressionsmethode gewählt!" + echo "Keine Kompressionsmethode gew�hlt!" fi return 0 } -# Soll CREATE_DATABASE hinzugefügt werden? +# Soll CREATE_DATABASE hinzugef�gt werden? if [ "$MYSQL_CREATE_DATABASE" = "no" ]; then MYSQL_OPT="$MYSQL_OPT --no-create-db" else MYSQL_OPT="$MYSQL_OPT --databases" fi -# Wähle alle Datenbanken aus +# W�hle alle Datenbanken aus if [ "$MYSQL_DBNAMES" = "all" ]; then - MYSQL_DBNAMES="`mysql --user=$MYSQL_USERNAME --password=$MYSQL_PASSWORD --host=$MYSQL_HOST --batch --skip-column-names -e "show databases"| sed 's/ /%/g'`" + MYSQL_DBNAMES="`mysql --user=$MYSQL_USERNAME --password=$MYSQL_PASSWORD --host=$MYSQL_HOST --batch --skip-column-names -e "show databases"| sed 's/ /%/g'`" - # Schließe Datenbanken aus + # Schließe Datenbanken aus for exclude in $MYSQL_DBEXCLUDE do MYSQL_DBNAMES=`echo $MYSQL_DBNAMES | sed "s/\b$exclude\b//g"` done - MYSQL_MDBNAMES=$MYSQL_DBNAMES + MYSQL_MDBNAMES=$MYSQL_DBNAMES fi display start # Zeige Start Informationen @@ -340,7 +326,7 @@ fi #================================================ if [ $DOM = "01" ]; then -# Erstellen benötigte Verzeichnisse +# Erstellen ben�tigte Verzeichnisse if [ ! -e "$MYSQL_BACKUPDIR/monthly/$M" ] then mkdir -p "$MYSQL_BACKUPDIR/monthly/$M" @@ -374,7 +360,7 @@ display datastart for DATA_MDIR in $DATA_MDIRNAMES do - # Bereite $DATA_MDIR für den Dateinamen vor + # Bereite $DATA_MDIR f�r den Dateinamen vor DATA_MDIR_DISP="`echo $DATA_MDIR | cut -b 2- | sed 's/\//_/g' | sed 's/ //g'" echo Monthly Backup of $DATA_MDIR... @@ -391,11 +377,11 @@ fi #================================================ -# Wöchentliches Backup +# W�chentliches Backup #================================================ if [ $DNOW = $DOWEEKLY ]; then -# Erstellen benötigte Verzeichnisse +# Erstellen ben�tigte Verzeichnisse if [ ! -e "$MYSQL_BACKUPDIR/weekly/week_$W" ] then mkdir -p "$MYSQL_BACKUPDIR/weekly/week_$W" @@ -406,7 +392,7 @@ if [ ! -e "$DATA_BACKUPDIR/weekly/week_$W" ] mkdir -p "$DATA_BACKUPDIR/weekly/week_$W" fi -# Lösche alte Backups +# L�sche alte Backups echo Rotating 5 weeks Backups... display dl if [ "$W" -le 05 ];then @@ -442,7 +428,7 @@ display datastart for DATA_WDIR in $DATA_WDIRNAMES do - # Bereite $DATA_WDIR für den Dateinamen vor + # Bereite $DATA_WDIR f�r den Dateinamen vor DATA_DIR_DISP="`echo $DATA_WDIR | cut -b 2- | sed 's/\//_/g' | sed 's/ //g'" echo Weekly Backup of $DATA_WDIR... @@ -458,9 +444,9 @@ display dataend fi #================================================ -# Tägliches Backup +# T�gliches Backup #================================================ -# Erstellen benötigte Verzeichnisse +# Erstellen ben�tigte Verzeichnisse if [ ! -e "$MYSQL_BACKUPDIR/daily/$DOW" ] then mkdir -p "$MYSQL_BACKUPDIR/daily/$DOW" @@ -471,7 +457,7 @@ if [ ! -e "$DATA_BACKUPDIR/daily/$DOW" ] mkdir -p "$DATA_BACKUPDIR/daily/$DOW" fi -# Lösche alte Backups +# L�sche alte Backups echo Rotating last weeks Backup... display l eval rm -fv "$MYSQL_BACKUPDIR/daily/$DOW/*" @@ -497,7 +483,7 @@ display datastart for DATA_DIR in $DATA_DIRNAMES do - # Bereite $DATA_DIR für den Dateinamen vor + # Bereite $DATA_DIR f�r den Dateinamen vor DATA_DIR_DISP="`echo $DATA_DIR | cut -b 2- | sed 's/\//_/g' | sed 's/ //g'" echo Daily Backup of $DATA_DIR... @@ -519,39 +505,39 @@ if [ "$POSTBACKUP" ]; then fi #Clean up IO redirection -exec 1>&6 6>&- # Stelle Standartausgabe wieder her und schließe Datei #6 -exec 1>&7 7>&- # Stelle Standartausgabe wieder her und schließe Datei #7 +exec 1>&6 6>&- # Stelle Standartausgabe wieder her und schlie�e Datei #6 +exec 1>&7 7>&- # Stelle Standartausgabe wieder her und schlie�e Datei #7 if [ "$MAIL_CONTENT" = "files" ] then if [ -s "$LOGERR" ] then - # Füge bei Fehlern Error Log hinzu + # F�ge bei Fehlern Error Log hinzu MYSQL_BACKUPFILES="$MYSQL_BACKUPFILES $LOGERR" ERRORNOTE="ACHTUNG Backup Fehler: " fi - # Ermittel SQL Dump Größe + # Ermittel SQL Dump Gr��e MAIL_ATTSIZE=`du -c $MYSQL_BACKUPFILES | grep "[[:digit:][:space:]]total$" |sed s/\s*total//` if [ $MAIL_MAXATTSIZE -ge $MAIL_ATTSIZE ] then BACKUPFILES=`echo "$BACKUPFILES" | sed -e "s# # -a #g"` # enable multiple attachments - mutt -s "$ERRORNOTE Backup Log and SQL Dump für $HOST - $DATE" $BACKUPFILES $MAIL_ADDR < $LOGFILE #senden via mutt + mutt -s "$ERRORNOTE Backup Log and SQL Dump f�r $HOST - $DATE" $BACKUPFILES $MAIL_ADDR < $LOGFILE #senden via mutt else - cat "$LOGFILE" | mail -s "ACHTUNG! - SQL Dump ist zu groß um gemailt zu werden auf $HOST - $DATE" $MAIL_ADDR + cat "$LOGFILE" | mail -s "ACHTUNG! - SQL Dump ist zu gro� um gemailt zu werden auf $HOST - $DATE" $MAIL_ADDR fi elif [ "$MAIL_CONTENT" = "log" ] then - cat "$LOGFILE" | mail -s "Backup Log für $HOST - $DATE" $MAIL_ADDR + cat "$LOGFILE" | mail -s "Backup Log f�r $HOST - $DATE" $MAIL_ADDR if [ -s "$LOGERR" ] then - cat "$LOGERR" | mail -s "$ERRORNOTE Error Log für: $HOST - $DATE" $MAIL_ADDR + cat "$LOGERR" | mail -s "$ERRORNOTE Error Log f�r: $HOST - $DATE" $MAIL_ADDR fi elif [ "$MAIL_CONTENT" = "quiet" ] then if [ -s "$LOGERR" ] then - cat "$LOGERR" | mail -s "$ERRORNOTE Error Log für $HOST - $DATE" $MAIL_ADDR - cat "$LOGFILE" | mail -s "Log für $HOST - $DATE" $MAIL_ADDR + cat "$LOGERR" | mail -s "$ERRORNOTE Error Log f�r $HOST - $DATE" $MAIL_ADDR + cat "$LOGFILE" | mail -s "Log f�r $HOST - $DATE" $MAIL_ADDR fi else if [ -s "$LOGERR" ] @@ -574,7 +560,7 @@ if [ -s "$LOGERR" ] STATUS=0 fi -# Löschen der Logfiles +# L�schen der Logfiles eval rm -f "$LOGFILE" eval rm -f "$LOGERR" diff --git a/bash/cartodb/import_tcx.sh b/bash/cartodb/import_tcx.sh new file mode 100755 index 0000000..d47121a --- /dev/null +++ b/bash/cartodb/import_tcx.sh @@ -0,0 +1,94 @@ +#!/bin/bash +## + # Import your sport activities from tapiriik.com to cartoco.com. + # + # Prerequisistes: + # - rclone + # - curl + # - jq + # - xsqlproc + # + # @copyright 2021, Steffen Vogel + # @license http://www.gnu.org/licenses/gpl.txt GNU Public License + # @author Steffen Vogel + # @link https://www.steffenvogel.de + ## + +CARTODB_API_KEY=$(pass apis/cartodb) +CARTODB_USER=stv0g +CARTODB_EP="https://${CARTODB_USER}.carto.com/api/v2/sql?api_key=${CARTODB_API_KEY}" + +TCXDIR=~/Tracks + +STYLESHEET=$(mktemp) +JQFILTER=$(mktemp) + +cat << EOF > ${JQFILTER} +if has("error") then + "Error: " + .error[0] +else + "Success: Rows added: " + (.total_rows|tostring) +end +EOF + +cat << EOF > ${STYLESHEET} + + + + + + q=INSERT INTO laps (number, starttime, averageheartratebpm, maximumheartratebpm, calories, distancemeters, intensity, totaltimeseconds, the_geom) VALUES + + + ( + , + TIMESTAMP '', + , + , + , + , + '', + , + ST_SetSRID(ST_GeomFromText('MULTILINESTRING(( + + + + , + + ))'), 4326) + ), + + ; + + + + +EOF + +FILES_BEFORE=$(ls -1 -d ${TCXDIR}/*.tcx) + +echo "##### Starting download from Dropbox #####" +rclone sync drpbx:/Apps/tapiriik/ ${TCXDIR} + +FILES_AFTER=$(ls -1 -d ${TCXDIR}/*.tcx) +FILES_NEW=$(comm -23 <(echo "${FILES_AFTER}") <(echo "${FILES_BEFORE}")) + +echo +echo "##### Starting import to CartoCB / PostGIS #####" +echo "${FILES_NEW}" | while read FILE; do + TEMPFILE=$(mktemp) + + xsltproc -o "${TEMPFILE}" "${STYLESHEET}" "${FILE}" + + printf "%s %-64s" "$(date +'%Y/%m/%d %H:%M:%S')" "$(basename "${FILE}"):" + + if [ -s ${TEMPFILE} ]; then + curl -sSX POST --data @${TEMPFILE} ${CARTODB_EP} | jq -rf ${JQFILTER} + else + echo "Note: There are no trackpoints. Skipped" + fi +done + +rm ${STYLESHEET} ${JQFILTER} diff --git a/bash/cartodb/tcx2gpx.sh b/bash/cartodb/tcx2gpx.sh new file mode 100755 index 0000000..80cc3b8 --- /dev/null +++ b/bash/cartodb/tcx2gpx.sh @@ -0,0 +1,47 @@ +#!/bin/bash +## + # Convert TCX files to GPX + # + # @copyright 2021, Steffen Vogel + # @license http://www.gnu.org/licenses/gpl.txt GNU Public License + # @author Steffen Vogel + # @link https://www.steffenvogel.de + ## + +SRC=${1:-${DROPBOX}/Apps/tapiriik} +DEST=${2:-${DROPBOX}/Apps/cartodb} + +SPORTS="" + +# Convert all TXC into GPX files +for FILE in ${SRC}/*.tcx; do + BASE=$(basename "${FILE// /_}" .tcx) + INPUT="${FILE}" + OUTPUT="${BASE}.gpx" + + SPORT="${BASE##*_}" + SPORT="${SPORT%% *}" + + SPORTS="$SPORTS $SPORT" + + echo "Converting $INPUT to $OUTPUT of Sport $SPORT" + + mkdir -p "${DEST}/${SPORT}" + + ${BABEL} -t -r -w -i gtrnctr -f "${INPUT}" -x track,speed -o gpx -F "${DEST}/${SPORT}/${OUTPUT}" +done + +SPORTS=$(echo $SPORTS | tr ' ' '\n' | sort -u | tr '\n' ' ') + +# Merge all activities per sport +for SPORT in ${SPORTS}; do + FILES="" + + for FILE in ${DEST}/${SPORT}/*.gpx; do + FILES="$FILES -f $FILE" + done + + echo "Merging into $SPORT.gpx" + + ${BABEL} -t -r -w -i gpx ${FILES} -o gpx -F ${DEST}/${SPORT}.gpx +done diff --git a/bash/cronic.sh b/bash/cronic.sh old mode 100644 new mode 100755 diff --git a/bash/crop.sh b/bash/crop.sh new file mode 100755 index 0000000..a07aa92 --- /dev/null +++ b/bash/crop.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +DPI=600 + +for INPUT in $@; do + OUTPUT=${INPUT%.*}_crop.pdf + + WIDTH_PTS=$(identify -density ${DPI} -format "%w" ${INPUT}) + HEIGHT_PTS=$(identify -density ${DPI} -format "%h" ${INPUT}) + + BON_WIDTH_INCH=$(bc <<< "scale=2; 8/2.54") # inch + BON_WIDTH_PTS=$(bc <<< "${BON_WIDTH_INCH} * ${DPI}") + + OFFSET_X_PTS=$(bc <<< "${WIDTH_PTS} / 2 - ${BON_WIDTH_PTS} / 2") + + convert -density ${DPI} -crop "${BON_WIDTH_PTS}x${HEIGHT_PTS}+${OFFSET_X_PTS}+0" +repage -compress JPEG ${INPUT} ${OUTPUT} +done diff --git a/bash/deviantbg.sh b/bash/deviant-bg.sh similarity index 60% rename from bash/deviantbg.sh rename to bash/deviant-bg.sh index d897451..38c913e 100755 --- a/bash/deviantbg.sh +++ b/bash/deviant-bg.sh @@ -2,25 +2,11 @@ ## # Deviant Background Changer # - # @copyright 2012 Steffen Vogel - # @license http://www.gnu.org/licenses/gpl.txt GNU Public License - # @author Steffen Vogel - # @link http://www.steffenvogel.de/2009/11/28/deviantart-wallpapers/ - # @version 1.1 - ## -## - # This script is free software: you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by - # the Free Software Foundation, either version 3 of the License, or - # any later version. - # - # This script is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this script. If not, see . + # @copyright 2021, Steffen Vogel + # @license http://www.gnu.org/licenses/gpl.txt GNU Public License + # @author Steffen Vogel + # @link https://www.steffenvogel.de/2009/11/28/deviantart-wallpapers/ + # @version 1.1 ## # Path to save downloaded images diff --git a/bash/dump.sh b/bash/dump.sh old mode 100644 new mode 100755 diff --git a/bash/dyndns-update.sh b/bash/dyndns-update.sh old mode 100644 new mode 100755 diff --git a/bash/fan-ctl.sh b/bash/fan-ctl.sh old mode 100644 new mode 100755 index 8a0a45b..1777e7b --- a/bash/fan-ctl.sh +++ b/bash/fan-ctl.sh @@ -8,8 +8,8 @@ IPMIHOST=169.254.0.1 IPMIUSER=root -IPMIPW=3LpnMcnY99cybeGM -IPMIEK=6055530028595864123105836429105276020000 +IPMIPW=XXXXX # Please change +IPMIEK=XXXXX # Please change FANSPEEDHEX=${1:-0x08} # See https://i.imgur.com/u1HMyqI.png MAXTEMP=60 @@ -18,15 +18,15 @@ HYSTERESIS=5 FANFILE=/var/run/autofan function ipmi() { - ipmitool -I lanplus -H "$IPMIHOST" -U "$IPMIUSER" -P "$IPMIPW" -y "$IPMIEK" $@ + ipmitool -I lanplus -H "$IPMIHOST" -U "$IPMIUSER" -P "$IPMIPW" -y "$IPMIEK" $@ } # For R710, which doesn't have cpu temps, try this line instead: # if ! TEMPS=$(ipmi sdr type temperature | grep -i inlet | grep -Po '\d{2,3}' 2> /dev/null); # thanks @bumbaclot if ! TEMPS=$(ipmi sdr type temperature | grep -vi inlet | grep -vi exhaust | grep -Po '\d{2,3}' 2> /dev/null); then - echo "FAILED TO READ TEMPERATURE SENSOR!" >&2 - logger -t "fanctl" -p user.err -i "Error: Could not read temperature sensor" + echo "FAILED TO READ TEMPERATURE SENSOR!" >&2 + logger -t "fanctl" -p user.err -i "Error: Could not read temperature sensor" fi HIGHTEMP=0 @@ -35,36 +35,36 @@ LOWTEMP=1 echo "Temps: ${TEMPS}" for TEMP in $TEMPS; do - if [[ $TEMP > $MAXTEMP ]]; then - HIGHTEMP=1 - fi - if [[ $TEMP > $(($MAXTEMP - $HYSTERESIS)) ]]; then - LOWTEMP=0 - fi + if [[ $TEMP > $MAXTEMP ]]; then + HIGHTEMP=1 + fi + if [[ $TEMP > $(($MAXTEMP - $HYSTERESIS)) ]]; then + LOWTEMP=0 + fi done if [[ -r "$FANFILE" ]]; then - AUTO=$(< "$FANFILE") + AUTO=$(< "$FANFILE") else - AUTO=1 + AUTO=1 fi echo "Low: ${LOWTEMP}" echo "High: ${HIGHTEMP}" if [[ $HIGHTEMP == 1 ]]; then - # Automatic fan control - ipmi raw 0x30 0x30 0x01 0x01 >& /dev/null || echo "FAILED TO SET FAN CONTROL MODE" >&2; exit 1 - echo "1" > "$FANFILE" - if [[ $AUTO == 0 ]]; then - logger -t "fanctl" -p user.info -i "Setting fan control to automatic" - fi + # Automatic fan control + ipmi raw 0x30 0x30 0x01 0x01 >& /dev/null || echo "FAILED TO SET FAN CONTROL MODE" >&2; exit 1 + echo "1" > "$FANFILE" + if [[ $AUTO == 0 ]]; then + logger -t "fanctl" -p user.info -i "Setting fan control to automatic" + fi elif [[ $LOWTEMP == 1 ]]; then - # Manual fan control - ipmi raw 0x30 0x30 0x01 0x00 >& /dev/null || echo "FAILED TO SET FAN CONTROL SPEED" >&2 - ipmi raw 0x30 0x30 0x02 0xff "$FANSPEEDHEX" >& /dev/null || echo "FAILED TO SET FAN SPEED" >&2 - echo "0" > "$FANFILE" - if [[ $AUTO == 1 ]]; then - logger -t "fanctl" -p user.info -i "Setting fan control to manual" - fi + # Manual fan control + ipmi raw 0x30 0x30 0x01 0x00 >& /dev/null || echo "FAILED TO SET FAN CONTROL SPEED" >&2 + ipmi raw 0x30 0x30 0x02 0xff "$FANSPEEDHEX" >& /dev/null || echo "FAILED TO SET FAN SPEED" >&2 + echo "0" > "$FANFILE" + if [[ $AUTO == 1 ]]; then + logger -t "fanctl" -p user.info -i "Setting fan control to manual" + fi fi diff --git a/bash/flv2mp4.sh b/bash/flv2mp4.sh deleted file mode 100755 index 0521082..0000000 --- a/bash/flv2mp4.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -ffmpeg -i "$1" -f mp4 -vcodec mpeg4 -maxrate 1000 -b 700 -qmin 3 -qmax 5 -bufsize 4096 -g 300 -acodec aac -ar 44100 -ab 192 -s 320x240 -aspect 4:3 "$1.mp4" diff --git a/bash/geo2gps.sh b/bash/geo2gps.sh deleted file mode 100755 index 0671ae0..0000000 --- a/bash/geo2gps.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -gpsbabel -i geo -f $1 -o garmin -F /dev/ttyS0 diff --git a/bash/get-panoramas.sh b/bash/get-panoramas.sh new file mode 100755 index 0000000..bd71f51 --- /dev/null +++ b/bash/get-panoramas.sh @@ -0,0 +1,27 @@ +#!/bin/bash +## + # Find images taken with little time diff (panoramas) + # + # @copyright 2021, Steffen Vogel + # @license http://www.gnu.org/licenses/gpl.txt GNU Public License + # @author Steffen Vogel + # @link https://www.steffenvogel.de + ## + +MIN_DIFF=5 +LAST_TS=0 + +mkdir panorama + +for i in *.JPG; do + TS=`stat -c %Y $i` + + let DIFF=$TS-$LAST_TS + + if [ "$DIFF" -lt "$MIN_DIFF" ]; then + echo $i + cp $i panorama/$i + fi + + LAST_TS=$TS +done diff --git a/bash/getpanoramas.sh b/bash/getpanoramas.sh deleted file mode 100755 index ca44e84..0000000 --- a/bash/getpanoramas.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -## - # Find images taken with little time diff (panoramas) - # - # @copyright 2012 Steffen Vogel - # @license http://www.gnu.org/licenses/gpl.txt GNU Public License - # @author Steffen Vogel - # @link http://www.steffenvogel.de/ - ## -## - # This script is free software: you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by - # the Free Software Foundation, either version 3 of the License, or - # any later version. - # - # This script is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this script. If not, see . - ## - -MIN_DIFF=5 -LAST_TS=0 - -mkdir panorama - -for i in *.JPG; do - TS=`stat -c %Y $i` - - let DIFF=$TS-$LAST_TS - - if [ "$DIFF" -lt "$MIN_DIFF" ]; then - echo $i - cp $i panorama/$i - fi - - LAST_TS=$TS -done diff --git a/bash/git-svn-relocate.sh b/bash/git-svn-relocate.sh index 66f3515..3848078 100755 --- a/bash/git-svn-relocate.sh +++ b/bash/git-svn-relocate.sh @@ -2,10 +2,9 @@ # Must be called with two command-line args. # Example: git-svn-relocate.sh http://old.server https://new.server -if [ $# -ne 2 ] -then - echo "Please invoke this script with two command-line arguments (old and new SVN URLs)." - exit $E_NO_ARGS +if [ $# -ne 2 ]; then + echo "Please invoke this script with two command-line arguments (old and new SVN URLs)." + exit $E_NO_ARGS fi # Prepare URLs for regex search and replace. diff --git a/bash/git-svn-relocate2.sh b/bash/git-svn-relocate2.sh index 555229e..707e5ac 100755 --- a/bash/git-svn-relocate2.sh +++ b/bash/git-svn-relocate2.sh @@ -7,50 +7,46 @@ # Use at your own risk. For the love of cthulhu, back # your repo up before letting this loose on it. -if [ $# -ne 1 ] -then - echo "Usage: `basename $0` {new subversion url}" - exit -1 +if [ $# -ne 1 ]; then + echo "Usage: `basename $0` {new subversion url}" + exit -1 fi -if [[ $1 = "--help" || $1 = "-h" ]] -then - echo - echo "Usage: `basename $0` {new subversion url}" - echo - echo " Changes the url of the subversion repository a git-svn repo is connected to." - echo " Analogous to svn switch. Potentially a weapon of mass destruction. Use with care." - echo " Run this from within your git repo. You only need one argument: the new url of the svn repo." - echo " git-svn-switch will attempt to verify that the url is at least a svn repo before starting the switch" - echo " but don't depend on it to stop you from doing summat daft." - echo - exit 1 +if [[ $1 = "--help" || $1 = "-h" ]]; then + echo + echo "Usage: `basename $0` {new subversion url}" + echo + echo " Changes the url of the subversion repository a git-svn repo is connected to." + echo " Analogous to svn switch. Potentially a weapon of mass destruction. Use with care." + echo " Run this from within your git repo. You only need one argument: the new url of the svn repo." + echo " git-svn-switch will attempt to verify that the url is at least a svn repo before starting the switch" + echo " but don't depend on it to stop you from doing summat daft." + echo + exit 1 fi # get the current subversion url SRC=`git svn info --url` -if [ -n "$SRC" ] -then - FROM=`echo $SRC | sed "s|/trunk||"` - REPO=`svn info $1` - echo "Checking $REPO is actually a subversion repository..." - if [ -n "$REPO" ] - then - echo "The new URL looks valid." - echo "Rewriting the git history with the new url..." - SED_FILTER="sed 's;git-svn-id: "$FROM";git-svn-id: "$1";g'" - git gc - git filter-branch --msg-filter "$SED_FILTER" $(cat .git/packed-refs | awk '// {print $2}' | grep -v 'pack-refs') +if [ -n "$SRC" ]; then + FROM=`echo $SRC | sed "s|/trunk||"` + REPO=`svn info $1` + echo "Checking $REPO is actually a subversion repository..." + if [ -n "$REPO" ]; then + echo "The new URL looks valid." + echo "Rewriting the git history with the new url..." + SED_FILTER="sed 's;git-svn-id: "$FROM";git-svn-id: "$1";g'" + git gc + git filter-branch --msg-filter "$SED_FILTER" $(cat .git/packed-refs | awk '// {print $2}' | grep -v 'pack-refs') #Couple of pointless checkouts - on some repos the log changes seem to need flushing by an operation like this - git checkout trunk - git checkout master - echo "Rebuild git-svn internals and updating the repo" - rm -rf .git/svn - sed -i~ 's|'$FROM'|'$1'|g' .git/config - git svn rebase - else - echo "Error: $1 Does not appear to be a subversion repository." - fi + git checkout trunk + git checkout master + echo "Rebuild git-svn internals and updating the repo" + rm -rf .git/svn + sed -i~ 's|'$FROM'|'$1'|g' .git/config + git svn rebase + else + echo "Error: $1 Does not appear to be a subversion repository." + fi else - echo "Error: This doesn't appear to be a git working directory, or it's a git repo that hasn't been created using a git-svn bridge" + echo "Error: This doesn't appear to be a git working directory, or it's a git repo that hasn't been created using a git-svn bridge" fi diff --git a/bash/gps2gpx.sh b/bash/gps2gpx.sh deleted file mode 100755 index 3ef22ce..0000000 --- a/bash/gps2gpx.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -gpsbabel -t -i garmin -f /dev/ttyS0 -o gpx -F /home/steffen/Desktop/track.gpx diff --git a/bash/gps2pc.sh b/bash/gps2pc.sh deleted file mode 100755 index d1d74a7..0000000 --- a/bash/gps2pc.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -gpsbabel -w -t -r -i garmin -f /dev/ttyS0 -o kml -F /home/steffen/.googleearth/gps2pc.kml diff --git a/bash/hetzer_sb_notify.sh b/bash/hetzer_sb_notify.sh deleted file mode 100755 index 9ef3feb..0000000 --- a/bash/hetzer_sb_notify.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -FILTER=$(mktemp) - -cat > ${FILTER} <= 3000 and - .ram >= 32 and - .bandwith >= 1000 and - .traffic == "unlimited" and - .cpu_benchmark >= 9000 and - (.setup_price | tonumber) == 0 and - (.price | tonumber) <= 50 and - (.specials | map(ascii_downcase ) | index("ssd")) - ) - ) | - sort_by(.price | tonumber) | reverse -EOF - -curl https://www.hetzner.de/a_hz_serverboerse/live_data.json | jq -f $FILTER diff --git a/bash/ip-rule-restore.sh b/bash/ip-rule-restore.sh old mode 100644 new mode 100755 index e3ed51c..e4f2e36 --- a/bash/ip-rule-restore.sh +++ b/bash/ip-rule-restore.sh @@ -16,13 +16,13 @@ for V in -4 -6; do $IPR flush ip $V route flush table default - if [ $V == -4 ]; then - ip $V route add 141.98.136.128/29 dev ${GW_IF} table default - ip $V route add default via 141.98.136.129 table default - else - ip $V route add 2a09:11c0:f0:bbf0::/64 dev ${GW_IF} table default - ip $V route add default via 2a09:11c0:f0:bbf0::1 dev ${GW_IF} src 2a09:11c0:f0:bbf0::3 table default - fi + if [ $V == -4 ]; then + ip $V route add 141.98.136.128/29 dev ${GW_IF} table default + ip $V route add default via 141.98.136.129 table default + else + ip $V route add 2a09:11c0:f0:bbf0::/64 dev ${GW_IF} table default + ip $V route add default via 2a09:11c0:f0:bbf0::1 dev ${GW_IF} src 2a09:11c0:f0:bbf0::3 table default + fi $IPR add pref 200 not fwmark 0x1000 lookup main $IPR add pref 240 not fwmark 0x1001 lookup dn42 diff --git a/bash/ipodvideo.sh b/bash/ipodvideo.sh deleted file mode 100755 index a974056..0000000 --- a/bash/ipodvideo.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -ffmpeg -i "$1" -f mp4 -vcodec mpeg4 -maxrate 1000 -b 700 -qmin 3 -qmax 5 -bufsize 4096 -g 300 -acodec aac -ar 44100 -ab 192 -s 320x240 -aspect 4:3 $2 diff --git a/bash/luks-open.sh b/bash/luks-open.sh old mode 100644 new mode 100755 diff --git a/bash/m4a2mp3.sh b/bash/m4a2mp3.sh deleted file mode 100755 index 5c9390a..0000000 --- a/bash/m4a2mp3.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -for i in *.m4a; do - echo "Converting: ${i%.m4a}.mp3" - faad -o - "$i" | lame - "${i%.m4a}.mp3" -done diff --git a/bash/mountl2p.sh b/bash/mount.l2p.sh similarity index 68% rename from bash/mountl2p.sh rename to bash/mount.l2p.sh index 5d1ba03..d11ce89 100755 --- a/bash/mountl2p.sh +++ b/bash/mount.l2p.sh @@ -2,24 +2,10 @@ ## # Mount MS Sharepoint folders of the RWTH L²P System in gvfs # - # @copyright 2012 Steffen Vogel - # @license http://www.gnu.org/licenses/gpl.txt GNU Public License - # @author Steffen Vogel - # @link http://www.steffenvogel.de/ - ## -## - # This script is free software: you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by - # the Free Software Foundation, either version 3 of the License, or - # any later version. - # - # This script is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this script. If not, see . + # @copyright 2021, Steffen Vogel + # @license http://www.gnu.org/licenses/gpl.txt GNU Public License + # @author Steffen Vogel + # @link https://www.steffenvogel.de ## function usage { diff --git a/bash/mount.luks.sh b/bash/mount.luks.sh index 334ea38..a7e9171 100755 --- a/bash/mount.luks.sh +++ b/bash/mount.luks.sh @@ -26,10 +26,10 @@ # followed by: # mount /home # - # @copyright 2013 Steffen Vogel - # @license http://www.gnu.org/licenses/gpl.txt GNU Public License - # @author Steffen Vogel - # @link http://www.steffenvogel.de + # @copyright 2021, Steffen Vogel + # @license http://www.gnu.org/licenses/gpl.txt GNU Public License + # @author Steffen Vogel + # @link https://www.steffenvogel.de ## if [ "$(basename $0)" == "mount.luks" ]; then @@ -39,9 +39,9 @@ if [ "$(basename $0)" == "mount.luks" ]; then shift 2 OPTS=$@ - UUID=$(cryptsetup luksUUID $DEV) - if [ $? -ne 0 ]; then - echo -e "$DEV is not a LUKS device" + UUID=$(cryptsetup luksUUID $DEV) + if [ $? -ne 0 ]; then + echo -e "$DEV is not a LUKS device" exit 1 fi @@ -61,9 +61,9 @@ elif [ "$(basename $0)" == "umount.luks" ]; then shift OPTS=$@ - umount -i $OPTS $DEV - # NOTE: The umount option '-i' is essentially required. It skips this - # helper script which would cause otherwise an endless self recursion + umount -i $OPTS $DEV + # NOTE: The umount option '-i' is essentially required. It skips this + # helper script which would cause otherwise an endless self recursion cryptsetup luksClose $UUID fi diff --git a/bash/mousewheel.sh b/bash/mousewheel.sh deleted file mode 100755 index acb116d..0000000 --- a/bash/mousewheel.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -xinput set-int-prop "Logitech USB Trackball" "Wheel Emulation" 8 1 -xinput set-int-prop "Logitech USB Trackball" "Wheel Emulation Button" 8 8 -xinput set-int-prop "Logitech USB Trackball" "Wheel Emulation Timeout" 16 200 -xinput set-int-prop "Logitech USB Trackball" "Wheel Emulation X Axis" 8 6 7 -xinput set-int-prop "Logitech USB Trackball" "Wheel Emulation Y Axis" 8 4 5 diff --git a/bash/netdev.sh b/bash/netdev.sh deleted file mode 100755 index 3a0ea94..0000000 --- a/bash/netdev.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -sudo /etc/init.d/apache2 restart -sudo /etc/init.d/mysql restart -firefox -new-tab http://localhost/workspace/ & -cd ~/workspace/ diff --git a/bash/nsupdate-dhclient-exit-hook.sh b/bash/nsupdate-dhclient-exit-hook.sh index 5a1b771..dd8e23f 100755 --- a/bash/nsupdate-dhclient-exit-hook.sh +++ b/bash/nsupdate-dhclient-exit-hook.sh @@ -18,8 +18,8 @@ host=wg.0l.de server=127.0.0.1 case $reason in - BOUND|RENEW|REBIND|TIMEOUT) - $NS update -d $new_ip_address -k $key -z $zone -n $server -i $interface $host ;; - RELEASE) - $NS delete -d $old_ip_address -k $key -z $zone -n $server $host ;; + BOUND|RENEW|REBIND|TIMEOUT) + $NS update -d $new_ip_address -k $key -z $zone -n $server -i $interface $host ;; + RELEASE) + $NS delete -d $old_ip_address -k $key -z $zone -n $server $host ;; esac diff --git a/bash/nsupdate.sh b/bash/nsupdate.sh index 2844984..7f300c0 100755 --- a/bash/nsupdate.sh +++ b/bash/nsupdate.sh @@ -2,7 +2,12 @@ ## # Bind9 nsupdate wrapper # + # @copyright 2013, Andrew Leonard + # @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 + # @author Andrew Leonard + # @author Steffen Vogel # @link https://www.steffenvogel.de + ## function usage { @@ -65,7 +70,7 @@ shift $((OPTIND-1)) # parsing host if [ -n "$1" ]; then - HOST=$1 + HOST=$1 else echo -e "missing host" echo diff --git a/bash/panel.sh b/bash/panel.sh deleted file mode 100755 index 0a9e444..0000000 --- a/bash/panel.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -if [ `gconftool --get /apps/panel/toplevels/bottom_panel_screen0/monitor` == 1 ]; then - gconftool --type int --set /apps/panel/toplevels/bottom_panel_screen0/monitor 0 -else - gconftool --type int --set /apps/panel/toplevels/bottom_panel_screen0/monitor 1 -fi - -if [ `gconftool --get /apps/panel/toplevels/top_panel_screen0/monitor` == 1 ]; then - gconftool --type int --set /apps/panel/toplevels/top_panel_screen0/monitor 0 -else - gconftool --type int --set /apps/panel/toplevels/top_panel_screen0/monitor 1 -fi - -if [ `gconftool --get /apps/panel/toplevels/panel_0/monitor` == 1 ]; then - gconftool --type int --set /apps/panel/toplevels/panel_0/monitor 0 -else - gconftool --type int --set /apps/panel/toplevels/panel_0/monitor 1 -fi diff --git a/bash/pc2gps.sh b/bash/pc2gps.sh deleted file mode 100755 index 0fd1e4e..0000000 --- a/bash/pc2gps.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -gpsbabel -w -t -r -i kml -f /home/steffen/.googleearth/pc2gps.kml -o garmin -F /dev/ttyS0 diff --git a/bash/presentation.sh b/bash/presentation.sh deleted file mode 100755 index 061ff05..0000000 --- a/bash/presentation.sh +++ /dev/null @@ -1,5 +0,0 @@ -#/bin/bash - -gksudo modprobe uinput -wminput -c /etc/cwiid/wminput/presentation & -openoffice.org -show /home/steffen/Schule/Informatik/Künstliche\ Intelligenz/Künstliche\ Intelligenz.odp diff --git a/bash/recursive-axfr.sh b/bash/recursive-axfr.sh deleted file mode 100644 index 3a05c7e..0000000 --- a/bash/recursive-axfr.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -## - # Perform resursive AXFR queries to fetch all hostnames of a zone - # - # @copyright 2021, Steffen Vogel - # @license http://www.gnu.org/licenses/gpl.txt GNU Public License - # @author Steffen Vogel - # @link https://www.steffenvogel.de - ## - -print_hosts() { - ZONE=$1; shift 1 - OPTS="$@" - - SUBZONES="" - HOSTS="" - - IFS=$'\n' - RECORDS=$(dig +nocmd $ZONE axfr +noall +answer ${OPTS}) - for RECORD in ${RECORDS}; do - NAME=$(echo ${RECORD} | tr -s '\t ' '\t' | cut -f1) - TYPE=$(echo ${RECORD} | tr -s '\t ' '\t' | cut -f4) - - if [ -z "${NAME}" -o "${NAME}" == *'*'* ]; then - continue - fi - - case ${TYPE} in - NS) SUBZONES="${SUBZONES} ${NAME}" ;; - A|AAAA|CNAME) HOSTS="${NAME} ${HOSTS}" ;; - esac - done - - UNIQUE_SUBZONES=$(echo ${SUBZONES} | tr ' ' '\n' | sort -u) - for SUBZONE in ${UNIQUE_SUBZONES}; do - if [ ${SUBZONE} != ${ZONE} ]; then - HOSTS="$(print_hosts ${SUBZONE}) ${HOSTS}" - fi - done - - UNIQUE_HOSTS=$(echo ${HOSTS} | tr ' ' '\n' | sort -u) - for HOST in ${UNIQUE_HOSTS}; do - echo ${HOST%.} - done -} - -print_hosts $@ diff --git a/bash/restic-btrfs-snapshots.sh b/bash/restic-btrfs-snapshots.sh old mode 100644 new mode 100755 diff --git a/bash/sep.sh b/bash/sep.sh new file mode 100755 index 0000000..d6949a9 --- /dev/null +++ b/bash/sep.sh @@ -0,0 +1,8 @@ +#!/bin/bash + + +for file in *.PDF; do + name=$(basename -s .PDF $file) + + pdfseparate $file "$name-%d.pdf" +done diff --git a/bash/smart-read.sh b/bash/smart-read.sh old mode 100644 new mode 100755 diff --git a/bash/update-roa.sh b/bash/update-roa.sh old mode 100644 new mode 100755 diff --git a/bash/update-xmltv.sh b/bash/update-xmltv.sh old mode 100644 new mode 100755 diff --git a/bash/uptime.sh b/bash/uptime.sh deleted file mode 100755 index a3cebfd..0000000 --- a/bash/uptime.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -### BEGIN INIT INFO -# Provides: uptime -# Required-Start: $remote_fs -# Required-Stop: $remote_fs -# Default-Stop: 0 1 6 -# Short-Description: Log uptime of server before shutdown -### END INIT INFO - -echo $(date +%s) $(cat /proc/uptime) >> /var/log/uptime.log diff --git a/bash/virsh-start-all.sh b/bash/virsh-all.sh old mode 100644 new mode 100755 similarity index 63% rename from bash/virsh-start-all.sh rename to bash/virsh-all.sh index f10f8c4..791add9 --- a/bash/virsh-start-all.sh +++ b/bash/virsh-all.sh @@ -1,13 +1,15 @@ #!/bin/bash ## - # Start all libvirt VMs + # Perform an action for all libvirt VMs # # @copyright 2021, Steffen Vogel # @license http://www.gnu.org/licenses/gpl.txt GNU Public License # @author Steffen Vogel - # @link http://www.steffenvogel.de + # @link https://www.steffenvogel.de ## + ACTION=${ACTION:-start} + for VM in $(virsh list --inactive --name); do - virsh start ${VM} + virsh ${ACTION} ${VM} done diff --git a/bash/wakeonlan.sh b/bash/wake-on-lan.sh similarity index 52% rename from bash/wakeonlan.sh rename to bash/wake-on-lan.sh index 122d5ee..42b9807 100755 --- a/bash/wakeonlan.sh +++ b/bash/wake-on-lan.sh @@ -4,24 +4,10 @@ # # includes MAC lookup via DNS and ARP # - # @copyright 2012 Steffen Vogel - # @license http://www.gnu.org/licenses/gpl.txt GNU Public License - # @author Steffen Vogel - # @link http://www.steffenvogel.de/ - ## -## - # This script is free software: you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by - # the Free Software Foundation, either version 3 of the License, or - # any later version. - # - # This script is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this script. If not, see . + # @copyright 2021, Steffen Vogel + # @license http://www.gnu.org/licenses/gpl.txt GNU Public License + # @author Steffen Vogel + # @link https://www.steffenvogel.de/ ## IP_REGEX="[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}" diff --git a/bash/zfs-load-keys.sh b/bash/zfs-load-keys.sh old mode 100644 new mode 100755 index 4986a72..119ff7c --- a/bash/zfs-load-keys.sh +++ b/bash/zfs-load-keys.sh @@ -13,13 +13,13 @@ IFS=" " for dataset in $(zfs list -H -p -o name,encryptionroot | \ - awk -F "\t" '{if ($1 == $2) { print $1 }}') + awk -F "\t" '{if ($1 == $2) { print $1 }}') do - if [ "$(zfs get -H -p -o value keylocation "$dataset")" = "prompt" ] && - [ "$(zfs get -H -p -o value keystatus "$dataset")" = "unavailable" ] - then - systemd-ask-password --id="zfs:$dataset" \ - "Enter passphrase for '$dataset':" | \ - zfs load-key "$dataset" - fi + if [ "$(zfs get -H -p -o value keylocation "$dataset")" = "prompt" ] && + [ "$(zfs get -H -p -o value keystatus "$dataset")" = "unavailable" ] + then + systemd-ask-password --id="zfs:$dataset" \ + "Enter passphrase for '$dataset':" | \ + zfs load-key "$dataset" + fi done diff --git a/bash/zyxel.sh b/bash/zyxel.sh index fcedc4d..1c66eb7 100755 --- a/bash/zyxel.sh +++ b/bash/zyxel.sh @@ -10,12 +10,12 @@ IP=192.168.1.1 USER=admin - -# change password here -#PW= +PW=XXXXX # Change me OLD_IP=`wget http://checkip.dyndns.org/ -O /dev/stdout 2>/dev/null | sed "s/.*Current IP Address: \([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/"` echo "Alte IP: $OLD_IP" + curl http://$USER:$PW@$IP/Forms/DiagADSL_1 -d "LineInfoDisplay=&DiagDSLDisconnect=PPPoE+Trennung" + NEW_IP=`wget http://checkip.dyndns.org/ -O /dev/stdout 2>/dev/null | sed "s/.*Current IP Address: \([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/"` echo "Neue IP: $NEW_IP"