From e4596cf76bfd9a06f43737d0582decf87a5a8424 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 001/120] =?UTF-8?q?D=C3=A9placemets=20des=20scripts=20en?= =?UTF-8?q?=20dossier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Perso: -Script de sauvegarde des paquets [Anciennement dossier TSP] --- Perso/package_save.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 Perso/package_save.sh diff --git a/Perso/package_save.sh b/Perso/package_save.sh new file mode 100755 index 0000000..856e69a --- /dev/null +++ b/Perso/package_save.sh @@ -0,0 +1,33 @@ +#! /bin/bash + +if [ $# -eq 0 ]; then + name=packages_state +else + name=$1 +fi + + +pathName="$name""_$(date +'%Y-%m-%d @ %Hh%M')" + +mkdir "$pathName" +cd "./$pathName" +mkdir "./preferences.d" + +cp /etc/apt/sources.list . +cp /etc/apt/preferences.d/my_preferences ./preferences.d/ + +sudo dpkg --get-selections > "manual_package_save" + +a=TEM.sh + +echo "#! /bin/bash" > $a +echo "" >> $a +echo "cd .." >> $a +echo "rm -r \"$pathName\"" >> $a + +chmod u+x "$a" + +cd - + +exit + From 31a5155f78385f67420ab60f8feafdeb1d06461f Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 19 Nov 2017 15:22:42 +0100 Subject: [PATCH 002/120] =?UTF-8?q?D=C3=A9placemets=20des=20scripts=20en?= =?UTF-8?q?=20dossier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Perso: -Script de sauvegarde des paquets [Anciennement dossier TSP] --- Perso/package_save.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 Perso/package_save.sh diff --git a/Perso/package_save.sh b/Perso/package_save.sh new file mode 100755 index 0000000..856e69a --- /dev/null +++ b/Perso/package_save.sh @@ -0,0 +1,33 @@ +#! /bin/bash + +if [ $# -eq 0 ]; then + name=packages_state +else + name=$1 +fi + + +pathName="$name""_$(date +'%Y-%m-%d @ %Hh%M')" + +mkdir "$pathName" +cd "./$pathName" +mkdir "./preferences.d" + +cp /etc/apt/sources.list . +cp /etc/apt/preferences.d/my_preferences ./preferences.d/ + +sudo dpkg --get-selections > "manual_package_save" + +a=TEM.sh + +echo "#! /bin/bash" > $a +echo "" >> $a +echo "cd .." >> $a +echo "rm -r \"$pathName\"" >> $a + +chmod u+x "$a" + +cd - + +exit + From d8a92b5c9c365de78c55720432a448d6ad35bc5a Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 003/120] Update de la save pour prendre en compte les listes secondaires --- Perso/package_save.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Perso/package_save.sh b/Perso/package_save.sh index 856e69a..edacc48 100755 --- a/Perso/package_save.sh +++ b/Perso/package_save.sh @@ -15,10 +15,11 @@ mkdir "./preferences.d" cp /etc/apt/sources.list . cp /etc/apt/preferences.d/my_preferences ./preferences.d/ +cp -r --copy-contents /etc/apt/sources.list.d . sudo dpkg --get-selections > "manual_package_save" -a=TEM.sh +a=C4.sh echo "#! /bin/bash" > $a echo "" >> $a From 46c6dfc830860843b7724e9a9400b7c9854829bd Mon Sep 17 00:00:00 2001 From: trotFunky Date: Tue, 21 Nov 2017 22:01:17 +0100 Subject: [PATCH 004/120] Update de la save pour prendre en compte les listes secondaires --- Perso/package_save.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Perso/package_save.sh b/Perso/package_save.sh index 856e69a..edacc48 100755 --- a/Perso/package_save.sh +++ b/Perso/package_save.sh @@ -15,10 +15,11 @@ mkdir "./preferences.d" cp /etc/apt/sources.list . cp /etc/apt/preferences.d/my_preferences ./preferences.d/ +cp -r --copy-contents /etc/apt/sources.list.d . sudo dpkg --get-selections > "manual_package_save" -a=TEM.sh +a=C4.sh echo "#! /bin/bash" > $a echo "" >> $a From a6d33b2c1a597f2ed2b77545c0424940a4b40f7e Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 005/120] =?UTF-8?q?Ajout=20de=20quoi=20g=C3=A9rer=20l'appe?= =?UTF-8?q?l=20au=20script=20depuis=20n'importe=20o=C3=B9=20de=20mani?= =?UTF-8?q?=C3=A8re=20contr=C3=B4l=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/package_save.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Perso/package_save.sh b/Perso/package_save.sh index edacc48..aadb344 100755 --- a/Perso/package_save.sh +++ b/Perso/package_save.sh @@ -1,12 +1,21 @@ #! /bin/bash -if [ $# -eq 0 ]; then - name=packages_state -else - name=$1 +name=packages_state +location="$HOME/SYS_SAVES/" + +if [ $# -ne 0 ]; then + if [ ! -z "$1" -a "$1" != "here" ]; then + name=$1 + fi + if [ "$2" = here -o "$1" = here ]; then + location="." + elif [ ! -z "$2" ]; then + echo "Second argument can be void or 'here' only" + exit + fi fi - +cd $location pathName="$name""_$(date +'%Y-%m-%d @ %Hh%M')" mkdir "$pathName" From ca2bf3eba1b8d46cc561171060cbc90f6317c57d Mon Sep 17 00:00:00 2001 From: trotFunky Date: Tue, 21 Nov 2017 23:23:43 +0100 Subject: [PATCH 006/120] =?UTF-8?q?Ajout=20de=20quoi=20g=C3=A9rer=20l'appe?= =?UTF-8?q?l=20au=20script=20depuis=20n'importe=20o=C3=B9=20de=20mani?= =?UTF-8?q?=C3=A8re=20contr=C3=B4l=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/package_save.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Perso/package_save.sh b/Perso/package_save.sh index edacc48..aadb344 100755 --- a/Perso/package_save.sh +++ b/Perso/package_save.sh @@ -1,12 +1,21 @@ #! /bin/bash -if [ $# -eq 0 ]; then - name=packages_state -else - name=$1 +name=packages_state +location="$HOME/SYS_SAVES/" + +if [ $# -ne 0 ]; then + if [ ! -z "$1" -a "$1" != "here" ]; then + name=$1 + fi + if [ "$2" = here -o "$1" = here ]; then + location="." + elif [ ! -z "$2" ]; then + echo "Second argument can be void or 'here' only" + exit + fi fi - +cd $location pathName="$name""_$(date +'%Y-%m-%d @ %Hh%M')" mkdir "$pathName" From cf6cfe9c392a4534aeaf78085057fa0381cb3b54 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 007/120] =?UTF-8?q?Script=20pour=20chopper=20l'output=20de?= =?UTF-8?q?=20la=20s=C3=A9rie=20et=20les=20foutre=20sous=20tableau?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 Perso/serialToCSV.sh diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh new file mode 100755 index 0000000..aadd5df --- /dev/null +++ b/Perso/serialToCSV.sh @@ -0,0 +1,13 @@ +#! /bin/bash + +stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok + +rm -f ./serialOutput/serialOutput.csv +touch ./serialOutput/serialOutput.csv + +while true; do + read line < /dev/ttyACM0 + echo $line >> ./serialOutput/serialOutput.csv +done + +python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py \ No newline at end of file From 249d3941d6b12b894689e4cae0a9b1796193db2c Mon Sep 17 00:00:00 2001 From: trotFunky Date: Tue, 12 Dec 2017 23:04:56 +0100 Subject: [PATCH 008/120] =?UTF-8?q?Script=20pour=20chopper=20l'output=20de?= =?UTF-8?q?=20la=20s=C3=A9rie=20et=20les=20foutre=20sous=20tableau?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 Perso/serialToCSV.sh diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh new file mode 100755 index 0000000..aadd5df --- /dev/null +++ b/Perso/serialToCSV.sh @@ -0,0 +1,13 @@ +#! /bin/bash + +stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok + +rm -f ./serialOutput/serialOutput.csv +touch ./serialOutput/serialOutput.csv + +while true; do + read line < /dev/ttyACM0 + echo $line >> ./serialOutput/serialOutput.csv +done + +python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py \ No newline at end of file From d4d89d6eca3986d8311e04c59021b5eb2784c473 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 009/120] =?UTF-8?q?Script=20qui=20allume=20bien=20python?= =?UTF-8?q?=20apr=C3=A8s=20parce=20que=20c'est=20quand=20m=C3=AAme=20foutr?= =?UTF-8?q?ement=20plus=20pratique?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index aadd5df..c5778c2 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -1,13 +1,17 @@ #! /bin/bash +trap "boucle=false" INT +trap "boucle=false" TERM +boucle=true + stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok rm -f ./serialOutput/serialOutput.csv touch ./serialOutput/serialOutput.csv -while true; do +while $boucle; do read line < /dev/ttyACM0 echo $line >> ./serialOutput/serialOutput.csv -done +done python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py \ No newline at end of file From 72ade7d68941caa247ebe22a54e8b066aa6eb91a Mon Sep 17 00:00:00 2001 From: trotFunky Date: Wed, 13 Dec 2017 17:05:03 +0100 Subject: [PATCH 010/120] =?UTF-8?q?Script=20qui=20allume=20bien=20python?= =?UTF-8?q?=20apr=C3=A8s=20parce=20que=20c'est=20quand=20m=C3=AAme=20foutr?= =?UTF-8?q?ement=20plus=20pratique?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index aadd5df..c5778c2 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -1,13 +1,17 @@ #! /bin/bash +trap "boucle=false" INT +trap "boucle=false" TERM +boucle=true + stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok rm -f ./serialOutput/serialOutput.csv touch ./serialOutput/serialOutput.csv -while true; do +while $boucle; do read line < /dev/ttyACM0 echo $line >> ./serialOutput/serialOutput.csv -done +done python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py \ No newline at end of file From bdbbdd81b8cf9cbe3453b1a61bd1933255364023 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 011/120] Script qui modifie le nom pour direct avoir les PID --- Perso/serialToCSV.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index c5778c2..0e810d4 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -6,12 +6,18 @@ boucle=true stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok -rm -f ./serialOutput/serialOutput.csv -touch ./serialOutput/serialOutput.csv +if [ $# -eq 3 ]; then + fileName="./serialOutput/serialOutput-"$1","$2","$3".csv" +else + fileName="./serialOutput/serialOutput.csv" +fi + +rm -f $fileName +touch $fileName while $boucle; do read line < /dev/ttyACM0 - echo $line >> ./serialOutput/serialOutput.csv + echo $line >> $fileName done -python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py \ No newline at end of file +python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 \ No newline at end of file From ae64313eced3acff0698647d37042ac32c852795 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Wed, 13 Dec 2017 17:33:02 +0100 Subject: [PATCH 012/120] Script qui modifie le nom pour direct avoir les PID --- Perso/serialToCSV.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index c5778c2..0e810d4 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -6,12 +6,18 @@ boucle=true stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok -rm -f ./serialOutput/serialOutput.csv -touch ./serialOutput/serialOutput.csv +if [ $# -eq 3 ]; then + fileName="./serialOutput/serialOutput-"$1","$2","$3".csv" +else + fileName="./serialOutput/serialOutput.csv" +fi + +rm -f $fileName +touch $fileName while $boucle; do read line < /dev/ttyACM0 - echo $line >> ./serialOutput/serialOutput.csv + echo $line >> $fileName done -python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py \ No newline at end of file +python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 \ No newline at end of file From 1cfd633f2de4715ea7a0115f0a87cc518b87a489 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 013/120] Scripts de son au boot --- Perso/bootSound | 43 +++++++++++++++++++++++++++++++++++ Perso/bootSound.sh | 5 ++++ Perso/serialOutput/.gitignore | 1 + 3 files changed, 49 insertions(+) create mode 100755 Perso/bootSound create mode 100755 Perso/bootSound.sh create mode 100644 Perso/serialOutput/.gitignore diff --git a/Perso/bootSound b/Perso/bootSound new file mode 100755 index 0000000..71fc806 --- /dev/null +++ b/Perso/bootSound @@ -0,0 +1,43 @@ +#! /bin/sh +# /etc/init.d/bootSound + +#A mettre dans le dossier ci-dessus pour que ça se lance pendant le boot + +### BEGIN INIT INFO +# Provides: bootSound +# Required-Start: $gdm3 $dbus $PackageKit +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start up sound +# Description: The above +### END INIT INFO + +case "$1" in + start) + pulseaudio & + sleep 1 + echo "My man it is $(date)" + mplayer -nogui -softvol -ao alsa,pulse /home/trotfunky/Documents/Sounds/winxp.mp3 & + wait %2 + killall pulseaudio + ;; + stop) + exit 0 + ;; + restart) + exit 0 + ;; + force-reload) + exit 0 + ;; + status) + exit 0 + ;; + *) + echo "Well you done fucked up" + exit 1 + ;; +esac + +exit 0 diff --git a/Perso/bootSound.sh b/Perso/bootSound.sh new file mode 100755 index 0000000..cb0cf89 --- /dev/null +++ b/Perso/bootSound.sh @@ -0,0 +1,5 @@ +#! /bin/sh + +mplayer -nogui -softvol -ao alsa,pulse /home/trotfunky/Documents/Sounds/winxp.mp3 & + +exit 0 \ No newline at end of file diff --git a/Perso/serialOutput/.gitignore b/Perso/serialOutput/.gitignore new file mode 100644 index 0000000..5c87cb1 --- /dev/null +++ b/Perso/serialOutput/.gitignore @@ -0,0 +1 @@ +serialOutput* From b2b27b84cc975d2584547fd430dfafef9e28512a Mon Sep 17 00:00:00 2001 From: trotFunky Date: Wed, 27 Dec 2017 18:07:32 +0100 Subject: [PATCH 014/120] Scripts de son au boot --- Perso/bootSound | 43 +++++++++++++++++++++++++++++++++++ Perso/bootSound.sh | 5 ++++ Perso/serialOutput/.gitignore | 1 + 3 files changed, 49 insertions(+) create mode 100755 Perso/bootSound create mode 100755 Perso/bootSound.sh create mode 100644 Perso/serialOutput/.gitignore diff --git a/Perso/bootSound b/Perso/bootSound new file mode 100755 index 0000000..71fc806 --- /dev/null +++ b/Perso/bootSound @@ -0,0 +1,43 @@ +#! /bin/sh +# /etc/init.d/bootSound + +#A mettre dans le dossier ci-dessus pour que ça se lance pendant le boot + +### BEGIN INIT INFO +# Provides: bootSound +# Required-Start: $gdm3 $dbus $PackageKit +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start up sound +# Description: The above +### END INIT INFO + +case "$1" in + start) + pulseaudio & + sleep 1 + echo "My man it is $(date)" + mplayer -nogui -softvol -ao alsa,pulse /home/trotfunky/Documents/Sounds/winxp.mp3 & + wait %2 + killall pulseaudio + ;; + stop) + exit 0 + ;; + restart) + exit 0 + ;; + force-reload) + exit 0 + ;; + status) + exit 0 + ;; + *) + echo "Well you done fucked up" + exit 1 + ;; +esac + +exit 0 diff --git a/Perso/bootSound.sh b/Perso/bootSound.sh new file mode 100755 index 0000000..cb0cf89 --- /dev/null +++ b/Perso/bootSound.sh @@ -0,0 +1,5 @@ +#! /bin/sh + +mplayer -nogui -softvol -ao alsa,pulse /home/trotfunky/Documents/Sounds/winxp.mp3 & + +exit 0 \ No newline at end of file diff --git a/Perso/serialOutput/.gitignore b/Perso/serialOutput/.gitignore new file mode 100644 index 0000000..5c87cb1 --- /dev/null +++ b/Perso/serialOutput/.gitignore @@ -0,0 +1 @@ +serialOutput* From d991f9328ded57f4615102935a4fb6ff41408836 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 015/120] =?UTF-8?q?Modification=20de=20l'interruption=20po?= =?UTF-8?q?ur=20que=20=C3=A7a=20marche=20en=20fait?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 0e810d4..93e9790 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -1,7 +1,7 @@ #! /bin/bash -trap "boucle=false" INT -trap "boucle=false" TERM +trap "boucle=false ; python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" INT +trap "boucle=false ; python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" TERM boucle=true stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok @@ -18,6 +18,4 @@ touch $fileName while $boucle; do read line < /dev/ttyACM0 echo $line >> $fileName -done - -python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 \ No newline at end of file +done \ No newline at end of file From 606b4f5b1932974495641cb5281c3023efb4ac5d Mon Sep 17 00:00:00 2001 From: trotFunky Date: Thu, 11 Jan 2018 01:59:16 +0100 Subject: [PATCH 016/120] =?UTF-8?q?Modification=20de=20l'interruption=20po?= =?UTF-8?q?ur=20que=20=C3=A7a=20marche=20en=20fait?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 0e810d4..93e9790 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -1,7 +1,7 @@ #! /bin/bash -trap "boucle=false" INT -trap "boucle=false" TERM +trap "boucle=false ; python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" INT +trap "boucle=false ; python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" TERM boucle=true stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok @@ -18,6 +18,4 @@ touch $fileName while $boucle; do read line < /dev/ttyACM0 echo $line >> $fileName -done - -python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 \ No newline at end of file +done \ No newline at end of file From 084419820d0d3fe17a01eb3bc76f56d219501e05 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 017/120] Prise en comtpe de la fin de transmission Proprification de la boucle infinie --- Perso/serialToCSV.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 93e9790..97f99c6 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -1,8 +1,7 @@ #! /bin/bash -trap "boucle=false ; python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" INT -trap "boucle=false ; python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" TERM -boucle=true +trap "python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" INT +trap "python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" TERM stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok @@ -15,7 +14,13 @@ fi rm -f $fileName touch $fileName -while $boucle; do +while true; do read line < /dev/ttyACM0 echo $line >> $fileName -done \ No newline at end of file + case "$line" in + *"DATAEND"*) + break;; + esac +done + +python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 \ No newline at end of file From 2df6441ec31b032f3e003dbadde2d0189ab0ce4f Mon Sep 17 00:00:00 2001 From: trotFunky Date: Thu, 11 Jan 2018 16:25:23 +0100 Subject: [PATCH 018/120] Prise en comtpe de la fin de transmission Proprification de la boucle infinie --- Perso/serialToCSV.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 93e9790..97f99c6 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -1,8 +1,7 @@ #! /bin/bash -trap "boucle=false ; python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" INT -trap "boucle=false ; python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" TERM -boucle=true +trap "python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" INT +trap "python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" TERM stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok @@ -15,7 +14,13 @@ fi rm -f $fileName touch $fileName -while $boucle; do +while true; do read line < /dev/ttyACM0 echo $line >> $fileName -done \ No newline at end of file + case "$line" in + *"DATAEND"*) + break;; + esac +done + +python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 \ No newline at end of file From c00275090b8959612d06018edb67eaff19016a0a Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 019/120] =?UTF-8?q?Modifications=20pour=20conserver=20les?= =?UTF-8?q?=20diff=C3=A9rentes=20sorties,=20si=20elles=20sont=20multiples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 97f99c6..19db0b8 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -1,7 +1,12 @@ #! /bin/bash -trap "python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" INT -trap "python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" TERM +function pythonGraph { + python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" $1 + exit +} + +trap pythonGraph INT +trap pythonGraph TERM stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok @@ -11,16 +16,21 @@ else fileName="./serialOutput/serialOutput.csv" fi -rm -f $fileName -touch $fileName +if [ -e "$fileName" ]; then + fileName=".""$(echo $fileName | cut -f 2 -d".")""-$(date +'%Y-%m-%d @ %Hh%M').csv" +fi + +touch "$fileName" +outFile=$(echo $fileName | cut -f 3 -d"/") + while true; do read line < /dev/ttyACM0 - echo $line >> $fileName + echo $line >> "$fileName" case "$line" in *"DATAEND"*) break;; esac done -python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 \ No newline at end of file +python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" $1 \ No newline at end of file From ff785ed8debfa65b8f11306f50687dafca00512e Mon Sep 17 00:00:00 2001 From: trotFunky Date: Fri, 12 Jan 2018 00:56:53 +0100 Subject: [PATCH 020/120] =?UTF-8?q?Modifications=20pour=20conserver=20les?= =?UTF-8?q?=20diff=C3=A9rentes=20sorties,=20si=20elles=20sont=20multiples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 97f99c6..19db0b8 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -1,7 +1,12 @@ #! /bin/bash -trap "python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" INT -trap "python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 ; exit" TERM +function pythonGraph { + python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" $1 + exit +} + +trap pythonGraph INT +trap pythonGraph TERM stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok @@ -11,16 +16,21 @@ else fileName="./serialOutput/serialOutput.csv" fi -rm -f $fileName -touch $fileName +if [ -e "$fileName" ]; then + fileName=".""$(echo $fileName | cut -f 2 -d".")""-$(date +'%Y-%m-%d @ %Hh%M').csv" +fi + +touch "$fileName" +outFile=$(echo $fileName | cut -f 3 -d"/") + while true; do read line < /dev/ttyACM0 - echo $line >> $fileName + echo $line >> "$fileName" case "$line" in *"DATAEND"*) break;; esac done -python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py $1 $2 $3 \ No newline at end of file +python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" $1 \ No newline at end of file From 25fc45855c31977e5343040bd1cbb97980967cb7 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 021/120] =?UTF-8?q?Becuz=20=C3=A7a=20marche=20mieux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 19db0b8..690242a 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -1,7 +1,8 @@ #! /bin/bash function pythonGraph { - python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" $1 + echo "DATAEND" >> "$fileName" + python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" "$1" exit } @@ -33,4 +34,4 @@ while true; do esac done -python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" $1 \ No newline at end of file +python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" "$1" \ No newline at end of file From 9a018fb8d30a1ba9e4cac034d66135745fc7d44f Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 15 Jan 2018 16:50:33 +0100 Subject: [PATCH 022/120] =?UTF-8?q?Becuz=20=C3=A7a=20marche=20mieux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 19db0b8..690242a 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -1,7 +1,8 @@ #! /bin/bash function pythonGraph { - python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" $1 + echo "DATAEND" >> "$fileName" + python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" "$1" exit } @@ -33,4 +34,4 @@ while true; do esac done -python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" $1 \ No newline at end of file +python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" "$1" \ No newline at end of file From e2bf18135d6c735fc061c44120ac67c18b714acc Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 023/120] =?UTF-8?q?Rajout=20des=20arguments=20de=20fonctio?= =?UTF-8?q?n=20pour=20que=20=C3=A7a=20fonctionne=20sur=20interruption?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 690242a..4e30316 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -1,13 +1,13 @@ #! /bin/bash function pythonGraph { - echo "DATAEND" >> "$fileName" - python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" "$1" + echo "DATAEND" >> "$3" + python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$2" "$1" exit } -trap pythonGraph INT -trap pythonGraph TERM +trap "pythonGraph $1 $outFile $fileName" INT +trap "pythonGraph $1 $outFile $fileName" TERM stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok From b7a5d05c599ab8991098739dbfd27b2af6b83935 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 15 Jan 2018 23:35:20 +0100 Subject: [PATCH 024/120] =?UTF-8?q?Rajout=20des=20arguments=20de=20fonctio?= =?UTF-8?q?n=20pour=20que=20=C3=A7a=20fonctionne=20sur=20interruption?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 690242a..4e30316 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -1,13 +1,13 @@ #! /bin/bash function pythonGraph { - echo "DATAEND" >> "$fileName" - python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" "$1" + echo "DATAEND" >> "$3" + python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$2" "$1" exit } -trap pythonGraph INT -trap pythonGraph TERM +trap "pythonGraph $1 $outFile $fileName" INT +trap "pythonGraph $1 $outFile $fileName" TERM stty -F /dev/ttyACM0 115200 raw -echo -echoe -echok From 0632f9e2bf921191ac43d7c67f31725880ee14e6 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 025/120] =?UTF-8?q?Clean=20de=20la=20s=C3=A9rie=20Rajout?= =?UTF-8?q?=20de=20la=20restauration=20de=20paquets=20dans=20le=20processu?= =?UTF-8?q?s=20de=20sauvegarde=20Fichier=20s=C3=A9par=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/package_restore.sh | 11 +++++++++++ Perso/package_save.sh | 16 ++++++++++++++++ Perso/serialToCSV.sh | 2 ++ 3 files changed, 29 insertions(+) create mode 100644 Perso/package_restore.sh diff --git a/Perso/package_restore.sh b/Perso/package_restore.sh new file mode 100644 index 0000000..84bd73d --- /dev/null +++ b/Perso/package_restore.sh @@ -0,0 +1,11 @@ +#! /bin/bash + +cp . /etc/apt/sources.list +cp ./preferences.d/ /etc/apt/preferences.d/my_preferences +cp -r ./sources.list.d/* /etc/apt/sources.list.d + +apt-get update +apt-get install dselect +dpkg --set-selections < "manual_package_save" +apt-get dselect-upgrade +apt-get remove dselect diff --git a/Perso/package_save.sh b/Perso/package_save.sh index aadb344..e31ee8e 100755 --- a/Perso/package_save.sh +++ b/Perso/package_save.sh @@ -37,6 +37,22 @@ echo "rm -r \"$pathName\"" >> $a chmod u+x "$a" +b="package_restore.sh" + +echo "#! /bin/bash" > $b +echo "" >> $b +echo cp . /etc/apt/sources.list >> $b +echo cp ./preferences.d/ /etc/apt/preferences.d/my_preferences >> $b +echo cp -r ./sources.list.d/* /etc/apt/sources.list.d >> $b +echo "" >> $b +echo apt-get update >> $b +echo apt-get install dselect >> $b +echo "dpkg --set-selections < "manual_package_save"" >> $b +echo apt-get dselect-upgrade >> $b +echo apt-get remove dselect >> $b + +chmod u-x "$b" + cd - exit diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 4e30316..30eb346 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -2,6 +2,7 @@ function pythonGraph { echo "DATAEND" >> "$3" + echo "" > /dev/ttyACM0 python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$2" "$1" exit } @@ -30,6 +31,7 @@ while true; do echo $line >> "$fileName" case "$line" in *"DATAEND"*) + echo "" > /dev/ttyACM0 break;; esac done From 414cf617ff31b1ca7db552d7818043edef26b780 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Tue, 27 Feb 2018 13:36:00 +0100 Subject: [PATCH 026/120] =?UTF-8?q?Clean=20de=20la=20s=C3=A9rie=20Rajout?= =?UTF-8?q?=20de=20la=20restauration=20de=20paquets=20dans=20le=20processu?= =?UTF-8?q?s=20de=20sauvegarde=20Fichier=20s=C3=A9par=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/package_restore.sh | 11 +++++++++++ Perso/package_save.sh | 16 ++++++++++++++++ Perso/serialToCSV.sh | 2 ++ 3 files changed, 29 insertions(+) create mode 100644 Perso/package_restore.sh diff --git a/Perso/package_restore.sh b/Perso/package_restore.sh new file mode 100644 index 0000000..84bd73d --- /dev/null +++ b/Perso/package_restore.sh @@ -0,0 +1,11 @@ +#! /bin/bash + +cp . /etc/apt/sources.list +cp ./preferences.d/ /etc/apt/preferences.d/my_preferences +cp -r ./sources.list.d/* /etc/apt/sources.list.d + +apt-get update +apt-get install dselect +dpkg --set-selections < "manual_package_save" +apt-get dselect-upgrade +apt-get remove dselect diff --git a/Perso/package_save.sh b/Perso/package_save.sh index aadb344..e31ee8e 100755 --- a/Perso/package_save.sh +++ b/Perso/package_save.sh @@ -37,6 +37,22 @@ echo "rm -r \"$pathName\"" >> $a chmod u+x "$a" +b="package_restore.sh" + +echo "#! /bin/bash" > $b +echo "" >> $b +echo cp . /etc/apt/sources.list >> $b +echo cp ./preferences.d/ /etc/apt/preferences.d/my_preferences >> $b +echo cp -r ./sources.list.d/* /etc/apt/sources.list.d >> $b +echo "" >> $b +echo apt-get update >> $b +echo apt-get install dselect >> $b +echo "dpkg --set-selections < "manual_package_save"" >> $b +echo apt-get dselect-upgrade >> $b +echo apt-get remove dselect >> $b + +chmod u-x "$b" + cd - exit diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 4e30316..30eb346 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -2,6 +2,7 @@ function pythonGraph { echo "DATAEND" >> "$3" + echo "" > /dev/ttyACM0 python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$2" "$1" exit } @@ -30,6 +31,7 @@ while true; do echo $line >> "$fileName" case "$line" in *"DATAEND"*) + echo "" > /dev/ttyACM0 break;; esac done From 8cccacac72d45d0ebb2eba269ff68298d0823073 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 027/120] =?UTF-8?q?On=20arr=C3=AAte=20d'=C3=AAtre=20stupid?= =?UTF-8?q?e=20et=20on=20=C3=A9chappe=20les=20commandes=20Arr=C3=AAt=20de?= =?UTF-8?q?=20la=20restauration=20si=20non=20superuser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/package_restore.sh | 11 ++++++++--- Perso/package_save.sh | 14 +++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) mode change 100644 => 100755 Perso/package_restore.sh diff --git a/Perso/package_restore.sh b/Perso/package_restore.sh old mode 100644 new mode 100755 index 84bd73d..7fad345 --- a/Perso/package_restore.sh +++ b/Perso/package_restore.sh @@ -1,11 +1,16 @@ #! /bin/bash -cp . /etc/apt/sources.list -cp ./preferences.d/ /etc/apt/preferences.d/my_preferences +if [ $(id -u) -ne "0" ]; then + echo "Please execute with superuser privileges" + exit -1 +fi + +cp ./sources.list /etc/apt/sources.list +cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences cp -r ./sources.list.d/* /etc/apt/sources.list.d apt-get update apt-get install dselect dpkg --set-selections < "manual_package_save" apt-get dselect-upgrade -apt-get remove dselect +apt-get remove dselect \ No newline at end of file diff --git a/Perso/package_save.sh b/Perso/package_save.sh index e31ee8e..25908b1 100755 --- a/Perso/package_save.sh +++ b/Perso/package_save.sh @@ -41,9 +41,14 @@ b="package_restore.sh" echo "#! /bin/bash" > $b echo "" >> $b -echo cp . /etc/apt/sources.list >> $b -echo cp ./preferences.d/ /etc/apt/preferences.d/my_preferences >> $b -echo cp -r ./sources.list.d/* /etc/apt/sources.list.d >> $b +echo 'if [ $(id -u) -ne "0" ]; then' >> $b +echo ' echo "Please execute with superuser privileges"' >> $b +echo " exit -1" >> $b +echo fi >> $b +echo "" >> $b +echo cp ./sources.list /etc/apt/sources.list >> $b +echo cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences >> $b +echo 'cp -r ./sources.list.d/* /etc/apt/sources.list.d' >> $b echo "" >> $b echo apt-get update >> $b echo apt-get install dselect >> $b @@ -55,5 +60,4 @@ chmod u-x "$b" cd - -exit - +exit \ No newline at end of file From 3012af9c19b698ae1230768054b7c02c96927043 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Tue, 27 Feb 2018 14:43:30 +0100 Subject: [PATCH 028/120] =?UTF-8?q?On=20arr=C3=AAte=20d'=C3=AAtre=20stupid?= =?UTF-8?q?e=20et=20on=20=C3=A9chappe=20les=20commandes=20Arr=C3=AAt=20de?= =?UTF-8?q?=20la=20restauration=20si=20non=20superuser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/package_restore.sh | 11 ++++++++--- Perso/package_save.sh | 14 +++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) mode change 100644 => 100755 Perso/package_restore.sh diff --git a/Perso/package_restore.sh b/Perso/package_restore.sh old mode 100644 new mode 100755 index 84bd73d..7fad345 --- a/Perso/package_restore.sh +++ b/Perso/package_restore.sh @@ -1,11 +1,16 @@ #! /bin/bash -cp . /etc/apt/sources.list -cp ./preferences.d/ /etc/apt/preferences.d/my_preferences +if [ $(id -u) -ne "0" ]; then + echo "Please execute with superuser privileges" + exit -1 +fi + +cp ./sources.list /etc/apt/sources.list +cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences cp -r ./sources.list.d/* /etc/apt/sources.list.d apt-get update apt-get install dselect dpkg --set-selections < "manual_package_save" apt-get dselect-upgrade -apt-get remove dselect +apt-get remove dselect \ No newline at end of file diff --git a/Perso/package_save.sh b/Perso/package_save.sh index e31ee8e..25908b1 100755 --- a/Perso/package_save.sh +++ b/Perso/package_save.sh @@ -41,9 +41,14 @@ b="package_restore.sh" echo "#! /bin/bash" > $b echo "" >> $b -echo cp . /etc/apt/sources.list >> $b -echo cp ./preferences.d/ /etc/apt/preferences.d/my_preferences >> $b -echo cp -r ./sources.list.d/* /etc/apt/sources.list.d >> $b +echo 'if [ $(id -u) -ne "0" ]; then' >> $b +echo ' echo "Please execute with superuser privileges"' >> $b +echo " exit -1" >> $b +echo fi >> $b +echo "" >> $b +echo cp ./sources.list /etc/apt/sources.list >> $b +echo cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences >> $b +echo 'cp -r ./sources.list.d/* /etc/apt/sources.list.d' >> $b echo "" >> $b echo apt-get update >> $b echo apt-get install dselect >> $b @@ -55,5 +60,4 @@ chmod u-x "$b" cd - -exit - +exit \ No newline at end of file From f3a679d087738cfc47641ba7fc1ee4e1ff1f57ab Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 029/120] =?UTF-8?q?Modifi=C3=A9=20pour=20avoir=20un=20son?= =?UTF-8?q?=20al=C3=A9atoire.=20Et=20oui,=20c'est=20d=C3=A9bile!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/bootSound.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Perso/bootSound.sh b/Perso/bootSound.sh index cb0cf89..9c14a2d 100755 --- a/Perso/bootSound.sh +++ b/Perso/bootSound.sh @@ -1,5 +1,16 @@ #! /bin/sh +cd /home/trotfunky/Documents/Sounds/Startup/ +qty=$(ls | grep -c "" ) -mplayer -nogui -softvol -ao alsa,pulse /home/trotfunky/Documents/Sounds/winxp.mp3 & +if [ $qty -lt 10 ]; then + maxBit=1 + diGrep=[[:digit:]] +elif [ $qty -lt 100]; then + maxBit=2 + diGrep=[[:digit:]][[:digit:]] +fi + +mplayer -nogui -softvol -ao alsa,pulse $(expr $(strings /dev/urandom | cut -b 1-$maxBit | grep $diGrep -m 1 ) % $qty )* & +cd - exit 0 \ No newline at end of file From 1a2e64daeda1af9de43be75ea3d61e4343bf99fd Mon Sep 17 00:00:00 2001 From: trotFunky Date: Fri, 2 Mar 2018 18:03:40 +0100 Subject: [PATCH 030/120] =?UTF-8?q?Modifi=C3=A9=20pour=20avoir=20un=20son?= =?UTF-8?q?=20al=C3=A9atoire.=20Et=20oui,=20c'est=20d=C3=A9bile!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/bootSound.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Perso/bootSound.sh b/Perso/bootSound.sh index cb0cf89..9c14a2d 100755 --- a/Perso/bootSound.sh +++ b/Perso/bootSound.sh @@ -1,5 +1,16 @@ #! /bin/sh +cd /home/trotfunky/Documents/Sounds/Startup/ +qty=$(ls | grep -c "" ) -mplayer -nogui -softvol -ao alsa,pulse /home/trotfunky/Documents/Sounds/winxp.mp3 & +if [ $qty -lt 10 ]; then + maxBit=1 + diGrep=[[:digit:]] +elif [ $qty -lt 100]; then + maxBit=2 + diGrep=[[:digit:]][[:digit:]] +fi + +mplayer -nogui -softvol -ao alsa,pulse $(expr $(strings /dev/urandom | cut -b 1-$maxBit | grep $diGrep -m 1 ) % $qty )* & +cd - exit 0 \ No newline at end of file From 7dcc1b1eef5cad09ac3f71fd8fe381681c0f2243 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 031/120] =?UTF-8?q?Modification=20relative=20au=20changeme?= =?UTF-8?q?nt=20de=20l'architecture=20du=20d=C3=A9p=C3=B4t=20Python=20(Oui?= =?UTF-8?q?=20c'est=20sale)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 30eb346..e175916 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -3,7 +3,7 @@ function pythonGraph { echo "DATAEND" >> "$3" echo "" > /dev/ttyACM0 - python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$2" "$1" + python3 /home/trotfunky/Programmation/Git/Python/INTech/extraction_asserv.py "$2" "$1" exit } @@ -36,4 +36,4 @@ while true; do esac done -python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" "$1" \ No newline at end of file +python3 /home/trotfunky/Programmation/Git/Python/INTech/extraction_asserv.py "$outFile" "$1" \ No newline at end of file From 12b0f6dc16fc26edd3c7a5eb2b87644a73a381cd Mon Sep 17 00:00:00 2001 From: trotFunky Date: Wed, 18 Apr 2018 00:39:55 +0200 Subject: [PATCH 032/120] =?UTF-8?q?Modification=20relative=20au=20changeme?= =?UTF-8?q?nt=20de=20l'architecture=20du=20d=C3=A9p=C3=B4t=20Python=20(Oui?= =?UTF-8?q?=20c'est=20sale)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/serialToCSV.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Perso/serialToCSV.sh b/Perso/serialToCSV.sh index 30eb346..e175916 100755 --- a/Perso/serialToCSV.sh +++ b/Perso/serialToCSV.sh @@ -3,7 +3,7 @@ function pythonGraph { echo "DATAEND" >> "$3" echo "" > /dev/ttyACM0 - python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$2" "$1" + python3 /home/trotfunky/Programmation/Git/Python/INTech/extraction_asserv.py "$2" "$1" exit } @@ -36,4 +36,4 @@ while true; do esac done -python3 /home/trotfunky/Programmation/Git/Python/extraction_asserv.py "$outFile" "$1" \ No newline at end of file +python3 /home/trotfunky/Programmation/Git/Python/INTech/extraction_asserv.py "$outFile" "$1" \ No newline at end of file From 5368e2c6a5d46f9e6ff5ad13c50c6fdc2985d39f Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 033/120] Script d'auto-configuration pour le haut-niveau du robot --- Perso/auto_config.sh | 141 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100755 Perso/auto_config.sh diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh new file mode 100755 index 0000000..de2000c --- /dev/null +++ b/Perso/auto_config.sh @@ -0,0 +1,141 @@ +#! /bin/bash + +function colourConvert { + if [ $1 = 'o' ]; then + echo "orange" + fi + if [ $1 = 'g' ]; then + echo "vert" + fi +} + +function monoGrep { # Permet de récupérer l'argument dans la config (true/false/etc) du paramètre passé à la fonction ($1) + if [ $# -eq 1 ]; then + echo $(grep $configFile -e "^$1" | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 2) + fi +} + +function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et, le cas échéant, le remplace par $3 + if [ $(monoGrep "$1") = "$2" ]; then + + echo "WARNING: $1 is $2" + echo "Setting $1 to $3" + echo "" + + parameterState=$(grep $configFile -e ^"$1") + sed -i "s/$parameterState/$(echo -n "$(echo "$parameterState" | cut -d "=" -f1 )"= $3)/" $configFile + + fi +} + +configFile='./config.txt' + + +### COLOR CHANGE + + +colour=$(monoGrep "COULEUR") + +if [ $colour = 'orange' ]; then + printf '\e[48;5;208m]' # Change la couleur du fond à orange + echo "bite" +elif [ $colour = 'vert' ]; then + printf '\e[48;5;118m]' # ou à vert +fi + +printf '\e[38;5;232m]' # Ecrit le texte en noir pour la lisibilité +clear + +echo "Current colour is $colour" + +colourConfirm=$colour + +while [ "$colourConfirm" != "$newColour" ]; do # Boucle de confirmation + + newColour=" " + colourConfirm=" " + + while [ "$newColour" != "o" -a "$newColour" != "g" ]; do + + echo -n "Please choose the colour (o/g): " + read newColour + + done + + if [ $newColour = 'o' ]; then + printf '\e[48;5;208m]' + elif [ $newColour = 'g' ]; then + printf '\e[48;5;118m]' + fi + + clear + + echo "The new colour is $(colourConvert $newColour)" + + while [ "$colourConfirm" != 'o' -a "$colourConfirm" != 'g' ]; do + + echo -n "Please confirm the chosen colour: " + read colourConfirm + done + +done + + +if [ $(colourConvert $colourConfirm) = "$colour" ]; then + echo "The colour remains $colour" +else + echo "The colour has been changed from $colour to $(colourConvert $colourConfirm)" + sed -i "s/= $colour/= $(colourConvert $colourConfirm)/" $configFile # Change la couleur à la couleur choisie +fi +echo "" + + +### PARAMETER CHANGE + + +parameterTest "SIMULATION" "true" "false" +parameterTest "ATTENTE_JUMPER" "false" "true" +parameterTest "basic_detection" "false" "true" + + +# On refait la même pour la version du match +# Reusability, anyone? + + +currentMatchVersion=$(monoGrep "MATCHSCRIPT_TO_EXECUTE") +echo "Ready to launch matchScript version $currentMatchVersion" + +while [ "$changeMatchScript" != 'y' -a "$changeMatchScript" != 'n' ]; do + echo -n "Would you like to change it ? (y/n)" + read changeMatchScript +done + +if [ $changeMatchScript != 'n' ]; then + newMatchVersion="" + confirmMatchVersion="coucou" + while [ "$confirmMatchVersion" != "$newMatchVersion" ]; do + confirmMatchVersion=" " + newMatchVersion=" " + + while [ "$newMatchVersion" != "0" -a "$newMatchVersion" != "1" -a "$newMatchVersion" != "99" ]; do + echo -n "Choose a valid version (0/1/99): " + read newMatchVersion + done + + while [ "$confirmMatchVersion" != "0" -a "$confirmMatchVersion" != "1" -a "$confirmMatchVersion" != "99" ]; do + echo -n "Please confirm your selection: " + read confirmMatchVersion + done + done + + if [ "$confirmMatchVersion" = "$currentMatchVersion" ]; then + echo "Match version remains $currentMatchVersion" + else + matchScriptState=$(grep $configFile -e ^"MATCHSCRIPT_TO_EXECUTE") + sed -i "s/$matchScriptState/$(echo -n "$(echo "$matchScriptState" | cut -d "=" -f1 )""= $newMatchVersion")/" $configFile + echo "MatchVersion has been changed from $currentMatchVersion to $confirmMatchVersion" + fi +fi + +echo "" +echo "May the Force be with Aspie" \ No newline at end of file From f51888ecfcc2148d863e45d263edb31afb91f4be Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sat, 21 Apr 2018 04:16:30 +0200 Subject: [PATCH 034/120] Script d'auto-configuration pour le haut-niveau du robot --- Perso/auto_config.sh | 141 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100755 Perso/auto_config.sh diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh new file mode 100755 index 0000000..de2000c --- /dev/null +++ b/Perso/auto_config.sh @@ -0,0 +1,141 @@ +#! /bin/bash + +function colourConvert { + if [ $1 = 'o' ]; then + echo "orange" + fi + if [ $1 = 'g' ]; then + echo "vert" + fi +} + +function monoGrep { # Permet de récupérer l'argument dans la config (true/false/etc) du paramètre passé à la fonction ($1) + if [ $# -eq 1 ]; then + echo $(grep $configFile -e "^$1" | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 2) + fi +} + +function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et, le cas échéant, le remplace par $3 + if [ $(monoGrep "$1") = "$2" ]; then + + echo "WARNING: $1 is $2" + echo "Setting $1 to $3" + echo "" + + parameterState=$(grep $configFile -e ^"$1") + sed -i "s/$parameterState/$(echo -n "$(echo "$parameterState" | cut -d "=" -f1 )"= $3)/" $configFile + + fi +} + +configFile='./config.txt' + + +### COLOR CHANGE + + +colour=$(monoGrep "COULEUR") + +if [ $colour = 'orange' ]; then + printf '\e[48;5;208m]' # Change la couleur du fond à orange + echo "bite" +elif [ $colour = 'vert' ]; then + printf '\e[48;5;118m]' # ou à vert +fi + +printf '\e[38;5;232m]' # Ecrit le texte en noir pour la lisibilité +clear + +echo "Current colour is $colour" + +colourConfirm=$colour + +while [ "$colourConfirm" != "$newColour" ]; do # Boucle de confirmation + + newColour=" " + colourConfirm=" " + + while [ "$newColour" != "o" -a "$newColour" != "g" ]; do + + echo -n "Please choose the colour (o/g): " + read newColour + + done + + if [ $newColour = 'o' ]; then + printf '\e[48;5;208m]' + elif [ $newColour = 'g' ]; then + printf '\e[48;5;118m]' + fi + + clear + + echo "The new colour is $(colourConvert $newColour)" + + while [ "$colourConfirm" != 'o' -a "$colourConfirm" != 'g' ]; do + + echo -n "Please confirm the chosen colour: " + read colourConfirm + done + +done + + +if [ $(colourConvert $colourConfirm) = "$colour" ]; then + echo "The colour remains $colour" +else + echo "The colour has been changed from $colour to $(colourConvert $colourConfirm)" + sed -i "s/= $colour/= $(colourConvert $colourConfirm)/" $configFile # Change la couleur à la couleur choisie +fi +echo "" + + +### PARAMETER CHANGE + + +parameterTest "SIMULATION" "true" "false" +parameterTest "ATTENTE_JUMPER" "false" "true" +parameterTest "basic_detection" "false" "true" + + +# On refait la même pour la version du match +# Reusability, anyone? + + +currentMatchVersion=$(monoGrep "MATCHSCRIPT_TO_EXECUTE") +echo "Ready to launch matchScript version $currentMatchVersion" + +while [ "$changeMatchScript" != 'y' -a "$changeMatchScript" != 'n' ]; do + echo -n "Would you like to change it ? (y/n)" + read changeMatchScript +done + +if [ $changeMatchScript != 'n' ]; then + newMatchVersion="" + confirmMatchVersion="coucou" + while [ "$confirmMatchVersion" != "$newMatchVersion" ]; do + confirmMatchVersion=" " + newMatchVersion=" " + + while [ "$newMatchVersion" != "0" -a "$newMatchVersion" != "1" -a "$newMatchVersion" != "99" ]; do + echo -n "Choose a valid version (0/1/99): " + read newMatchVersion + done + + while [ "$confirmMatchVersion" != "0" -a "$confirmMatchVersion" != "1" -a "$confirmMatchVersion" != "99" ]; do + echo -n "Please confirm your selection: " + read confirmMatchVersion + done + done + + if [ "$confirmMatchVersion" = "$currentMatchVersion" ]; then + echo "Match version remains $currentMatchVersion" + else + matchScriptState=$(grep $configFile -e ^"MATCHSCRIPT_TO_EXECUTE") + sed -i "s/$matchScriptState/$(echo -n "$(echo "$matchScriptState" | cut -d "=" -f1 )""= $newMatchVersion")/" $configFile + echo "MatchVersion has been changed from $currentMatchVersion to $confirmMatchVersion" + fi +fi + +echo "" +echo "May the Force be with Aspie" \ No newline at end of file From 6ca12196bf203355c9db8784486a1dfd6e838428 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 035/120] =?UTF-8?q?Script=20de=20d=C3=A9marrage=20de=20mat?= =?UTF-8?q?ch=20complet=20(Normalement)=20Modification=20de=20l'auto-confi?= =?UTF-8?q?g=20pour=20que=20ce=20soit=20pas=20trop=20chiant=20avec=20le=20?= =?UTF-8?q?match=20complet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/MATCH_BEGIN.sh | 13 +++++++++++++ Perso/auto_config.sh | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 Perso/MATCH_BEGIN.sh diff --git a/Perso/MATCH_BEGIN.sh b/Perso/MATCH_BEGIN.sh new file mode 100755 index 0000000..65e238f --- /dev/null +++ b/Perso/MATCH_BEGIN.sh @@ -0,0 +1,13 @@ +#! /bin/bash + +x-term -e "~/Documents/TechTheTown-HighLevel/config/auto_config.sh" + +couleur=$(grep $configFile -e "^COULEUR" | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 2) + +if [ couleur = "orange" ]; then + xterm -e "python ~/Documents/TechTheTown-HighLevel/src/patternRecognition/setPatternPosition/SetPatternPositionOrange.py;exit" +else + xterm -e "python ~/Documents/TechTheTown-HighLevel/src/patternRecognition/setPatternPosition/SetPatternPositionGreen.py;exit" +fi + +xterm -e "cd ~/Documents/TechTheTown-HighLevel; java -jar techthetown-highlevel.jar;cd - " \ No newline at end of file diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh index de2000c..37fe45e 100755 --- a/Perso/auto_config.sh +++ b/Perso/auto_config.sh @@ -138,4 +138,6 @@ if [ $changeMatchScript != 'n' ]; then fi echo "" -echo "May the Force be with Aspie" \ No newline at end of file +echo "May the Force be with Aspie" + +exit \ No newline at end of file From dadac7c1ec7d3a210339cdc04704208149faf7fd Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 30 Apr 2018 23:32:23 +0200 Subject: [PATCH 036/120] =?UTF-8?q?Script=20de=20d=C3=A9marrage=20de=20mat?= =?UTF-8?q?ch=20complet=20(Normalement)=20Modification=20de=20l'auto-confi?= =?UTF-8?q?g=20pour=20que=20ce=20soit=20pas=20trop=20chiant=20avec=20le=20?= =?UTF-8?q?match=20complet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/MATCH_BEGIN.sh | 13 +++++++++++++ Perso/auto_config.sh | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 Perso/MATCH_BEGIN.sh diff --git a/Perso/MATCH_BEGIN.sh b/Perso/MATCH_BEGIN.sh new file mode 100755 index 0000000..65e238f --- /dev/null +++ b/Perso/MATCH_BEGIN.sh @@ -0,0 +1,13 @@ +#! /bin/bash + +x-term -e "~/Documents/TechTheTown-HighLevel/config/auto_config.sh" + +couleur=$(grep $configFile -e "^COULEUR" | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 2) + +if [ couleur = "orange" ]; then + xterm -e "python ~/Documents/TechTheTown-HighLevel/src/patternRecognition/setPatternPosition/SetPatternPositionOrange.py;exit" +else + xterm -e "python ~/Documents/TechTheTown-HighLevel/src/patternRecognition/setPatternPosition/SetPatternPositionGreen.py;exit" +fi + +xterm -e "cd ~/Documents/TechTheTown-HighLevel; java -jar techthetown-highlevel.jar;cd - " \ No newline at end of file diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh index de2000c..37fe45e 100755 --- a/Perso/auto_config.sh +++ b/Perso/auto_config.sh @@ -138,4 +138,6 @@ if [ $changeMatchScript != 'n' ]; then fi echo "" -echo "May the Force be with Aspie" \ No newline at end of file +echo "May the Force be with Aspie" + +exit \ No newline at end of file From 2b8f6b55430aa4b3c84dde3b1e664e71fd99ab0c Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 037/120] =?UTF-8?q?Singe-proof=20de=20l'auto=20config=20po?= =?UTF-8?q?ur=20la=20lancer=20de=20n'importe=20o=C3=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/auto_config.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh index 37fe45e..7c3b162 100755 --- a/Perso/auto_config.sh +++ b/Perso/auto_config.sh @@ -16,7 +16,7 @@ function monoGrep { # Permet de récupérer l'argument dans la config (true/fa } function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et, le cas échéant, le remplace par $3 - if [ $(monoGrep "$1") = "$2" ]; then + if [ "$(monoGrep "$1")" = "$2" ]; then echo "WARNING: $1 is $2" echo "Setting $1 to $3" @@ -28,8 +28,12 @@ function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et fi } -configFile='./config.txt' +configFile=""$( dirname "${BASH_SOURCE[0]}" )"/config.txt" +if [ ! -e $configFile ]; then + echo "Erreur: fichier de config invalide!" + exit +fi ### COLOR CHANGE @@ -140,4 +144,4 @@ fi echo "" echo "May the Force be with Aspie" -exit \ No newline at end of file +exit From 8354cebf4a372d6691ecbf38a23148f5f06a4e7f Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sat, 5 May 2018 16:10:20 +0200 Subject: [PATCH 038/120] =?UTF-8?q?Singe-proof=20de=20l'auto=20config=20po?= =?UTF-8?q?ur=20la=20lancer=20de=20n'importe=20o=C3=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/auto_config.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh index 37fe45e..7c3b162 100755 --- a/Perso/auto_config.sh +++ b/Perso/auto_config.sh @@ -16,7 +16,7 @@ function monoGrep { # Permet de récupérer l'argument dans la config (true/fa } function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et, le cas échéant, le remplace par $3 - if [ $(monoGrep "$1") = "$2" ]; then + if [ "$(monoGrep "$1")" = "$2" ]; then echo "WARNING: $1 is $2" echo "Setting $1 to $3" @@ -28,8 +28,12 @@ function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et fi } -configFile='./config.txt' +configFile=""$( dirname "${BASH_SOURCE[0]}" )"/config.txt" +if [ ! -e $configFile ]; then + echo "Erreur: fichier de config invalide!" + exit +fi ### COLOR CHANGE @@ -140,4 +144,4 @@ fi echo "" echo "May the Force be with Aspie" -exit \ No newline at end of file +exit From 8505a69939ab3fedfe969677c203af7b9b3b876a Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 039/120] =?UTF-8?q?Modularit=C3=A9=20avec=20les=20versions?= =?UTF-8?q?=20de=20matchScript=20sous=20forme=20de=20liste?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/auto_config.sh | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh index 7c3b162..a699529 100755 --- a/Perso/auto_config.sh +++ b/Perso/auto_config.sh @@ -28,6 +28,21 @@ function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et fi } +function multiTest { # Vérifie si $1 fait parti des éléments de $2 + + if [ ! $# -eq 2 ]; then + exit + fi + + for toTest in ${!2}; do + if [ "$1" = "$toTest" ]; then + echo "0" + exit + fi + done + exit +} + configFile=""$( dirname "${BASH_SOURCE[0]}" )"/config.txt" if [ ! -e $configFile ]; then @@ -35,6 +50,8 @@ if [ ! -e $configFile ]; then exit fi +matchScriptVersions=("0" "1" "2" "99") + ### COLOR CHANGE @@ -114,19 +131,26 @@ while [ "$changeMatchScript" != 'y' -a "$changeMatchScript" != 'n' ]; do read changeMatchScript done -if [ $changeMatchScript != 'n' ]; then - newMatchVersion="" - confirmMatchVersion="coucou" - while [ "$confirmMatchVersion" != "$newMatchVersion" ]; do - confirmMatchVersion=" " - newMatchVersion=" " - - while [ "$newMatchVersion" != "0" -a "$newMatchVersion" != "1" -a "$newMatchVersion" != "99" ]; do - echo -n "Choose a valid version (0/1/99): " + if [ $changeMatchScript != 'n' ]; then + newMatchVersion="" + confirmMatchVersion="coucou" + while [ "$confirmMatchVersion" != "$newMatchVersion" ]; do + confirmMatchVersion=" " + newMatchVersion=" " + + while [ ! $(multiTest "$newMatchVersion" matchScriptVersions[@]) ]; do + echo -n "Choose a valid version (" + for i in ${matchScriptVersions[@]};do + echo -n "$i" + if [ ! "$i" = "${matchScriptVersions[$(expr ${#matchScriptVersions[@]} - 1)]}" ]; then + echo -n "/" + fi + done + echo -n "): " read newMatchVersion done - while [ "$confirmMatchVersion" != "0" -a "$confirmMatchVersion" != "1" -a "$confirmMatchVersion" != "99" ]; do + while [ ! $(multiTest "$confirmMatchVersion" matchScriptVersions[@] ) ]; do echo -n "Please confirm your selection: " read confirmMatchVersion done From dedb4bc31b5ecb8bba83f324064cfa603f00fe1b Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sat, 5 May 2018 19:04:03 +0200 Subject: [PATCH 040/120] =?UTF-8?q?Modularit=C3=A9=20avec=20les=20versions?= =?UTF-8?q?=20de=20matchScript=20sous=20forme=20de=20liste?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/auto_config.sh | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh index 7c3b162..a699529 100755 --- a/Perso/auto_config.sh +++ b/Perso/auto_config.sh @@ -28,6 +28,21 @@ function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et fi } +function multiTest { # Vérifie si $1 fait parti des éléments de $2 + + if [ ! $# -eq 2 ]; then + exit + fi + + for toTest in ${!2}; do + if [ "$1" = "$toTest" ]; then + echo "0" + exit + fi + done + exit +} + configFile=""$( dirname "${BASH_SOURCE[0]}" )"/config.txt" if [ ! -e $configFile ]; then @@ -35,6 +50,8 @@ if [ ! -e $configFile ]; then exit fi +matchScriptVersions=("0" "1" "2" "99") + ### COLOR CHANGE @@ -114,19 +131,26 @@ while [ "$changeMatchScript" != 'y' -a "$changeMatchScript" != 'n' ]; do read changeMatchScript done -if [ $changeMatchScript != 'n' ]; then - newMatchVersion="" - confirmMatchVersion="coucou" - while [ "$confirmMatchVersion" != "$newMatchVersion" ]; do - confirmMatchVersion=" " - newMatchVersion=" " - - while [ "$newMatchVersion" != "0" -a "$newMatchVersion" != "1" -a "$newMatchVersion" != "99" ]; do - echo -n "Choose a valid version (0/1/99): " + if [ $changeMatchScript != 'n' ]; then + newMatchVersion="" + confirmMatchVersion="coucou" + while [ "$confirmMatchVersion" != "$newMatchVersion" ]; do + confirmMatchVersion=" " + newMatchVersion=" " + + while [ ! $(multiTest "$newMatchVersion" matchScriptVersions[@]) ]; do + echo -n "Choose a valid version (" + for i in ${matchScriptVersions[@]};do + echo -n "$i" + if [ ! "$i" = "${matchScriptVersions[$(expr ${#matchScriptVersions[@]} - 1)]}" ]; then + echo -n "/" + fi + done + echo -n "): " read newMatchVersion done - while [ "$confirmMatchVersion" != "0" -a "$confirmMatchVersion" != "1" -a "$confirmMatchVersion" != "99" ]; do + while [ ! $(multiTest "$confirmMatchVersion" matchScriptVersions[@] ) ]; do echo -n "Please confirm your selection: " read confirmMatchVersion done From f0a608211d06f10003b81c2d78cf4a94513e3904 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 041/120] =?UTF-8?q?Modifications=20de=20l'auto=5Fconfig=20?= =?UTF-8?q?pour=20le=20rendre=20plus=20modulaire=20au=20niveau=20des=20par?= =?UTF-8?q?am=C3=A8tres=20Ajout=20d'options=20pour=20compenser=20la=20lour?= =?UTF-8?q?deur=20des=20param=C3=A8tres=20Modifications=20de=20commentaire?= =?UTF-8?q?s/messages=20d'info/etc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/auto_config.sh | 106 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 97 insertions(+), 9 deletions(-) diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh index a699529..729b4df 100755 --- a/Perso/auto_config.sh +++ b/Perso/auto_config.sh @@ -1,5 +1,6 @@ #! /bin/bash + function colourConvert { if [ $1 = 'o' ]; then echo "orange" @@ -15,10 +16,71 @@ function monoGrep { # Permet de récupérer l'argument dans la config (true/fa fi } -function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et, le cas échéant, le remplace par $3 - if [ "$(monoGrep "$1")" = "$2" ]; then +function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et, le cas échéant, le remplace par $3. Demande confirmation + answer="" + + if [ "$(monoGrep "$1")" = "$2" ]; then # Si le paramètre est à la valeur $2, demande si on veut la changer ou pas echo "WARNING: $1 is $2" + case $mode in + "std" ) + while [ "$answer" != "y" -a "$answer" != "n" ]; do + echo -n "Change it to standard value ($3) ? (y/n): " + read answer + done + ;; + "force-yes" ) + answer="y" + ;; + "force-no" ) + answer="n" + ;; + esac + + if [ $answer = "y" ]; then + echo "Setting $1 to $3" + echo "" + + parameterState=$(grep $configFile -e ^"$1") + sed -i "s/$parameterState/$(echo -n "$(echo "$parameterState" | cut -d "=" -f1 )"= $3)/" $configFile + else + echo "Keeping $1 at non-standard value ($2)" + echo "" + fi + + elif [ "$(monoGrep "$1")" = "$3" ]; then # Si le paramètre est à la valeur $3 demande si on veut le garder ou pas + + echo "$1 is already $3" + + case $mode in + "std" ) + while [ "$answer" != "y" -a "$answer" != "n" ]; do + echo -n "Keep it at standard value ? (y/n): " + read answer + done + ;; + "force-yes" ) + answer="y" + ;; + "force-no" ) + answer="n" + ;; + esac + + if [ $answer = "y" ]; then + echo "Keeping $1 at standard value ($3)" + echo "" + else + echo "Changing $1 to non-standard value ($2)" + echo "" + + parameterState=$(grep $configFile -e ^"$1") + sed -i "s/$parameterState/$(echo -n "$(echo "$parameterState" | cut -d "=" -f1 )"= $2)/" $configFile + fi + + else + + echo "WARNING: $1 value is invalid" echo "Setting $1 to $3" echo "" @@ -43,10 +105,33 @@ function multiTest { # Vérifie si $1 fait parti des éléments de $2 exit } -configFile=""$( dirname "${BASH_SOURCE[0]}" )"/config.txt" + +if [ $# -eq 0 ]; then + echo "Standard mode" + mode="std" +else + while getopts ":yYnN" option; do # Permet de gérer les options du script + case $option in + y | Y ) + echo "Forcing yes" + mode="force-yes" + break;; + n | N ) + echo "Forcing no" + mode="force-no" + break;; + * ) + echo "Invalid option used. Valid options are: (yYnN)" + exit + esac + done +fi + + +configFile=""$( dirname "${BASH_SOURCE[0]}" )"/config.txt" # Obtient le chemin d'origine du script et pas le lieu d'éxécution if [ ! -e $configFile ]; then - echo "Erreur: fichier de config invalide!" + echo "ERROR: Invalid config file!" exit fi @@ -71,7 +156,7 @@ echo "Current colour is $colour" colourConfirm=$colour -while [ "$colourConfirm" != "$newColour" ]; do # Boucle de confirmation +while [ "$colourConfirm" != "$newColour" ]; do # Boucle de confirmation newColour=" " colourConfirm=" " @@ -116,7 +201,7 @@ echo "" parameterTest "SIMULATION" "true" "false" parameterTest "ATTENTE_JUMPER" "false" "true" -parameterTest "basic_detection" "false" "true" +parameterTest "BASIC_DETECTION" "false" "true" # On refait la même pour la version du match @@ -127,19 +212,21 @@ currentMatchVersion=$(monoGrep "MATCHSCRIPT_TO_EXECUTE") echo "Ready to launch matchScript version $currentMatchVersion" while [ "$changeMatchScript" != 'y' -a "$changeMatchScript" != 'n' ]; do - echo -n "Would you like to change it ? (y/n)" + echo -n "Would you like to change it ? (y/n): " read changeMatchScript done if [ $changeMatchScript != 'n' ]; then newMatchVersion="" confirmMatchVersion="coucou" + while [ "$confirmMatchVersion" != "$newMatchVersion" ]; do confirmMatchVersion=" " newMatchVersion=" " while [ ! $(multiTest "$newMatchVersion" matchScriptVersions[@]) ]; do - echo -n "Choose a valid version (" + + echo -n "Choose a valid version (" # Permet d'afficher les valeurs du tableau proprement for i in ${matchScriptVersions[@]};do echo -n "$i" if [ ! "$i" = "${matchScriptVersions[$(expr ${#matchScriptVersions[@]} - 1)]}" ]; then @@ -148,6 +235,7 @@ done done echo -n "): " read newMatchVersion + done while [ ! $(multiTest "$confirmMatchVersion" matchScriptVersions[@] ) ]; do @@ -168,4 +256,4 @@ fi echo "" echo "May the Force be with Aspie" -exit +exit \ No newline at end of file From be3ab6785b0c8a7dab61ff16f8f70f1b70616600 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 7 May 2018 16:48:49 +0200 Subject: [PATCH 042/120] =?UTF-8?q?Modifications=20de=20l'auto=5Fconfig=20?= =?UTF-8?q?pour=20le=20rendre=20plus=20modulaire=20au=20niveau=20des=20par?= =?UTF-8?q?am=C3=A8tres=20Ajout=20d'options=20pour=20compenser=20la=20lour?= =?UTF-8?q?deur=20des=20param=C3=A8tres=20Modifications=20de=20commentaire?= =?UTF-8?q?s/messages=20d'info/etc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/auto_config.sh | 106 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 97 insertions(+), 9 deletions(-) diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh index a699529..729b4df 100755 --- a/Perso/auto_config.sh +++ b/Perso/auto_config.sh @@ -1,5 +1,6 @@ #! /bin/bash + function colourConvert { if [ $1 = 'o' ]; then echo "orange" @@ -15,10 +16,71 @@ function monoGrep { # Permet de récupérer l'argument dans la config (true/fa fi } -function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et, le cas échéant, le remplace par $3 - if [ "$(monoGrep "$1")" = "$2" ]; then +function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et, le cas échéant, le remplace par $3. Demande confirmation + answer="" + + if [ "$(monoGrep "$1")" = "$2" ]; then # Si le paramètre est à la valeur $2, demande si on veut la changer ou pas echo "WARNING: $1 is $2" + case $mode in + "std" ) + while [ "$answer" != "y" -a "$answer" != "n" ]; do + echo -n "Change it to standard value ($3) ? (y/n): " + read answer + done + ;; + "force-yes" ) + answer="y" + ;; + "force-no" ) + answer="n" + ;; + esac + + if [ $answer = "y" ]; then + echo "Setting $1 to $3" + echo "" + + parameterState=$(grep $configFile -e ^"$1") + sed -i "s/$parameterState/$(echo -n "$(echo "$parameterState" | cut -d "=" -f1 )"= $3)/" $configFile + else + echo "Keeping $1 at non-standard value ($2)" + echo "" + fi + + elif [ "$(monoGrep "$1")" = "$3" ]; then # Si le paramètre est à la valeur $3 demande si on veut le garder ou pas + + echo "$1 is already $3" + + case $mode in + "std" ) + while [ "$answer" != "y" -a "$answer" != "n" ]; do + echo -n "Keep it at standard value ? (y/n): " + read answer + done + ;; + "force-yes" ) + answer="y" + ;; + "force-no" ) + answer="n" + ;; + esac + + if [ $answer = "y" ]; then + echo "Keeping $1 at standard value ($3)" + echo "" + else + echo "Changing $1 to non-standard value ($2)" + echo "" + + parameterState=$(grep $configFile -e ^"$1") + sed -i "s/$parameterState/$(echo -n "$(echo "$parameterState" | cut -d "=" -f1 )"= $2)/" $configFile + fi + + else + + echo "WARNING: $1 value is invalid" echo "Setting $1 to $3" echo "" @@ -43,10 +105,33 @@ function multiTest { # Vérifie si $1 fait parti des éléments de $2 exit } -configFile=""$( dirname "${BASH_SOURCE[0]}" )"/config.txt" + +if [ $# -eq 0 ]; then + echo "Standard mode" + mode="std" +else + while getopts ":yYnN" option; do # Permet de gérer les options du script + case $option in + y | Y ) + echo "Forcing yes" + mode="force-yes" + break;; + n | N ) + echo "Forcing no" + mode="force-no" + break;; + * ) + echo "Invalid option used. Valid options are: (yYnN)" + exit + esac + done +fi + + +configFile=""$( dirname "${BASH_SOURCE[0]}" )"/config.txt" # Obtient le chemin d'origine du script et pas le lieu d'éxécution if [ ! -e $configFile ]; then - echo "Erreur: fichier de config invalide!" + echo "ERROR: Invalid config file!" exit fi @@ -71,7 +156,7 @@ echo "Current colour is $colour" colourConfirm=$colour -while [ "$colourConfirm" != "$newColour" ]; do # Boucle de confirmation +while [ "$colourConfirm" != "$newColour" ]; do # Boucle de confirmation newColour=" " colourConfirm=" " @@ -116,7 +201,7 @@ echo "" parameterTest "SIMULATION" "true" "false" parameterTest "ATTENTE_JUMPER" "false" "true" -parameterTest "basic_detection" "false" "true" +parameterTest "BASIC_DETECTION" "false" "true" # On refait la même pour la version du match @@ -127,19 +212,21 @@ currentMatchVersion=$(monoGrep "MATCHSCRIPT_TO_EXECUTE") echo "Ready to launch matchScript version $currentMatchVersion" while [ "$changeMatchScript" != 'y' -a "$changeMatchScript" != 'n' ]; do - echo -n "Would you like to change it ? (y/n)" + echo -n "Would you like to change it ? (y/n): " read changeMatchScript done if [ $changeMatchScript != 'n' ]; then newMatchVersion="" confirmMatchVersion="coucou" + while [ "$confirmMatchVersion" != "$newMatchVersion" ]; do confirmMatchVersion=" " newMatchVersion=" " while [ ! $(multiTest "$newMatchVersion" matchScriptVersions[@]) ]; do - echo -n "Choose a valid version (" + + echo -n "Choose a valid version (" # Permet d'afficher les valeurs du tableau proprement for i in ${matchScriptVersions[@]};do echo -n "$i" if [ ! "$i" = "${matchScriptVersions[$(expr ${#matchScriptVersions[@]} - 1)]}" ]; then @@ -148,6 +235,7 @@ done done echo -n "): " read newMatchVersion + done while [ ! $(multiTest "$confirmMatchVersion" matchScriptVersions[@] ) ]; do @@ -168,4 +256,4 @@ fi echo "" echo "May the Force be with Aspie" -exit +exit \ No newline at end of file From 1e1a67a6580956afcc9640cf7ad3ef5a0e977b63 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 043/120] =?UTF-8?q?Ajout=20de=20la=20d=C3=A9tection=20avan?= =?UTF-8?q?c=C3=A9e=20Match=5Fbegin=20fonctionnel=20(DUH)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/MATCH_BEGIN.sh | 8 ++++---- Perso/auto_config.sh | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Perso/MATCH_BEGIN.sh b/Perso/MATCH_BEGIN.sh index 65e238f..cb74df0 100755 --- a/Perso/MATCH_BEGIN.sh +++ b/Perso/MATCH_BEGIN.sh @@ -1,13 +1,13 @@ #! /bin/bash -x-term -e "~/Documents/TechTheTown-HighLevel/config/auto_config.sh" +xterm -e "/home/pi/Documents/TechTheTown-HighLevel/config/auto_config.sh" -couleur=$(grep $configFile -e "^COULEUR" | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 2) +couleur=$(grep "/home/pi/Documents/TechTheTown-HighLevel/config/config.txt" -e "^COULEUR" | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 2) -if [ couleur = "orange" ]; then +if [ $couleur = "orange" ]; then xterm -e "python ~/Documents/TechTheTown-HighLevel/src/patternRecognition/setPatternPosition/SetPatternPositionOrange.py;exit" else xterm -e "python ~/Documents/TechTheTown-HighLevel/src/patternRecognition/setPatternPosition/SetPatternPositionGreen.py;exit" fi -xterm -e "cd ~/Documents/TechTheTown-HighLevel; java -jar techthetown-highlevel.jar;cd - " \ No newline at end of file +xterm -e "cd ~/Documents/TechTheTown-HighLevel; java -jar techthetown-highlevel.jar;cd - " diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh index 729b4df..99f4266 100755 --- a/Perso/auto_config.sh +++ b/Perso/auto_config.sh @@ -202,6 +202,7 @@ echo "" parameterTest "SIMULATION" "true" "false" parameterTest "ATTENTE_JUMPER" "false" "true" parameterTest "BASIC_DETECTION" "false" "true" +parameterTest "ADVANCED_DETECTION" "false" "true" # On refait la même pour la version du match From 4b5cca26d81dbcf06d957b44166a29d78005d63c Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 7 May 2018 18:16:39 +0200 Subject: [PATCH 044/120] =?UTF-8?q?Ajout=20de=20la=20d=C3=A9tection=20avan?= =?UTF-8?q?c=C3=A9e=20Match=5Fbegin=20fonctionnel=20(DUH)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/MATCH_BEGIN.sh | 8 ++++---- Perso/auto_config.sh | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Perso/MATCH_BEGIN.sh b/Perso/MATCH_BEGIN.sh index 65e238f..cb74df0 100755 --- a/Perso/MATCH_BEGIN.sh +++ b/Perso/MATCH_BEGIN.sh @@ -1,13 +1,13 @@ #! /bin/bash -x-term -e "~/Documents/TechTheTown-HighLevel/config/auto_config.sh" +xterm -e "/home/pi/Documents/TechTheTown-HighLevel/config/auto_config.sh" -couleur=$(grep $configFile -e "^COULEUR" | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 2) +couleur=$(grep "/home/pi/Documents/TechTheTown-HighLevel/config/config.txt" -e "^COULEUR" | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 2) -if [ couleur = "orange" ]; then +if [ $couleur = "orange" ]; then xterm -e "python ~/Documents/TechTheTown-HighLevel/src/patternRecognition/setPatternPosition/SetPatternPositionOrange.py;exit" else xterm -e "python ~/Documents/TechTheTown-HighLevel/src/patternRecognition/setPatternPosition/SetPatternPositionGreen.py;exit" fi -xterm -e "cd ~/Documents/TechTheTown-HighLevel; java -jar techthetown-highlevel.jar;cd - " \ No newline at end of file +xterm -e "cd ~/Documents/TechTheTown-HighLevel; java -jar techthetown-highlevel.jar;cd - " diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh index 729b4df..99f4266 100755 --- a/Perso/auto_config.sh +++ b/Perso/auto_config.sh @@ -202,6 +202,7 @@ echo "" parameterTest "SIMULATION" "true" "false" parameterTest "ATTENTE_JUMPER" "false" "true" parameterTest "BASIC_DETECTION" "false" "true" +parameterTest "ADVANCED_DETECTION" "false" "true" # On refait la même pour la version du match From 2c622e075f617813770c8e455c49d78e808df30c Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 045/120] =?UTF-8?q?Ajout=20de=20l'option=20pour=20garder?= =?UTF-8?q?=20les=20param=C3=A8tres=20de=20la=20config=20dans=20leur=20?= =?UTF-8?q?=C3=A9tat=20actuel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/auto_config.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh index 99f4266..fe60387 100755 --- a/Perso/auto_config.sh +++ b/Perso/auto_config.sh @@ -32,7 +32,7 @@ function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et "force-yes" ) answer="y" ;; - "force-no" ) + "force-no" | "keep-cfg" ) answer="n" ;; esac @@ -59,7 +59,7 @@ function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et read answer done ;; - "force-yes" ) + "force-yes" | "keep-cfg" ) answer="y" ;; "force-no" ) @@ -110,7 +110,7 @@ if [ $# -eq 0 ]; then echo "Standard mode" mode="std" else - while getopts ":yYnN" option; do # Permet de gérer les options du script + while getopts ":yYnNkK" option; do # Permet de gérer les options du script case $option in y | Y ) echo "Forcing yes" @@ -120,8 +120,12 @@ else echo "Forcing no" mode="force-no" break;; + k | K ) + echo "Keeping parameter values" + mode="keep-cfg" + break;; * ) - echo "Invalid option used. Valid options are: (yYnN)" + echo "Invalid option used. Valid options are: (yYnNkK)" exit esac done From 03a7c14447fc40a4f575859181c3be8c2fccabdc Mon Sep 17 00:00:00 2001 From: trotFunky Date: Tue, 8 May 2018 15:52:25 +0200 Subject: [PATCH 046/120] =?UTF-8?q?Ajout=20de=20l'option=20pour=20garder?= =?UTF-8?q?=20les=20param=C3=A8tres=20de=20la=20config=20dans=20leur=20?= =?UTF-8?q?=C3=A9tat=20actuel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/auto_config.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Perso/auto_config.sh b/Perso/auto_config.sh index 99f4266..fe60387 100755 --- a/Perso/auto_config.sh +++ b/Perso/auto_config.sh @@ -32,7 +32,7 @@ function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et "force-yes" ) answer="y" ;; - "force-no" ) + "force-no" | "keep-cfg" ) answer="n" ;; esac @@ -59,7 +59,7 @@ function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et read answer done ;; - "force-yes" ) + "force-yes" | "keep-cfg" ) answer="y" ;; "force-no" ) @@ -110,7 +110,7 @@ if [ $# -eq 0 ]; then echo "Standard mode" mode="std" else - while getopts ":yYnN" option; do # Permet de gérer les options du script + while getopts ":yYnNkK" option; do # Permet de gérer les options du script case $option in y | Y ) echo "Forcing yes" @@ -120,8 +120,12 @@ else echo "Forcing no" mode="force-no" break;; + k | K ) + echo "Keeping parameter values" + mode="keep-cfg" + break;; * ) - echo "Invalid option used. Valid options are: (yYnN)" + echo "Invalid option used. Valid options are: (yYnNkK)" exit esac done From b07934d774db34ac6dc675679036addaf23ccd12 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 047/120] =?UTF-8?q?Cr=C3=A9ation=20du=20Linux=20Auto=20Upl?= =?UTF-8?q?oader=20(LAU):=20script=20permettant=20d'uploader=20sur=20ma=20?= =?UTF-8?q?dropbox=20depuis=20la=20ligne=20de=20commande=20et=20d'obtenir?= =?UTF-8?q?=20le=20lien=20de=20t=C3=A9l=C3=A9chargement.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TODO: -Process d'OAuth2 complet -Gestion des sous-dossiers pour le fichier uploadé (Deuxième argument optionnel? +regex?) --- Perso/LAU.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 Perso/LAU.sh diff --git a/Perso/LAU.sh b/Perso/LAU.sh new file mode 100755 index 0000000..9f5e88d --- /dev/null +++ b/Perso/LAU.sh @@ -0,0 +1,60 @@ +#! /bin/bash + +#trotFunky's Linux Auto Uploader (LAU) +#Uses dropbox HTTP API through curl to upload a file and copy shareable link into clipboard +#NEEDS : curl, xclip + +if [ -z "$DROPBOX_TOKEN" ]; then + echo "No token provided." + echo "Please set the env variable DROPBOX_TOKEN to the dropbox authorization token" + exit -1 +fi + +if [ $# -lt 1 ]; then + echo "Too few arguments. Expecting one agument: File name" + exit -1 +elif [ $# -gt 1 -a "$2" != "debug" ]; then + echo "Too many arguments. Expecting only one argument: File name" + exit -1 +elif [ ! -f "$1" ]; then + echo "File does not exist or is not uploadable" + exit -1 +fi + +filePath=$1 + +if [[ $filePath = */* ]]; then #If the string contains a / + fileName="/${filePath##*/}" #Or you know, just remove the largest possible string matching */ and a / at the beginning (Keeping the other for reference) + #fileName="${filePath#"${filePath%/*}"}" #Variable expansion. Innermost bracket reads "Get what does not match the /* anchored at the end". +else #The outermost bracket then removes it from the original string (By doing the same as above but anchored to the start) + fileName="/$filePath" +fi + +if [ -n "$2" ]; then + echo $filePath + echo $fileName +fi + +#CF curl's and dropbox API's documentations + +upload=$(curl --silent https://content.dropboxapi.com/2/files/upload \ + -H "Authorization: Bearer $DROPBOX_TOKEN" \ + -H 'Dropbox-API-Arg: {"path": "'"$fileName"'", "mode": "add", "autorename": true, "mute": false}' \ + -H "Content-type: application/octet-stream" \ + --data-binary @"$filePath" ) + +link=$(curl --silent https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings \ + -H "Authorization: Bearer $DROPBOX_TOKEN" \ + -H "Content-type: application/json" \ + -d '{"path": "'"$fileName"'"}' ) + +if [ -n "$2" ]; then + echo $upload + echo $link +fi + +tmpShareLink="$(echo -n $link | cut -d, -f2 | cut -d: -f2-3)" #According to the returned data, this is where the URL is +tmpShareLink="${tmpShareLink#*\"}" #Removes everything matching *" +tmpShareLink="${tmpShareLink%\"*}" #Removes everything matching "* +shareLink="${tmpShareLink/https:\/\/www/https:\/\/dl}" #Replaces www by dl for direct link +echo -n "$shareLink" | xclip -selection clipboard From 63944ba313ecffcd90b284f557bad2a50815cf76 Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Sun, 15 Jul 2018 03:54:48 +0200 Subject: [PATCH 048/120] =?UTF-8?q?Cr=C3=A9ation=20du=20Linux=20Auto=20Upl?= =?UTF-8?q?oader=20(LAU):=20script=20permettant=20d'uploader=20sur=20ma=20?= =?UTF-8?q?dropbox=20depuis=20la=20ligne=20de=20commande=20et=20d'obtenir?= =?UTF-8?q?=20le=20lien=20de=20t=C3=A9l=C3=A9chargement.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TODO: -Process d'OAuth2 complet -Gestion des sous-dossiers pour le fichier uploadé (Deuxième argument optionnel? +regex?) --- Perso/LAU.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 Perso/LAU.sh diff --git a/Perso/LAU.sh b/Perso/LAU.sh new file mode 100755 index 0000000..9f5e88d --- /dev/null +++ b/Perso/LAU.sh @@ -0,0 +1,60 @@ +#! /bin/bash + +#trotFunky's Linux Auto Uploader (LAU) +#Uses dropbox HTTP API through curl to upload a file and copy shareable link into clipboard +#NEEDS : curl, xclip + +if [ -z "$DROPBOX_TOKEN" ]; then + echo "No token provided." + echo "Please set the env variable DROPBOX_TOKEN to the dropbox authorization token" + exit -1 +fi + +if [ $# -lt 1 ]; then + echo "Too few arguments. Expecting one agument: File name" + exit -1 +elif [ $# -gt 1 -a "$2" != "debug" ]; then + echo "Too many arguments. Expecting only one argument: File name" + exit -1 +elif [ ! -f "$1" ]; then + echo "File does not exist or is not uploadable" + exit -1 +fi + +filePath=$1 + +if [[ $filePath = */* ]]; then #If the string contains a / + fileName="/${filePath##*/}" #Or you know, just remove the largest possible string matching */ and a / at the beginning (Keeping the other for reference) + #fileName="${filePath#"${filePath%/*}"}" #Variable expansion. Innermost bracket reads "Get what does not match the /* anchored at the end". +else #The outermost bracket then removes it from the original string (By doing the same as above but anchored to the start) + fileName="/$filePath" +fi + +if [ -n "$2" ]; then + echo $filePath + echo $fileName +fi + +#CF curl's and dropbox API's documentations + +upload=$(curl --silent https://content.dropboxapi.com/2/files/upload \ + -H "Authorization: Bearer $DROPBOX_TOKEN" \ + -H 'Dropbox-API-Arg: {"path": "'"$fileName"'", "mode": "add", "autorename": true, "mute": false}' \ + -H "Content-type: application/octet-stream" \ + --data-binary @"$filePath" ) + +link=$(curl --silent https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings \ + -H "Authorization: Bearer $DROPBOX_TOKEN" \ + -H "Content-type: application/json" \ + -d '{"path": "'"$fileName"'"}' ) + +if [ -n "$2" ]; then + echo $upload + echo $link +fi + +tmpShareLink="$(echo -n $link | cut -d, -f2 | cut -d: -f2-3)" #According to the returned data, this is where the URL is +tmpShareLink="${tmpShareLink#*\"}" #Removes everything matching *" +tmpShareLink="${tmpShareLink%\"*}" #Removes everything matching "* +shareLink="${tmpShareLink/https:\/\/www/https:\/\/dl}" #Replaces www by dl for direct link +echo -n "$shareLink" | xclip -selection clipboard From 72cba0d03cce02d93f624a761c1909012d97f4f0 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 049/120] Timed systemd unit for lockscreen background update --- Perso/systemd_timers/lockScreenUpdate.service | 7 +++++++ Perso/systemd_timers/lockScreenUpdate.timer | 10 ++++++++++ 2 files changed, 17 insertions(+) create mode 100644 Perso/systemd_timers/lockScreenUpdate.service create mode 100644 Perso/systemd_timers/lockScreenUpdate.timer diff --git a/Perso/systemd_timers/lockScreenUpdate.service b/Perso/systemd_timers/lockScreenUpdate.service new file mode 100644 index 0000000..b78b1f3 --- /dev/null +++ b/Perso/systemd_timers/lockScreenUpdate.service @@ -0,0 +1,7 @@ +[Unit] +Description=Updates lockscreen background + +[Service] +Type=oneshot +User=trotfunky +ExecStart=/bin/bash -c 'DISPLAY=:0 scrot -z ~/Pictures/lock.png ; convert -blur 0x3 ~/Pictures/lock.png ~/Pictures/lock.png' \ No newline at end of file diff --git a/Perso/systemd_timers/lockScreenUpdate.timer b/Perso/systemd_timers/lockScreenUpdate.timer new file mode 100644 index 0000000..5c777f4 --- /dev/null +++ b/Perso/systemd_timers/lockScreenUpdate.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Updates lockscreen background +Requires=lightdm.service +After=lightdm.service + +[Timer] +OnActiveSec=5min + +[Install] +WantedBy=timers.target \ No newline at end of file From 0c7efade527f58c7b40f26dcdaf3b58df4a4cf0a Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Thu, 24 Jan 2019 23:29:58 +0100 Subject: [PATCH 050/120] Timed systemd unit for lockscreen background update --- Perso/systemd_timers/lockScreenUpdate.service | 7 +++++++ Perso/systemd_timers/lockScreenUpdate.timer | 10 ++++++++++ 2 files changed, 17 insertions(+) create mode 100644 Perso/systemd_timers/lockScreenUpdate.service create mode 100644 Perso/systemd_timers/lockScreenUpdate.timer diff --git a/Perso/systemd_timers/lockScreenUpdate.service b/Perso/systemd_timers/lockScreenUpdate.service new file mode 100644 index 0000000..b78b1f3 --- /dev/null +++ b/Perso/systemd_timers/lockScreenUpdate.service @@ -0,0 +1,7 @@ +[Unit] +Description=Updates lockscreen background + +[Service] +Type=oneshot +User=trotfunky +ExecStart=/bin/bash -c 'DISPLAY=:0 scrot -z ~/Pictures/lock.png ; convert -blur 0x3 ~/Pictures/lock.png ~/Pictures/lock.png' \ No newline at end of file diff --git a/Perso/systemd_timers/lockScreenUpdate.timer b/Perso/systemd_timers/lockScreenUpdate.timer new file mode 100644 index 0000000..5c777f4 --- /dev/null +++ b/Perso/systemd_timers/lockScreenUpdate.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Updates lockscreen background +Requires=lightdm.service +After=lightdm.service + +[Timer] +OnActiveSec=5min + +[Install] +WantedBy=timers.target \ No newline at end of file From febcdb296b9838a456a88dbb50d25f27bf3901f2 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 051/120] Corrected non-repeating timer --- Perso/systemd_timers/lockScreenUpdate.timer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Perso/systemd_timers/lockScreenUpdate.timer b/Perso/systemd_timers/lockScreenUpdate.timer index 5c777f4..9a0ea57 100644 --- a/Perso/systemd_timers/lockScreenUpdate.timer +++ b/Perso/systemd_timers/lockScreenUpdate.timer @@ -4,7 +4,7 @@ Requires=lightdm.service After=lightdm.service [Timer] -OnActiveSec=5min +OnUnitActiveSec=5min [Install] WantedBy=timers.target \ No newline at end of file From 1e3861819fc978aff1e4df9f5f0eb553007e6fc1 Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Fri, 25 Jan 2019 10:58:01 +0100 Subject: [PATCH 052/120] Corrected non-repeating timer --- Perso/systemd_timers/lockScreenUpdate.timer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Perso/systemd_timers/lockScreenUpdate.timer b/Perso/systemd_timers/lockScreenUpdate.timer index 5c777f4..9a0ea57 100644 --- a/Perso/systemd_timers/lockScreenUpdate.timer +++ b/Perso/systemd_timers/lockScreenUpdate.timer @@ -4,7 +4,7 @@ Requires=lightdm.service After=lightdm.service [Timer] -OnActiveSec=5min +OnUnitActiveSec=5min [Install] WantedBy=timers.target \ No newline at end of file From ecf9e11103ec032891f269c7966bd849f1d009a3 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 053/120] =?UTF-8?q?D=C3=A9marrage=20du=20service=20au=20bo?= =?UTF-8?q?ot=20pour=20lancer=20le=20timer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/systemd_timers/lockScreenUpdate.timer | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Perso/systemd_timers/lockScreenUpdate.timer b/Perso/systemd_timers/lockScreenUpdate.timer index 9a0ea57..cd5edfb 100644 --- a/Perso/systemd_timers/lockScreenUpdate.timer +++ b/Perso/systemd_timers/lockScreenUpdate.timer @@ -4,7 +4,8 @@ Requires=lightdm.service After=lightdm.service [Timer] +OnBootSec=5min OnUnitActiveSec=5min [Install] -WantedBy=timers.target \ No newline at end of file +WantedBy=timers.target From 63b349bef20e92dc620fb04df3a01b66c9b58749 Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Mon, 28 Jan 2019 17:09:04 +0100 Subject: [PATCH 054/120] =?UTF-8?q?D=C3=A9marrage=20du=20service=20au=20bo?= =?UTF-8?q?ot=20pour=20lancer=20le=20timer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/systemd_timers/lockScreenUpdate.timer | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Perso/systemd_timers/lockScreenUpdate.timer b/Perso/systemd_timers/lockScreenUpdate.timer index 9a0ea57..cd5edfb 100644 --- a/Perso/systemd_timers/lockScreenUpdate.timer +++ b/Perso/systemd_timers/lockScreenUpdate.timer @@ -4,7 +4,8 @@ Requires=lightdm.service After=lightdm.service [Timer] +OnBootSec=5min OnUnitActiveSec=5min [Install] -WantedBy=timers.target \ No newline at end of file +WantedBy=timers.target From 41df0b06eddb5155e39177c3b905f6a5a5fd26b8 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 055/120] =?UTF-8?q?Script=20verouillage=20=C3=A9cran=20gno?= =?UTF-8?q?me?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/locksreenshot.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 Perso/locksreenshot.sh diff --git a/Perso/locksreenshot.sh b/Perso/locksreenshot.sh new file mode 100755 index 0000000..6d8c5d6 --- /dev/null +++ b/Perso/locksreenshot.sh @@ -0,0 +1,5 @@ +#! /bin/bash + +DISPLAY=:0 scrot -z ~/Images/Wallpapers/lockscreen.png +convert -blur 0x3 ~/Images/Wallpapers/lockscreen.png ~/Images/Wallpapers/lockscreen.png +dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock \ No newline at end of file From cb63b0c96624c5a61ad941f94086f9fada1967e2 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Wed, 20 Feb 2019 20:07:12 +0100 Subject: [PATCH 056/120] =?UTF-8?q?Script=20verouillage=20=C3=A9cran=20gno?= =?UTF-8?q?me?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/locksreenshot.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 Perso/locksreenshot.sh diff --git a/Perso/locksreenshot.sh b/Perso/locksreenshot.sh new file mode 100755 index 0000000..6d8c5d6 --- /dev/null +++ b/Perso/locksreenshot.sh @@ -0,0 +1,5 @@ +#! /bin/bash + +DISPLAY=:0 scrot -z ~/Images/Wallpapers/lockscreen.png +convert -blur 0x3 ~/Images/Wallpapers/lockscreen.png ~/Images/Wallpapers/lockscreen.png +dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock \ No newline at end of file From 2ef6c55ee32bd50bc67589abfd1db18aecfc2952 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 057/120] Scrot ne marche plus sous wayland, sad :( --- Perso/locksreenshot.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Perso/locksreenshot.sh b/Perso/locksreenshot.sh index 6d8c5d6..fc2b9ad 100755 --- a/Perso/locksreenshot.sh +++ b/Perso/locksreenshot.sh @@ -1,5 +1,5 @@ #! /bin/bash -DISPLAY=:0 scrot -z ~/Images/Wallpapers/lockscreen.png +gnome-screenshot --display=':0' -f ~/Images/Wallpapers/lockscreen.png convert -blur 0x3 ~/Images/Wallpapers/lockscreen.png ~/Images/Wallpapers/lockscreen.png -dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock \ No newline at end of file +dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock From 35731aed7fddadf5c8bb0d7f1c678c0e8887998c Mon Sep 17 00:00:00 2001 From: trotFunky Date: Tue, 9 Apr 2019 22:17:30 +0200 Subject: [PATCH 058/120] Scrot ne marche plus sous wayland, sad :( --- Perso/locksreenshot.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Perso/locksreenshot.sh b/Perso/locksreenshot.sh index 6d8c5d6..fc2b9ad 100755 --- a/Perso/locksreenshot.sh +++ b/Perso/locksreenshot.sh @@ -1,5 +1,5 @@ #! /bin/bash -DISPLAY=:0 scrot -z ~/Images/Wallpapers/lockscreen.png +gnome-screenshot --display=':0' -f ~/Images/Wallpapers/lockscreen.png convert -blur 0x3 ~/Images/Wallpapers/lockscreen.png ~/Images/Wallpapers/lockscreen.png -dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock \ No newline at end of file +dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock From de4d3026fee90d0a7724f8a21c78c067d5748a12 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 059/120] Repassage sur X11 donc scrot --- Perso/locksreenshot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Perso/locksreenshot.sh b/Perso/locksreenshot.sh index fc2b9ad..fca8945 100755 --- a/Perso/locksreenshot.sh +++ b/Perso/locksreenshot.sh @@ -1,5 +1,5 @@ #! /bin/bash -gnome-screenshot --display=':0' -f ~/Images/Wallpapers/lockscreen.png +DISPLAY=':1' scrot -z ~/Images/Wallpapers/lockscreen.png convert -blur 0x3 ~/Images/Wallpapers/lockscreen.png ~/Images/Wallpapers/lockscreen.png dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock From 234a0e912850927ffb27a8d89760262dad35c9ac Mon Sep 17 00:00:00 2001 From: trotFunky Date: Tue, 9 Apr 2019 22:56:19 +0200 Subject: [PATCH 060/120] Repassage sur X11 donc scrot --- Perso/locksreenshot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Perso/locksreenshot.sh b/Perso/locksreenshot.sh index fc2b9ad..fca8945 100755 --- a/Perso/locksreenshot.sh +++ b/Perso/locksreenshot.sh @@ -1,5 +1,5 @@ #! /bin/bash -gnome-screenshot --display=':0' -f ~/Images/Wallpapers/lockscreen.png +DISPLAY=':1' scrot -z ~/Images/Wallpapers/lockscreen.png convert -blur 0x3 ~/Images/Wallpapers/lockscreen.png ~/Images/Wallpapers/lockscreen.png dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock From 398e4a5643c8d987ebe5f143c6a6c2fefb2f8a67 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 061/120] =?UTF-8?q?Script=20de=20mise=20=C3=A0=20jour=20po?= =?UTF-8?q?ur=20d=C3=A9p=C3=B4ts=20bare?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/INTech/gitUpdate.sh | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 Perso/INTech/gitUpdate.sh diff --git a/Perso/INTech/gitUpdate.sh b/Perso/INTech/gitUpdate.sh new file mode 100755 index 0000000..4feb0fe --- /dev/null +++ b/Perso/INTech/gitUpdate.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +GIT_REPO="." +WORK_DIR="~/.gitAutoPull" + +if [ $# -gt 0 ]; then + GIT_REPO="$1" +fi + +GIT_REPO_NAME="$(echo '$GIT_REPO' | tr '/' '_' | tr -d '~')" +CHECK_TIMER_FILE=$WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" + +if [ ! -d "$GIT_REPO/.git/" ]; then + echo $GIT_REPO" is not a git repository" + exit -2 +fi + +if [ ! -d $WORK_DIR ]; then + mkdir $WORK_DIR +fi + +if [ ! -d $WORK_DIR ]; then + echo "Could not create work directory, aborting" + exit -4 +fi + +cd $GIT_REPO + +if [ -e $CHECK_TIMER_FILE ]; then + read count < $CHECK_TIMER_FILE + if [ $cout -ne 0 ]; then + echo $(( $count - 1 )) > $CHECK_TIMER_FILE + exit -1 + else + rm -f $CHECK_TIMER_FILE + fi +fi + +remoteStatus="$(git fetch --all --dry-run)" # Empty if there are no commits to fetch +localStatus="$(git push -n --porcelain | grep -e'up to date')" # Empty if there are commits to push + +if [ -z "$remoteStatus" ]; then + if [ -z "$localStatus" ]; then + echo "Pushing "$GIT_REPO" updates to origin" | wall + git push | wall + exit 1 + fi +else + if [ -z "localStatus" ]; then + echo "Local and remote diverged, stopping auto-update for 30 iterations..." | wall + echo 30 > $WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" + else + echo "Updating "$GIT_REPO" with remote commits" | wall + git fetch --all | wall + git remote update | wall + exit 1 + fi +fi + +exit 0 \ No newline at end of file From ab71845f55ec4b17ae0c6676da6d62f1f79477fb Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Mon, 20 May 2019 01:08:25 +0200 Subject: [PATCH 062/120] =?UTF-8?q?Script=20de=20mise=20=C3=A0=20jour=20po?= =?UTF-8?q?ur=20d=C3=A9p=C3=B4ts=20bare?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/INTech/gitUpdate.sh | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 Perso/INTech/gitUpdate.sh diff --git a/Perso/INTech/gitUpdate.sh b/Perso/INTech/gitUpdate.sh new file mode 100755 index 0000000..4feb0fe --- /dev/null +++ b/Perso/INTech/gitUpdate.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +GIT_REPO="." +WORK_DIR="~/.gitAutoPull" + +if [ $# -gt 0 ]; then + GIT_REPO="$1" +fi + +GIT_REPO_NAME="$(echo '$GIT_REPO' | tr '/' '_' | tr -d '~')" +CHECK_TIMER_FILE=$WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" + +if [ ! -d "$GIT_REPO/.git/" ]; then + echo $GIT_REPO" is not a git repository" + exit -2 +fi + +if [ ! -d $WORK_DIR ]; then + mkdir $WORK_DIR +fi + +if [ ! -d $WORK_DIR ]; then + echo "Could not create work directory, aborting" + exit -4 +fi + +cd $GIT_REPO + +if [ -e $CHECK_TIMER_FILE ]; then + read count < $CHECK_TIMER_FILE + if [ $cout -ne 0 ]; then + echo $(( $count - 1 )) > $CHECK_TIMER_FILE + exit -1 + else + rm -f $CHECK_TIMER_FILE + fi +fi + +remoteStatus="$(git fetch --all --dry-run)" # Empty if there are no commits to fetch +localStatus="$(git push -n --porcelain | grep -e'up to date')" # Empty if there are commits to push + +if [ -z "$remoteStatus" ]; then + if [ -z "$localStatus" ]; then + echo "Pushing "$GIT_REPO" updates to origin" | wall + git push | wall + exit 1 + fi +else + if [ -z "localStatus" ]; then + echo "Local and remote diverged, stopping auto-update for 30 iterations..." | wall + echo 30 > $WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" + else + echo "Updating "$GIT_REPO" with remote commits" | wall + git fetch --all | wall + git remote update | wall + exit 1 + fi +fi + +exit 0 \ No newline at end of file From e5bd0ff9d466fdf8e93c1cf9d9915034b38f6a03 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 063/120] =?UTF-8?q?Modifi=C3=A9=20car=20git=20output=20pri?= =?UTF-8?q?ncipalement=20sur=20stderr=20Modification=20pour=20v=C3=A9rifie?= =?UTF-8?q?r=20si=20c'est=20bien=20un=20d=C3=A9p=C3=B4t=20git=20(Pour=20le?= =?UTF-8?q?s=20bare,=20qui=20n'ont=20donc=20pas=20de=20.git)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/INTech/gitUpdate.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Perso/INTech/gitUpdate.sh b/Perso/INTech/gitUpdate.sh index 4feb0fe..24e9e4f 100755 --- a/Perso/INTech/gitUpdate.sh +++ b/Perso/INTech/gitUpdate.sh @@ -1,7 +1,7 @@ #!/bin/bash GIT_REPO="." -WORK_DIR="~/.gitAutoPull" +WORK_DIR=$HOME"/.gitAutoPull" if [ $# -gt 0 ]; then GIT_REPO="$1" @@ -10,13 +10,20 @@ fi GIT_REPO_NAME="$(echo '$GIT_REPO' | tr '/' '_' | tr -d '~')" CHECK_TIMER_FILE=$WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" -if [ ! -d "$GIT_REPO/.git/" ]; then +cd $GIT_REPO > /dev/null + +if [ $? -ne 0 ]; then + echo $GIT_REPO" Does not exist or is not a directory" + exit -2 +fi + +if [ -z "$(git rev-parse --git-dir 2>/dev/null)" ]; then echo $GIT_REPO" is not a git repository" exit -2 fi if [ ! -d $WORK_DIR ]; then - mkdir $WORK_DIR + mkdir $WORK_DIR > /dev/null fi if [ ! -d $WORK_DIR ]; then @@ -24,8 +31,6 @@ if [ ! -d $WORK_DIR ]; then exit -4 fi -cd $GIT_REPO - if [ -e $CHECK_TIMER_FILE ]; then read count < $CHECK_TIMER_FILE if [ $cout -ne 0 ]; then @@ -36,13 +41,13 @@ if [ -e $CHECK_TIMER_FILE ]; then fi fi -remoteStatus="$(git fetch --all --dry-run)" # Empty if there are no commits to fetch +remoteStatus="$(git fetch --dry-run 2>&1)" # Empty if there are no commits to fetch localStatus="$(git push -n --porcelain | grep -e'up to date')" # Empty if there are commits to push if [ -z "$remoteStatus" ]; then if [ -z "$localStatus" ]; then echo "Pushing "$GIT_REPO" updates to origin" | wall - git push | wall + git push 2>&1 | wall exit 1 fi else @@ -51,8 +56,8 @@ else echo 30 > $WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" else echo "Updating "$GIT_REPO" with remote commits" | wall - git fetch --all | wall - git remote update | wall + git fetch --all 2>&1 | wall + git remote update 2>&1 | wall exit 1 fi fi From a26a4e5eaa7462a97c444570c7c6d3bbfe84877f Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Mon, 20 May 2019 02:36:19 +0200 Subject: [PATCH 064/120] =?UTF-8?q?Modifi=C3=A9=20car=20git=20output=20pri?= =?UTF-8?q?ncipalement=20sur=20stderr=20Modification=20pour=20v=C3=A9rifie?= =?UTF-8?q?r=20si=20c'est=20bien=20un=20d=C3=A9p=C3=B4t=20git=20(Pour=20le?= =?UTF-8?q?s=20bare,=20qui=20n'ont=20donc=20pas=20de=20.git)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/INTech/gitUpdate.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Perso/INTech/gitUpdate.sh b/Perso/INTech/gitUpdate.sh index 4feb0fe..24e9e4f 100755 --- a/Perso/INTech/gitUpdate.sh +++ b/Perso/INTech/gitUpdate.sh @@ -1,7 +1,7 @@ #!/bin/bash GIT_REPO="." -WORK_DIR="~/.gitAutoPull" +WORK_DIR=$HOME"/.gitAutoPull" if [ $# -gt 0 ]; then GIT_REPO="$1" @@ -10,13 +10,20 @@ fi GIT_REPO_NAME="$(echo '$GIT_REPO' | tr '/' '_' | tr -d '~')" CHECK_TIMER_FILE=$WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" -if [ ! -d "$GIT_REPO/.git/" ]; then +cd $GIT_REPO > /dev/null + +if [ $? -ne 0 ]; then + echo $GIT_REPO" Does not exist or is not a directory" + exit -2 +fi + +if [ -z "$(git rev-parse --git-dir 2>/dev/null)" ]; then echo $GIT_REPO" is not a git repository" exit -2 fi if [ ! -d $WORK_DIR ]; then - mkdir $WORK_DIR + mkdir $WORK_DIR > /dev/null fi if [ ! -d $WORK_DIR ]; then @@ -24,8 +31,6 @@ if [ ! -d $WORK_DIR ]; then exit -4 fi -cd $GIT_REPO - if [ -e $CHECK_TIMER_FILE ]; then read count < $CHECK_TIMER_FILE if [ $cout -ne 0 ]; then @@ -36,13 +41,13 @@ if [ -e $CHECK_TIMER_FILE ]; then fi fi -remoteStatus="$(git fetch --all --dry-run)" # Empty if there are no commits to fetch +remoteStatus="$(git fetch --dry-run 2>&1)" # Empty if there are no commits to fetch localStatus="$(git push -n --porcelain | grep -e'up to date')" # Empty if there are commits to push if [ -z "$remoteStatus" ]; then if [ -z "$localStatus" ]; then echo "Pushing "$GIT_REPO" updates to origin" | wall - git push | wall + git push 2>&1 | wall exit 1 fi else @@ -51,8 +56,8 @@ else echo 30 > $WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" else echo "Updating "$GIT_REPO" with remote commits" | wall - git fetch --all | wall - git remote update | wall + git fetch --all 2>&1 | wall + git remote update 2>&1 | wall exit 1 fi fi From 2ac286797b3d76c9febe831cf5a01ede8fb34157 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 065/120] =?UTF-8?q?Correction=20du=20cas=20o=C3=B9=20on=20?= =?UTF-8?q?a=20des=20commits=20locaux=20donc=20le=20fetch=20indique=20quel?= =?UTF-8?q?que=20chose=20Gestion=20de=20plusieurs=20d=C3=A9p=C3=B4ts=20par?= =?UTF-8?q?=20un=20script=20Changements=20utilitaires=20pour=20le=20wall?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/INTech/gitUpdate.sh | 114 ++++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 54 deletions(-) diff --git a/Perso/INTech/gitUpdate.sh b/Perso/INTech/gitUpdate.sh index 24e9e4f..629642d 100755 --- a/Perso/INTech/gitUpdate.sh +++ b/Perso/INTech/gitUpdate.sh @@ -1,65 +1,71 @@ #!/bin/bash - -GIT_REPO="." +export LC_ALL=POSIX WORK_DIR=$HOME"/.gitAutoPull" +work_array="." + if [ $# -gt 0 ]; then - GIT_REPO="$1" + work_array=$@ fi -GIT_REPO_NAME="$(echo '$GIT_REPO' | tr '/' '_' | tr -d '~')" -CHECK_TIMER_FILE=$WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" +for GIT_REPO in $work_array ; do -cd $GIT_REPO > /dev/null - -if [ $? -ne 0 ]; then - echo $GIT_REPO" Does not exist or is not a directory" - exit -2 -fi - -if [ -z "$(git rev-parse --git-dir 2>/dev/null)" ]; then - echo $GIT_REPO" is not a git repository" - exit -2 -fi - -if [ ! -d $WORK_DIR ]; then - mkdir $WORK_DIR > /dev/null -fi - -if [ ! -d $WORK_DIR ]; then - echo "Could not create work directory, aborting" - exit -4 -fi - -if [ -e $CHECK_TIMER_FILE ]; then - read count < $CHECK_TIMER_FILE - if [ $cout -ne 0 ]; then - echo $(( $count - 1 )) > $CHECK_TIMER_FILE - exit -1 + GIT_REPO_NAME="$(echo '$GIT_REPO' | tr '/' '_' | tr -d '~')" + CHECK_TIMER_FILE=$WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" + + cd $GIT_REPO > /dev/null + + if [ $? -ne 0 ]; then + echo $GIT_REPO" Does not exist or is not a directory" + exit -2 + fi + + if [ -z "$(git rev-parse --git-dir 2>/dev/null)" ]; then + echo $GIT_REPO" is not a git repository" + exit -2 + fi + + if [ ! -d $WORK_DIR ]; then + mkdir $WORK_DIR > /dev/null + fi + + if [ ! -d $WORK_DIR ]; then + echo "Could not create work directory, aborting" + exit -4 + fi + + if [ -e $CHECK_TIMER_FILE ]; then + read count < $CHECK_TIMER_FILE + if [ $cout -ne 0 ]; then + echo $(( $count - 1 )) > $CHECK_TIMER_FILE + exit -1 + else + rm -f $CHECK_TIMER_FILE + fi + fi + + remoteStatus="$(git fetch --dry-run 2>&1 | tail -n 1 | grep -v -e'+')" # Empty if there are no commits to fetch + localStatus="$(git push -n --porcelain | grep -e'up to date')" # Empty if there are commits to push + + { + if [ -z "$remoteStatus" ]; then + if [ -z "$localStatus" ]; then + echo "Pushing "$GIT_REPO" updates to origin" + git push 2>&1 + exit 1 + fi else - rm -f $CHECK_TIMER_FILE - fi -fi + if [ -z "localStatus" ]; then + echo "Local and remote diverged, stopping auto-update for 30 iterations..." + echo 30 > $WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" + else + echo "Updating "$GIT_REPO" with remote commits" + git fetch --all 2>&1 + git remote update 2>&1 + exit 1 + fi + fi } | wall -remoteStatus="$(git fetch --dry-run 2>&1)" # Empty if there are no commits to fetch -localStatus="$(git push -n --porcelain | grep -e'up to date')" # Empty if there are commits to push - -if [ -z "$remoteStatus" ]; then - if [ -z "$localStatus" ]; then - echo "Pushing "$GIT_REPO" updates to origin" | wall - git push 2>&1 | wall - exit 1 - fi -else - if [ -z "localStatus" ]; then - echo "Local and remote diverged, stopping auto-update for 30 iterations..." | wall - echo 30 > $WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" - else - echo "Updating "$GIT_REPO" with remote commits" | wall - git fetch --all 2>&1 | wall - git remote update 2>&1 | wall - exit 1 - fi -fi +done exit 0 \ No newline at end of file From 27776d5a128eb4ce8297d0135ed7353887a6d7b2 Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Mon, 20 May 2019 15:55:09 +0200 Subject: [PATCH 066/120] =?UTF-8?q?Correction=20du=20cas=20o=C3=B9=20on=20?= =?UTF-8?q?a=20des=20commits=20locaux=20donc=20le=20fetch=20indique=20quel?= =?UTF-8?q?que=20chose=20Gestion=20de=20plusieurs=20d=C3=A9p=C3=B4ts=20par?= =?UTF-8?q?=20un=20script=20Changements=20utilitaires=20pour=20le=20wall?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/INTech/gitUpdate.sh | 114 ++++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 54 deletions(-) diff --git a/Perso/INTech/gitUpdate.sh b/Perso/INTech/gitUpdate.sh index 24e9e4f..629642d 100755 --- a/Perso/INTech/gitUpdate.sh +++ b/Perso/INTech/gitUpdate.sh @@ -1,65 +1,71 @@ #!/bin/bash - -GIT_REPO="." +export LC_ALL=POSIX WORK_DIR=$HOME"/.gitAutoPull" +work_array="." + if [ $# -gt 0 ]; then - GIT_REPO="$1" + work_array=$@ fi -GIT_REPO_NAME="$(echo '$GIT_REPO' | tr '/' '_' | tr -d '~')" -CHECK_TIMER_FILE=$WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" +for GIT_REPO in $work_array ; do -cd $GIT_REPO > /dev/null - -if [ $? -ne 0 ]; then - echo $GIT_REPO" Does not exist or is not a directory" - exit -2 -fi - -if [ -z "$(git rev-parse --git-dir 2>/dev/null)" ]; then - echo $GIT_REPO" is not a git repository" - exit -2 -fi - -if [ ! -d $WORK_DIR ]; then - mkdir $WORK_DIR > /dev/null -fi - -if [ ! -d $WORK_DIR ]; then - echo "Could not create work directory, aborting" - exit -4 -fi - -if [ -e $CHECK_TIMER_FILE ]; then - read count < $CHECK_TIMER_FILE - if [ $cout -ne 0 ]; then - echo $(( $count - 1 )) > $CHECK_TIMER_FILE - exit -1 + GIT_REPO_NAME="$(echo '$GIT_REPO' | tr '/' '_' | tr -d '~')" + CHECK_TIMER_FILE=$WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" + + cd $GIT_REPO > /dev/null + + if [ $? -ne 0 ]; then + echo $GIT_REPO" Does not exist or is not a directory" + exit -2 + fi + + if [ -z "$(git rev-parse --git-dir 2>/dev/null)" ]; then + echo $GIT_REPO" is not a git repository" + exit -2 + fi + + if [ ! -d $WORK_DIR ]; then + mkdir $WORK_DIR > /dev/null + fi + + if [ ! -d $WORK_DIR ]; then + echo "Could not create work directory, aborting" + exit -4 + fi + + if [ -e $CHECK_TIMER_FILE ]; then + read count < $CHECK_TIMER_FILE + if [ $cout -ne 0 ]; then + echo $(( $count - 1 )) > $CHECK_TIMER_FILE + exit -1 + else + rm -f $CHECK_TIMER_FILE + fi + fi + + remoteStatus="$(git fetch --dry-run 2>&1 | tail -n 1 | grep -v -e'+')" # Empty if there are no commits to fetch + localStatus="$(git push -n --porcelain | grep -e'up to date')" # Empty if there are commits to push + + { + if [ -z "$remoteStatus" ]; then + if [ -z "$localStatus" ]; then + echo "Pushing "$GIT_REPO" updates to origin" + git push 2>&1 + exit 1 + fi else - rm -f $CHECK_TIMER_FILE - fi -fi + if [ -z "localStatus" ]; then + echo "Local and remote diverged, stopping auto-update for 30 iterations..." + echo 30 > $WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" + else + echo "Updating "$GIT_REPO" with remote commits" + git fetch --all 2>&1 + git remote update 2>&1 + exit 1 + fi + fi } | wall -remoteStatus="$(git fetch --dry-run 2>&1)" # Empty if there are no commits to fetch -localStatus="$(git push -n --porcelain | grep -e'up to date')" # Empty if there are commits to push - -if [ -z "$remoteStatus" ]; then - if [ -z "$localStatus" ]; then - echo "Pushing "$GIT_REPO" updates to origin" | wall - git push 2>&1 | wall - exit 1 - fi -else - if [ -z "localStatus" ]; then - echo "Local and remote diverged, stopping auto-update for 30 iterations..." | wall - echo 30 > $WORK_DIR/localCommitsCheck"$GIT_REPO_NAME" - else - echo "Updating "$GIT_REPO" with remote commits" | wall - git fetch --all 2>&1 | wall - git remote update 2>&1 | wall - exit 1 - fi -fi +done exit 0 \ No newline at end of file From 13a4f4ae577b4afce9731316d15286e12212ad8c Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 067/120] Premier jet timer update --- Perso/systemd_timers/gitUpdate.service | 7 +++++++ Perso/systemd_timers/gitUpdate.timer | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 Perso/systemd_timers/gitUpdate.service create mode 100644 Perso/systemd_timers/gitUpdate.timer diff --git a/Perso/systemd_timers/gitUpdate.service b/Perso/systemd_timers/gitUpdate.service new file mode 100644 index 0000000..a38072d --- /dev/null +++ b/Perso/systemd_timers/gitUpdate.service @@ -0,0 +1,7 @@ +[Unit] +Description=Updates git repos + +[Service] +Type=oneshot +User=intech +ExecStart=/bin/bash ~/git_repos/gitUpdate.sh "/home/intech/git_repos/TechTheTachyon-HighLevel.git" "/home/intech/git_repos/TechTheTachyon-LowLevel.git" \ No newline at end of file diff --git a/Perso/systemd_timers/gitUpdate.timer b/Perso/systemd_timers/gitUpdate.timer new file mode 100644 index 0000000..5110325 --- /dev/null +++ b/Perso/systemd_timers/gitUpdate.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Updates git repos + +[Timer] +OnBootSec=5min +OnUnitActiveSec=1min + +[Install] +WantedBy=timers.target From 03ea6eafc8ea4eaaa98235c38a43e50e091298b9 Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Mon, 20 May 2019 16:12:57 +0200 Subject: [PATCH 068/120] Premier jet timer update --- Perso/systemd_timers/gitUpdate.service | 7 +++++++ Perso/systemd_timers/gitUpdate.timer | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 Perso/systemd_timers/gitUpdate.service create mode 100644 Perso/systemd_timers/gitUpdate.timer diff --git a/Perso/systemd_timers/gitUpdate.service b/Perso/systemd_timers/gitUpdate.service new file mode 100644 index 0000000..a38072d --- /dev/null +++ b/Perso/systemd_timers/gitUpdate.service @@ -0,0 +1,7 @@ +[Unit] +Description=Updates git repos + +[Service] +Type=oneshot +User=intech +ExecStart=/bin/bash ~/git_repos/gitUpdate.sh "/home/intech/git_repos/TechTheTachyon-HighLevel.git" "/home/intech/git_repos/TechTheTachyon-LowLevel.git" \ No newline at end of file diff --git a/Perso/systemd_timers/gitUpdate.timer b/Perso/systemd_timers/gitUpdate.timer new file mode 100644 index 0000000..5110325 --- /dev/null +++ b/Perso/systemd_timers/gitUpdate.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Updates git repos + +[Timer] +OnBootSec=5min +OnUnitActiveSec=1min + +[Install] +WantedBy=timers.target From 92062ff0139e0fcb1391afb4bbeef11410be5e38 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 069/120] =?UTF-8?q?Modification=20pour=20lancer=20le=20scr?= =?UTF-8?q?ipt=20et=20=C3=A9viter=20le=20spam=20de=20wall=20vides?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/INTech/gitUpdate.sh | 8 ++++++-- Perso/systemd_timers/gitUpdate.service | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Perso/INTech/gitUpdate.sh b/Perso/INTech/gitUpdate.sh index 629642d..9fb8f76 100755 --- a/Perso/INTech/gitUpdate.sh +++ b/Perso/INTech/gitUpdate.sh @@ -47,7 +47,7 @@ for GIT_REPO in $work_array ; do remoteStatus="$(git fetch --dry-run 2>&1 | tail -n 1 | grep -v -e'+')" # Empty if there are no commits to fetch localStatus="$(git push -n --porcelain | grep -e'up to date')" # Empty if there are commits to push - { + output=$( if [ -z "$remoteStatus" ]; then if [ -z "$localStatus" ]; then echo "Pushing "$GIT_REPO" updates to origin" @@ -64,8 +64,12 @@ for GIT_REPO in $work_array ; do git remote update 2>&1 exit 1 fi - fi } | wall + fi ) + if [ ! -z "$output" ]; then + echo "$output" | wall + fi + done exit 0 \ No newline at end of file diff --git a/Perso/systemd_timers/gitUpdate.service b/Perso/systemd_timers/gitUpdate.service index a38072d..90e03de 100644 --- a/Perso/systemd_timers/gitUpdate.service +++ b/Perso/systemd_timers/gitUpdate.service @@ -4,4 +4,4 @@ Description=Updates git repos [Service] Type=oneshot User=intech -ExecStart=/bin/bash ~/git_repos/gitUpdate.sh "/home/intech/git_repos/TechTheTachyon-HighLevel.git" "/home/intech/git_repos/TechTheTachyon-LowLevel.git" \ No newline at end of file +ExecStart=/bin/bash /home/intech/git_repos/gitUpdate.sh "/home/intech/git_repos/TechTheTachyon-HighLevel.git" "/home/intech/git_repos/TechTheTachyon-LowLevel.git" \ No newline at end of file From 9c881c366e6cb1fbfe572587690b8467ff55185e Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Mon, 20 May 2019 17:05:13 +0200 Subject: [PATCH 070/120] =?UTF-8?q?Modification=20pour=20lancer=20le=20scr?= =?UTF-8?q?ipt=20et=20=C3=A9viter=20le=20spam=20de=20wall=20vides?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/INTech/gitUpdate.sh | 8 ++++++-- Perso/systemd_timers/gitUpdate.service | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Perso/INTech/gitUpdate.sh b/Perso/INTech/gitUpdate.sh index 629642d..9fb8f76 100755 --- a/Perso/INTech/gitUpdate.sh +++ b/Perso/INTech/gitUpdate.sh @@ -47,7 +47,7 @@ for GIT_REPO in $work_array ; do remoteStatus="$(git fetch --dry-run 2>&1 | tail -n 1 | grep -v -e'+')" # Empty if there are no commits to fetch localStatus="$(git push -n --porcelain | grep -e'up to date')" # Empty if there are commits to push - { + output=$( if [ -z "$remoteStatus" ]; then if [ -z "$localStatus" ]; then echo "Pushing "$GIT_REPO" updates to origin" @@ -64,8 +64,12 @@ for GIT_REPO in $work_array ; do git remote update 2>&1 exit 1 fi - fi } | wall + fi ) + if [ ! -z "$output" ]; then + echo "$output" | wall + fi + done exit 0 \ No newline at end of file diff --git a/Perso/systemd_timers/gitUpdate.service b/Perso/systemd_timers/gitUpdate.service index a38072d..90e03de 100644 --- a/Perso/systemd_timers/gitUpdate.service +++ b/Perso/systemd_timers/gitUpdate.service @@ -4,4 +4,4 @@ Description=Updates git repos [Service] Type=oneshot User=intech -ExecStart=/bin/bash ~/git_repos/gitUpdate.sh "/home/intech/git_repos/TechTheTachyon-HighLevel.git" "/home/intech/git_repos/TechTheTachyon-LowLevel.git" \ No newline at end of file +ExecStart=/bin/bash /home/intech/git_repos/gitUpdate.sh "/home/intech/git_repos/TechTheTachyon-HighLevel.git" "/home/intech/git_repos/TechTheTachyon-LowLevel.git" \ No newline at end of file From 0757988b4df408f33facd2843dcd12edd0d04e2c Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 071/120] =?UTF-8?q?Correction=20pour=20prendre=20en=20comp?= =?UTF-8?q?te=20les=20cas=20chelous=20o=C3=B9=20c'est=20=C3=A0=20jour=20pa?= =?UTF-8?q?s=20pas=20de=20[up=20to=20date]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/INTech/gitUpdate.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Perso/INTech/gitUpdate.sh b/Perso/INTech/gitUpdate.sh index 9fb8f76..6e96e64 100755 --- a/Perso/INTech/gitUpdate.sh +++ b/Perso/INTech/gitUpdate.sh @@ -45,8 +45,22 @@ for GIT_REPO in $work_array ; do fi remoteStatus="$(git fetch --dry-run 2>&1 | tail -n 1 | grep -v -e'+')" # Empty if there are no commits to fetch - localStatus="$(git push -n --porcelain | grep -e'up to date')" # Empty if there are commits to push - + + refChanges=$(git push -n --porcelain | grep -e'refs') + nbRefs=$(echo "$refChanges" | wc -l) + nbNonPushRefs=$(echo $(echo "$refChanges" | cut -f1) | wc -w) + + + localStatus="Nothing to do" # Empty if there are commits to push + + if [ ! -z $(echo $refChanges | grep -e"*") ]; then + localStatus="" + fi + + if [ ! $nbRefs -eq $nbNonPushRefs ]; then + localStatus="" + fi + output=$( if [ -z "$remoteStatus" ]; then if [ -z "$localStatus" ]; then From 2184e036a30c881c08bf37bbe1a63916161a1fe3 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 20 May 2019 23:36:42 +0200 Subject: [PATCH 072/120] =?UTF-8?q?Correction=20pour=20prendre=20en=20comp?= =?UTF-8?q?te=20les=20cas=20chelous=20o=C3=B9=20c'est=20=C3=A0=20jour=20pa?= =?UTF-8?q?s=20pas=20de=20[up=20to=20date]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/INTech/gitUpdate.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Perso/INTech/gitUpdate.sh b/Perso/INTech/gitUpdate.sh index 9fb8f76..6e96e64 100755 --- a/Perso/INTech/gitUpdate.sh +++ b/Perso/INTech/gitUpdate.sh @@ -45,8 +45,22 @@ for GIT_REPO in $work_array ; do fi remoteStatus="$(git fetch --dry-run 2>&1 | tail -n 1 | grep -v -e'+')" # Empty if there are no commits to fetch - localStatus="$(git push -n --porcelain | grep -e'up to date')" # Empty if there are commits to push - + + refChanges=$(git push -n --porcelain | grep -e'refs') + nbRefs=$(echo "$refChanges" | wc -l) + nbNonPushRefs=$(echo $(echo "$refChanges" | cut -f1) | wc -w) + + + localStatus="Nothing to do" # Empty if there are commits to push + + if [ ! -z $(echo $refChanges | grep -e"*") ]; then + localStatus="" + fi + + if [ ! $nbRefs -eq $nbNonPushRefs ]; then + localStatus="" + fi + output=$( if [ -z "$remoteStatus" ]; then if [ -z "$localStatus" ]; then From e4f76bf328076e557394810d72aa00280eaa401f Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 14:26:09 +0100 Subject: [PATCH 073/120] Wrote an apt watcher script --- Perso/AptUpdateWatcher.sh | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 Perso/AptUpdateWatcher.sh diff --git a/Perso/AptUpdateWatcher.sh b/Perso/AptUpdateWatcher.sh new file mode 100755 index 0000000..ee0afbe --- /dev/null +++ b/Perso/AptUpdateWatcher.sh @@ -0,0 +1,61 @@ +#! /bin/bash + +# This script updates the apt database if running as root and retrieves the number of upgradable packages. +# If the count is high enough or if some important packages can be upgraded, inform the administrator. + + +while getopts ":c:p:h" option; do + case ${option} in + c ) + trigger_count=$OPTARG + ;; + p ) + # Add each matching option to the array + key_packages+=("$OPTARG") + ;; + h | \? | : ) + echo "Usage : AptUpdateWatcher [-c count] [-p package matching regex] [-h] [-?]" + echo " -c : Change the minimum count of upgradable packages before sending a warning" + echo " -p : Add an expression to watch for important packages. If a package matching this option is found, send a warning" + echo " -h/-? : Prints this message" + exit 1 + ;; + esac +done + +# Use default options if nothing provided + +if [ -z "$trigger_count" ]; then + trigger_count=20 +fi + +if [ -z "$key_packages" ]; then + key_packages=( "ssh" "ssl" "apache" "kernel" ) +fi + + +if [ "$EUID" -eq 0 ]; then + apt-get update +fi + +upgradable_packages="$(apt-get -s -V upgrade | grep -e'=>')" +upgradable_count=$(echo "$upgradable_packages" | wc -l) + +if [ $upgradable_count -gt $trigger_count ]; then + output="There are more than $trigger_count packages ready to upgrade ($upgradable_count packages):\n" + output+="$upgradable_packages\n\n" +fi + +for expression in "${key_packages[@]}"; do + matching_packages=$(echo "$upgradable_packages" | grep -e"$expression") + if [ -n "$matching_packages" ]; then + output+="Packages matching the expression '""$expression""' can be upgraded: \n" + output+="$matching_packages\n\n" + fi +done + +if [ -n "$output" ]; then + output="The Apt Update Watcher has been triggered.\n\n""$output" + + echo -e "$output" # Can be replaced by anything or piped into sendmail +fi From 64527ae96ac402080cf5154377a7e84486a2f219 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sat, 7 Dec 2019 22:13:13 +0100 Subject: [PATCH 074/120] Wrote an apt watcher script --- Perso/AptUpdateWatcher.sh | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 Perso/AptUpdateWatcher.sh diff --git a/Perso/AptUpdateWatcher.sh b/Perso/AptUpdateWatcher.sh new file mode 100755 index 0000000..ee0afbe --- /dev/null +++ b/Perso/AptUpdateWatcher.sh @@ -0,0 +1,61 @@ +#! /bin/bash + +# This script updates the apt database if running as root and retrieves the number of upgradable packages. +# If the count is high enough or if some important packages can be upgraded, inform the administrator. + + +while getopts ":c:p:h" option; do + case ${option} in + c ) + trigger_count=$OPTARG + ;; + p ) + # Add each matching option to the array + key_packages+=("$OPTARG") + ;; + h | \? | : ) + echo "Usage : AptUpdateWatcher [-c count] [-p package matching regex] [-h] [-?]" + echo " -c : Change the minimum count of upgradable packages before sending a warning" + echo " -p : Add an expression to watch for important packages. If a package matching this option is found, send a warning" + echo " -h/-? : Prints this message" + exit 1 + ;; + esac +done + +# Use default options if nothing provided + +if [ -z "$trigger_count" ]; then + trigger_count=20 +fi + +if [ -z "$key_packages" ]; then + key_packages=( "ssh" "ssl" "apache" "kernel" ) +fi + + +if [ "$EUID" -eq 0 ]; then + apt-get update +fi + +upgradable_packages="$(apt-get -s -V upgrade | grep -e'=>')" +upgradable_count=$(echo "$upgradable_packages" | wc -l) + +if [ $upgradable_count -gt $trigger_count ]; then + output="There are more than $trigger_count packages ready to upgrade ($upgradable_count packages):\n" + output+="$upgradable_packages\n\n" +fi + +for expression in "${key_packages[@]}"; do + matching_packages=$(echo "$upgradable_packages" | grep -e"$expression") + if [ -n "$matching_packages" ]; then + output+="Packages matching the expression '""$expression""' can be upgraded: \n" + output+="$matching_packages\n\n" + fi +done + +if [ -n "$output" ]; then + output="The Apt Update Watcher has been triggered.\n\n""$output" + + echo -e "$output" # Can be replaced by anything or piped into sendmail +fi From d8fa66baa6fb01307231b1247adab840d49b3f56 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 15:07:53 +0100 Subject: [PATCH 075/120] Changed the structure, added README --- {Perso => INTech}/MATCH_BEGIN.sh | 0 {Perso => INTech}/auto_config.sh | 0 {Perso/INTech => INTech}/gitUpdate.sh | 0 Perso/.gitignore | 1 + Perso/serialOutput/.gitignore | 1 - README.md | 9 +++++++++ 6 files changed, 10 insertions(+), 1 deletion(-) rename {Perso => INTech}/MATCH_BEGIN.sh (100%) rename {Perso => INTech}/auto_config.sh (100%) rename {Perso/INTech => INTech}/gitUpdate.sh (100%) create mode 100644 Perso/.gitignore delete mode 100644 Perso/serialOutput/.gitignore create mode 100644 README.md diff --git a/Perso/MATCH_BEGIN.sh b/INTech/MATCH_BEGIN.sh similarity index 100% rename from Perso/MATCH_BEGIN.sh rename to INTech/MATCH_BEGIN.sh diff --git a/Perso/auto_config.sh b/INTech/auto_config.sh similarity index 100% rename from Perso/auto_config.sh rename to INTech/auto_config.sh diff --git a/Perso/INTech/gitUpdate.sh b/INTech/gitUpdate.sh similarity index 100% rename from Perso/INTech/gitUpdate.sh rename to INTech/gitUpdate.sh diff --git a/Perso/.gitignore b/Perso/.gitignore new file mode 100644 index 0000000..59c92fa --- /dev/null +++ b/Perso/.gitignore @@ -0,0 +1 @@ +serialOutput/ diff --git a/Perso/serialOutput/.gitignore b/Perso/serialOutput/.gitignore deleted file mode 100644 index 5c87cb1..0000000 --- a/Perso/serialOutput/.gitignore +++ /dev/null @@ -1 +0,0 @@ -serialOutput* diff --git a/README.md b/README.md new file mode 100644 index 0000000..5f53a8d --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Shell scripts + +This repository contains shell scripts that I wrote for myself, my robotics club or my server, mainly in Bash. +It also contains some timer services for systemd. + +## Structure + + - Perso : Personal scripts + - INTech : Scripts made for INTech, my robotics club From 4bcec25c2eb5b49cf00a6a68dbaf10fe38e3b120 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 15:07:53 +0100 Subject: [PATCH 076/120] Changed the structure, added README --- {Perso => INTech}/MATCH_BEGIN.sh | 0 {Perso => INTech}/auto_config.sh | 0 {Perso/INTech => INTech}/gitUpdate.sh | 0 Perso/.gitignore | 1 + Perso/serialOutput/.gitignore | 1 - README.md | 9 +++++++++ 6 files changed, 10 insertions(+), 1 deletion(-) rename {Perso => INTech}/MATCH_BEGIN.sh (100%) rename {Perso => INTech}/auto_config.sh (100%) rename {Perso/INTech => INTech}/gitUpdate.sh (100%) create mode 100644 Perso/.gitignore delete mode 100644 Perso/serialOutput/.gitignore create mode 100644 README.md diff --git a/Perso/MATCH_BEGIN.sh b/INTech/MATCH_BEGIN.sh similarity index 100% rename from Perso/MATCH_BEGIN.sh rename to INTech/MATCH_BEGIN.sh diff --git a/Perso/auto_config.sh b/INTech/auto_config.sh similarity index 100% rename from Perso/auto_config.sh rename to INTech/auto_config.sh diff --git a/Perso/INTech/gitUpdate.sh b/INTech/gitUpdate.sh similarity index 100% rename from Perso/INTech/gitUpdate.sh rename to INTech/gitUpdate.sh diff --git a/Perso/.gitignore b/Perso/.gitignore new file mode 100644 index 0000000..59c92fa --- /dev/null +++ b/Perso/.gitignore @@ -0,0 +1 @@ +serialOutput/ diff --git a/Perso/serialOutput/.gitignore b/Perso/serialOutput/.gitignore deleted file mode 100644 index 5c87cb1..0000000 --- a/Perso/serialOutput/.gitignore +++ /dev/null @@ -1 +0,0 @@ -serialOutput* diff --git a/README.md b/README.md new file mode 100644 index 0000000..5f53a8d --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Shell scripts + +This repository contains shell scripts that I wrote for myself, my robotics club or my server, mainly in Bash. +It also contains some timer services for systemd. + +## Structure + + - Perso : Personal scripts + - INTech : Scripts made for INTech, my robotics club From bed784128fbc7ee8f3ed1b95bf2f1099e3b491e2 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 15:16:48 +0100 Subject: [PATCH 077/120] Moved some scripts to a VPS directory --- Perso/package_restore.sh | 16 ---------------- README.md | 2 ++ {Perso => VPS}/AptUpdateWatcher.sh | 0 {Perso => VPS}/package_save.sh | 0 4 files changed, 2 insertions(+), 16 deletions(-) delete mode 100755 Perso/package_restore.sh rename {Perso => VPS}/AptUpdateWatcher.sh (100%) rename {Perso => VPS}/package_save.sh (100%) diff --git a/Perso/package_restore.sh b/Perso/package_restore.sh deleted file mode 100755 index 7fad345..0000000 --- a/Perso/package_restore.sh +++ /dev/null @@ -1,16 +0,0 @@ -#! /bin/bash - -if [ $(id -u) -ne "0" ]; then - echo "Please execute with superuser privileges" - exit -1 -fi - -cp ./sources.list /etc/apt/sources.list -cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences -cp -r ./sources.list.d/* /etc/apt/sources.list.d - -apt-get update -apt-get install dselect -dpkg --set-selections < "manual_package_save" -apt-get dselect-upgrade -apt-get remove dselect \ No newline at end of file diff --git a/README.md b/README.md index 5f53a8d..ff65606 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,5 @@ It also contains some timer services for systemd. - Perso : Personal scripts - INTech : Scripts made for INTech, my robotics club + - VPS : Scripts mainly used on my server + diff --git a/Perso/AptUpdateWatcher.sh b/VPS/AptUpdateWatcher.sh similarity index 100% rename from Perso/AptUpdateWatcher.sh rename to VPS/AptUpdateWatcher.sh diff --git a/Perso/package_save.sh b/VPS/package_save.sh similarity index 100% rename from Perso/package_save.sh rename to VPS/package_save.sh From 7be8a138896f6609a02c75956a7a907596ed04fb Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 15:16:48 +0100 Subject: [PATCH 078/120] Moved some scripts to a VPS directory --- Perso/package_restore.sh | 16 ---------------- README.md | 2 ++ {Perso => VPS}/AptUpdateWatcher.sh | 0 {Perso => VPS}/package_save.sh | 0 4 files changed, 2 insertions(+), 16 deletions(-) delete mode 100755 Perso/package_restore.sh rename {Perso => VPS}/AptUpdateWatcher.sh (100%) rename {Perso => VPS}/package_save.sh (100%) diff --git a/Perso/package_restore.sh b/Perso/package_restore.sh deleted file mode 100755 index 7fad345..0000000 --- a/Perso/package_restore.sh +++ /dev/null @@ -1,16 +0,0 @@ -#! /bin/bash - -if [ $(id -u) -ne "0" ]; then - echo "Please execute with superuser privileges" - exit -1 -fi - -cp ./sources.list /etc/apt/sources.list -cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences -cp -r ./sources.list.d/* /etc/apt/sources.list.d - -apt-get update -apt-get install dselect -dpkg --set-selections < "manual_package_save" -apt-get dselect-upgrade -apt-get remove dselect \ No newline at end of file diff --git a/README.md b/README.md index 5f53a8d..ff65606 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,5 @@ It also contains some timer services for systemd. - Perso : Personal scripts - INTech : Scripts made for INTech, my robotics club + - VPS : Scripts mainly used on my server + diff --git a/Perso/AptUpdateWatcher.sh b/VPS/AptUpdateWatcher.sh similarity index 100% rename from Perso/AptUpdateWatcher.sh rename to VPS/AptUpdateWatcher.sh diff --git a/Perso/package_save.sh b/VPS/package_save.sh similarity index 100% rename from Perso/package_save.sh rename to VPS/package_save.sh From a3f9bab38f323d75ffce2cec5695c13923ab38e8 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 15:24:45 +0100 Subject: [PATCH 079/120] Added mail send --- VPS/AptUpdateWatcher.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/VPS/AptUpdateWatcher.sh b/VPS/AptUpdateWatcher.sh index ee0afbe..c338021 100755 --- a/VPS/AptUpdateWatcher.sh +++ b/VPS/AptUpdateWatcher.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/bash # This script updates the apt database if running as root and retrieves the number of upgradable packages. # If the count is high enough or if some important packages can be upgraded, inform the administrator. @@ -30,7 +30,7 @@ if [ -z "$trigger_count" ]; then fi if [ -z "$key_packages" ]; then - key_packages=( "ssh" "ssl" "apache" "kernel" ) + key_packages=( "ssh" "ssl" "apache" "kernel" "linux-image" "syncthing" "wireguard" ) fi @@ -57,5 +57,5 @@ done if [ -n "$output" ]; then output="The Apt Update Watcher has been triggered.\n\n""$output" - echo -e "$output" # Can be replaced by anything or piped into sendmail + echo -e "$output" | mail -aFrom:"$mail_sender" -s "[$(uname -n)] APT update warning $(date +%D-%Hh%M)" "$mail_recipients" fi From 0a1f9082879a8604ef84d8acf4e0b47ae95c1ab7 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 15:24:45 +0100 Subject: [PATCH 080/120] Added mail send --- VPS/AptUpdateWatcher.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/VPS/AptUpdateWatcher.sh b/VPS/AptUpdateWatcher.sh index ee0afbe..c338021 100755 --- a/VPS/AptUpdateWatcher.sh +++ b/VPS/AptUpdateWatcher.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/bash # This script updates the apt database if running as root and retrieves the number of upgradable packages. # If the count is high enough or if some important packages can be upgraded, inform the administrator. @@ -30,7 +30,7 @@ if [ -z "$trigger_count" ]; then fi if [ -z "$key_packages" ]; then - key_packages=( "ssh" "ssl" "apache" "kernel" ) + key_packages=( "ssh" "ssl" "apache" "kernel" "linux-image" "syncthing" "wireguard" ) fi @@ -57,5 +57,5 @@ done if [ -n "$output" ]; then output="The Apt Update Watcher has been triggered.\n\n""$output" - echo -e "$output" # Can be replaced by anything or piped into sendmail + echo -e "$output" | mail -aFrom:"$mail_sender" -s "[$(uname -n)] APT update warning $(date +%D-%Hh%M)" "$mail_recipients" fi From 3289fafbc0a302e71d1ae55305b023b873a9898b Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 15:25:27 +0100 Subject: [PATCH 081/120] Updated package_save to use here-documents and save/restore apt keyring --- VPS/package_save.sh | 57 ++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/VPS/package_save.sh b/VPS/package_save.sh index 25908b1..2841e31 100755 --- a/VPS/package_save.sh +++ b/VPS/package_save.sh @@ -10,7 +10,7 @@ if [ $# -ne 0 ]; then if [ "$2" = here -o "$1" = here ]; then location="." elif [ ! -z "$2" ]; then - echo "Second argument can be void or 'here' only" + echo "Second argument can only be null or 'here'" exit fi fi @@ -19,45 +19,54 @@ cd $location pathName="$name""_$(date +'%Y-%m-%d @ %Hh%M')" mkdir "$pathName" -cd "./$pathName" +cd "$pathName" mkdir "./preferences.d" cp /etc/apt/sources.list . cp /etc/apt/preferences.d/my_preferences ./preferences.d/ cp -r --copy-contents /etc/apt/sources.list.d . -sudo dpkg --get-selections > "manual_package_save" +dpkg --get-selections > "manual_package_save" +apt-key exportall > "apt_keys" a=C4.sh -echo "#! /bin/bash" > $a -echo "" >> $a -echo "cd .." >> $a -echo "rm -r \"$pathName\"" >> $a +cat < "$a" +#! /bin/bash + +cd .. +rm -r "$pathName" + +EOF chmod u+x "$a" b="package_restore.sh" -echo "#! /bin/bash" > $b -echo "" >> $b -echo 'if [ $(id -u) -ne "0" ]; then' >> $b -echo ' echo "Please execute with superuser privileges"' >> $b -echo " exit -1" >> $b -echo fi >> $b -echo "" >> $b -echo cp ./sources.list /etc/apt/sources.list >> $b -echo cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences >> $b -echo 'cp -r ./sources.list.d/* /etc/apt/sources.list.d' >> $b -echo "" >> $b -echo apt-get update >> $b -echo apt-get install dselect >> $b -echo "dpkg --set-selections < "manual_package_save"" >> $b -echo apt-get dselect-upgrade >> $b -echo apt-get remove dselect >> $b +cat < "$b" +#! /bin/bash" + +if [ $(id -u) -ne "0" ]; then + echo "Please execute with superuser privileges" + exit - +fi + +cp ./sources.list /etc/apt/sources.list +cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences +cp -r ./sources.list.d/* /etc/apt/sources.list.d' + +apt-key add < "apt_keys" +apt-get update +apt-get install dselect +dselect update +dpkg --set-selections < "manual_package_save" +apt-get dselect-upgrade -y +apt-get remove dselect + +EOF chmod u-x "$b" cd - -exit \ No newline at end of file +exit From 4a754e72384c7fad4db6e3adfe5ca2ebeee083a2 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 15:25:27 +0100 Subject: [PATCH 082/120] Updated package_save to use here-documents and save/restore apt keyring --- VPS/package_save.sh | 57 ++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/VPS/package_save.sh b/VPS/package_save.sh index 25908b1..2841e31 100755 --- a/VPS/package_save.sh +++ b/VPS/package_save.sh @@ -10,7 +10,7 @@ if [ $# -ne 0 ]; then if [ "$2" = here -o "$1" = here ]; then location="." elif [ ! -z "$2" ]; then - echo "Second argument can be void or 'here' only" + echo "Second argument can only be null or 'here'" exit fi fi @@ -19,45 +19,54 @@ cd $location pathName="$name""_$(date +'%Y-%m-%d @ %Hh%M')" mkdir "$pathName" -cd "./$pathName" +cd "$pathName" mkdir "./preferences.d" cp /etc/apt/sources.list . cp /etc/apt/preferences.d/my_preferences ./preferences.d/ cp -r --copy-contents /etc/apt/sources.list.d . -sudo dpkg --get-selections > "manual_package_save" +dpkg --get-selections > "manual_package_save" +apt-key exportall > "apt_keys" a=C4.sh -echo "#! /bin/bash" > $a -echo "" >> $a -echo "cd .." >> $a -echo "rm -r \"$pathName\"" >> $a +cat < "$a" +#! /bin/bash + +cd .. +rm -r "$pathName" + +EOF chmod u+x "$a" b="package_restore.sh" -echo "#! /bin/bash" > $b -echo "" >> $b -echo 'if [ $(id -u) -ne "0" ]; then' >> $b -echo ' echo "Please execute with superuser privileges"' >> $b -echo " exit -1" >> $b -echo fi >> $b -echo "" >> $b -echo cp ./sources.list /etc/apt/sources.list >> $b -echo cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences >> $b -echo 'cp -r ./sources.list.d/* /etc/apt/sources.list.d' >> $b -echo "" >> $b -echo apt-get update >> $b -echo apt-get install dselect >> $b -echo "dpkg --set-selections < "manual_package_save"" >> $b -echo apt-get dselect-upgrade >> $b -echo apt-get remove dselect >> $b +cat < "$b" +#! /bin/bash" + +if [ $(id -u) -ne "0" ]; then + echo "Please execute with superuser privileges" + exit - +fi + +cp ./sources.list /etc/apt/sources.list +cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences +cp -r ./sources.list.d/* /etc/apt/sources.list.d' + +apt-key add < "apt_keys" +apt-get update +apt-get install dselect +dselect update +dpkg --set-selections < "manual_package_save" +apt-get dselect-upgrade -y +apt-get remove dselect + +EOF chmod u-x "$b" cd - -exit \ No newline at end of file +exit From 0b98a3b8ee181b39c9a880597343700e9c45ca26 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 15:25:51 +0100 Subject: [PATCH 083/120] Added scripts for backing up and updating Firely-III --- VPS/FireflyUpdate.sh | 68 ++++++++++++++++++++++++++++++++ VPS/restic-backup.sh | 92 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100755 VPS/FireflyUpdate.sh create mode 100755 VPS/restic-backup.sh diff --git a/VPS/FireflyUpdate.sh b/VPS/FireflyUpdate.sh new file mode 100755 index 0000000..e39feda --- /dev/null +++ b/VPS/FireflyUpdate.sh @@ -0,0 +1,68 @@ +#!/bin/bash +set -euo pipefail + +# See documentation at https://docs.firefly-iii.org/advanced-installation/upgrade#created-using-composer-create-project + +if [ "$USER" != "www-data" -a "$USER" != "http" ]; then + echo "Please run this script as the user used by the webserver" + exit 1 +fi + +if [ $# -ne 2 ]; then + echo "Usage : FireflyUpdate /path/to/firefly/rootdir newVersion" + exit 1 +fi + +if [ ! -d "$1" ]; then + echo "Directory does not exist" + exit 1 +fi + + +( + +cd "$1"/.. + +rootDir=$(pwd) +originalDir=$(basename "$1") +newDir="$originalDir"-updated + +echo "Downloading new version..." + +composer create-project grumpydictator/firefly-iii --no-dev --prefer-dist "$originalDir"-updated $2 + +echo "Copying stored data..." + +cp "$1"/.env "$rootDir/$newDir"/.env +cp -r "$1"/storage/{upload,export} "$rootDir/$newDir"/storage +cp "$1"/storage/database/database.sqlite "$rootDir/$newDir"/storage/database/ + +echo "Cleaning caches and running migrations..." + +cd "$newDir" +rm -rf bootstrap/cache/* +php artisan cache:clear +php artisan migrate --seed +php artisan firefly-iii:upgrade-database +php artisan passport:install +php artisan cache:clear + +echo "Forcing access rights to 775 on storage..." + +chmod -R 775 storage + +cd "$rootDir" + +echo "Switching installs..." + +mv "$originalDir" "$originalDir"-old +mv "$newDir" "$originalDir" + +echo "Upgrade done !" +echo "Please check if it was sucessful, if so you can safely run the following command to remove the previous version:" +echo "sudo rm -rf \"$rootDir/$originalDir-old\"" + +) + +exit 0 + diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh new file mode 100755 index 0000000..6557dc1 --- /dev/null +++ b/VPS/restic-backup.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +# Use setcap'd binary in home directory +PATH="/home/restic/bin/:$PATH" + +backup_origin="/backups/restic" +backup_container="central-backup" + +if [[ -z "$1" || "$1" != "daily" && "$1" != "weekly" && "$1" != "monthly" ]]; then + echo "Usage : backup [daily|weekly|monthly]" + exit 1 +fi + +include_files="" + +# Use case fallthrough to include each subset of files +# Set the number of backups to keep at the same time using default values +case "$1" in + "monthly") + include_files="$include_files"" --files-from targets/monthly" + backup_count=${backup_count:-6} + ;& + "weekly") + include_files="$include_files"" --files-from targets/weekly" + backup_count=${backup_count:-8} + ;& + "daily") + include_files="$include_files"" --files-from targets/daily" + backup_count=${backup_count:-14} + ;; +esac + +cd "$backup_origin" + +# Run database backups + +echo "Backing up BookStack db..." +mysqldump -u restic BookStack > temp/BookStack_db.mysql +echo "Backing up BitWarden db..." +sqlite3 /home/bitwarden/data/db.sqlite3 ".backup $backup_origin/temp/BitWarden_db.sqlite" +echo "Backing up Firefly db..." +sqlite3 /var/www/firefly-iii/storage/database/database.sqlite ".backup $backup_origin/temp/Firefly_db.sqlite" + +# Backup apt package list and keys +( +cd temp + +echo "Backing up apt keys,sources and packages..." +../package_save.sh here +) + +# Use OVH credentials and backup + +source openstack_creds.sh + +export RESTIC_PASSWORD_FILE="$backup_container".pass +export RESTIC_REPOSITORY="swift:$backup_container:/restic" + +restic backup $include_files --verbose --tag "$1" > backup_output.log 2>&1 +if [ $? -ne 0 ]; then + error_message="Restic backup failed ! See log bellow.\n" + error_message="$error_message""Backup check and purge will not be run.\n\n" + error_message="$error_message""$(cat backup_output.log)" +fi + +if [ -z "$error_message" ]; then + restic check --verbose > check_output.log 2>&1 +fi +if [ $? -ne 0 ]; then + error_message="Restic check failed ! See log below.\n" + error_message="$error_message""Backup purge will not be run.\n\n" + error_message="$error_message""$(cat check_output.log)" +fi + +# Clean up and remove old backups +rm -rf temp/* + +if [ -z "$error_message" ]; then + restic forget --verbose --prune --tag "$1" --keep-last "$backup_count" > forget_output.log 2>&1 +fi +if [ $? -ne 0 ]; then + error_message="Restic forget failed ! See log bellow.\n\n" + error_message="$error_message""$(cat forget_output.log)" +fi + + +if [ -n "$error_message" ]; then + echo -e "$error_message" | mail -aFrom:"$mail_sender" -s "[$(uname -n)] ⚠️ Backup error $(date +%D-%Hh%M)" "$mail_recipients" + exit 1 +fi + +exit 0 From 7e76730c191a1e10ba73a633183f9506df4455a0 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 17 May 2020 15:25:51 +0100 Subject: [PATCH 084/120] Added scripts for backing up and updating Firely-III --- VPS/FireflyUpdate.sh | 68 ++++++++++++++++++++++++++++++++ VPS/restic-backup.sh | 92 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100755 VPS/FireflyUpdate.sh create mode 100755 VPS/restic-backup.sh diff --git a/VPS/FireflyUpdate.sh b/VPS/FireflyUpdate.sh new file mode 100755 index 0000000..e39feda --- /dev/null +++ b/VPS/FireflyUpdate.sh @@ -0,0 +1,68 @@ +#!/bin/bash +set -euo pipefail + +# See documentation at https://docs.firefly-iii.org/advanced-installation/upgrade#created-using-composer-create-project + +if [ "$USER" != "www-data" -a "$USER" != "http" ]; then + echo "Please run this script as the user used by the webserver" + exit 1 +fi + +if [ $# -ne 2 ]; then + echo "Usage : FireflyUpdate /path/to/firefly/rootdir newVersion" + exit 1 +fi + +if [ ! -d "$1" ]; then + echo "Directory does not exist" + exit 1 +fi + + +( + +cd "$1"/.. + +rootDir=$(pwd) +originalDir=$(basename "$1") +newDir="$originalDir"-updated + +echo "Downloading new version..." + +composer create-project grumpydictator/firefly-iii --no-dev --prefer-dist "$originalDir"-updated $2 + +echo "Copying stored data..." + +cp "$1"/.env "$rootDir/$newDir"/.env +cp -r "$1"/storage/{upload,export} "$rootDir/$newDir"/storage +cp "$1"/storage/database/database.sqlite "$rootDir/$newDir"/storage/database/ + +echo "Cleaning caches and running migrations..." + +cd "$newDir" +rm -rf bootstrap/cache/* +php artisan cache:clear +php artisan migrate --seed +php artisan firefly-iii:upgrade-database +php artisan passport:install +php artisan cache:clear + +echo "Forcing access rights to 775 on storage..." + +chmod -R 775 storage + +cd "$rootDir" + +echo "Switching installs..." + +mv "$originalDir" "$originalDir"-old +mv "$newDir" "$originalDir" + +echo "Upgrade done !" +echo "Please check if it was sucessful, if so you can safely run the following command to remove the previous version:" +echo "sudo rm -rf \"$rootDir/$originalDir-old\"" + +) + +exit 0 + diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh new file mode 100755 index 0000000..6557dc1 --- /dev/null +++ b/VPS/restic-backup.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +# Use setcap'd binary in home directory +PATH="/home/restic/bin/:$PATH" + +backup_origin="/backups/restic" +backup_container="central-backup" + +if [[ -z "$1" || "$1" != "daily" && "$1" != "weekly" && "$1" != "monthly" ]]; then + echo "Usage : backup [daily|weekly|monthly]" + exit 1 +fi + +include_files="" + +# Use case fallthrough to include each subset of files +# Set the number of backups to keep at the same time using default values +case "$1" in + "monthly") + include_files="$include_files"" --files-from targets/monthly" + backup_count=${backup_count:-6} + ;& + "weekly") + include_files="$include_files"" --files-from targets/weekly" + backup_count=${backup_count:-8} + ;& + "daily") + include_files="$include_files"" --files-from targets/daily" + backup_count=${backup_count:-14} + ;; +esac + +cd "$backup_origin" + +# Run database backups + +echo "Backing up BookStack db..." +mysqldump -u restic BookStack > temp/BookStack_db.mysql +echo "Backing up BitWarden db..." +sqlite3 /home/bitwarden/data/db.sqlite3 ".backup $backup_origin/temp/BitWarden_db.sqlite" +echo "Backing up Firefly db..." +sqlite3 /var/www/firefly-iii/storage/database/database.sqlite ".backup $backup_origin/temp/Firefly_db.sqlite" + +# Backup apt package list and keys +( +cd temp + +echo "Backing up apt keys,sources and packages..." +../package_save.sh here +) + +# Use OVH credentials and backup + +source openstack_creds.sh + +export RESTIC_PASSWORD_FILE="$backup_container".pass +export RESTIC_REPOSITORY="swift:$backup_container:/restic" + +restic backup $include_files --verbose --tag "$1" > backup_output.log 2>&1 +if [ $? -ne 0 ]; then + error_message="Restic backup failed ! See log bellow.\n" + error_message="$error_message""Backup check and purge will not be run.\n\n" + error_message="$error_message""$(cat backup_output.log)" +fi + +if [ -z "$error_message" ]; then + restic check --verbose > check_output.log 2>&1 +fi +if [ $? -ne 0 ]; then + error_message="Restic check failed ! See log below.\n" + error_message="$error_message""Backup purge will not be run.\n\n" + error_message="$error_message""$(cat check_output.log)" +fi + +# Clean up and remove old backups +rm -rf temp/* + +if [ -z "$error_message" ]; then + restic forget --verbose --prune --tag "$1" --keep-last "$backup_count" > forget_output.log 2>&1 +fi +if [ $? -ne 0 ]; then + error_message="Restic forget failed ! See log bellow.\n\n" + error_message="$error_message""$(cat forget_output.log)" +fi + + +if [ -n "$error_message" ]; then + echo -e "$error_message" | mail -aFrom:"$mail_sender" -s "[$(uname -n)] ⚠️ Backup error $(date +%D-%Hh%M)" "$mail_recipients" + exit 1 +fi + +exit 0 From d8bb9ea3a5c147494314c84fd2099c33bb1f24ed Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 21 Jun 2020 12:46:41 +0100 Subject: [PATCH 085/120] Clean up of backups by tag needs to use group-by --- VPS/restic-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh index 6557dc1..44c969c 100755 --- a/VPS/restic-backup.sh +++ b/VPS/restic-backup.sh @@ -76,7 +76,7 @@ fi rm -rf temp/* if [ -z "$error_message" ]; then - restic forget --verbose --prune --tag "$1" --keep-last "$backup_count" > forget_output.log 2>&1 + restic forget --verbose --prune --group-by tag --tag "$1" --keep-last "$backup_count" > forget_output.log 2>&1 fi if [ $? -ne 0 ]; then error_message="Restic forget failed ! See log bellow.\n\n" From 8355b7a7114ea9174475fae7e364838f486d4c56 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 21 Jun 2020 12:46:41 +0100 Subject: [PATCH 086/120] Clean up of backups by tag needs to use group-by --- VPS/restic-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh index 6557dc1..44c969c 100755 --- a/VPS/restic-backup.sh +++ b/VPS/restic-backup.sh @@ -76,7 +76,7 @@ fi rm -rf temp/* if [ -z "$error_message" ]; then - restic forget --verbose --prune --tag "$1" --keep-last "$backup_count" > forget_output.log 2>&1 + restic forget --verbose --prune --group-by tag --tag "$1" --keep-last "$backup_count" > forget_output.log 2>&1 fi if [ $? -ne 0 ]; then error_message="Restic forget failed ! See log bellow.\n\n" From 434df6bb4234a38ff6cda748709987efa83446e3 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 5 Jul 2020 16:08:21 +0100 Subject: [PATCH 087/120] Add lockscreen script for i3-lock-colors Script screenshots current screen, blurs it and add a black rectangle for i3-lock info. i3-lock parameters mainly set up colors and position --- Perso/i3-lockscreenshot.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 Perso/i3-lockscreenshot.sh diff --git a/Perso/i3-lockscreenshot.sh b/Perso/i3-lockscreenshot.sh new file mode 100755 index 0000000..ff7fe96 --- /dev/null +++ b/Perso/i3-lockscreenshot.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Credit github user iambecomeroot, MIT licence +# https://github.com/iambecomeroot/dotfiles/blob/master/bin/bin/lock +# Modified by trotFunky + +rectangles=" " + +#scrot_options="-scale 5% -scale 2000%" # Pixelate +scrot_options="-blur 0x3" + +SR=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*') +for RES in $SR; do + SRA=(${RES//[x+]/ }) + CX=$((${SRA[2]} + 25)) + CY=$((${SRA[1]} - 80)) + rectangles+="rectangle $CX,$CY $((CX+300)),$((CY-80)) " +done + +TMPBG=/tmp/screen.png +scrot $TMPBG && convert $TMPBG $scrot_options -draw "fill black fill-opacity 0.4 $rectangles" $TMPBG + +i3lock \ + -i $TMPBG \ + -e --force-clock \ + --timepos="ix-100:iy" \ + --datepos="tx:ty+25" \ + --clock --datestr "%A, %d/%m/%Y" \ + --insidecolor=00000000 --ringcolor=ffffffff --line-uses-inside \ + --keyhlcolor=d23c3dff --bshlcolor=d23c3dff --separatorcolor=00000000 \ + --insidevercolor=fecf4dff --insidewrongcolor=d23c3dff \ + --ringvercolor=ffffffff --ringwrongcolor=ffffffff --indpos="x+290:h-120" \ + --radius=20 --ring-width=3 \ + --greetertext="" --veriftext="" --wrongtext="" --noinputtext="" \ + --greetercolor="ffffffff" --timecolor="ffffffff" --datecolor="ffffffff" + +rm $TMPBG From 93d70d6295cb21b8f5fa2637f2e196a3411a278f Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 5 Jul 2020 16:08:21 +0100 Subject: [PATCH 088/120] Add lockscreen script for i3-lock-colors Script screenshots current screen, blurs it and add a black rectangle for i3-lock info. i3-lock parameters mainly set up colors and position --- Perso/i3-lockscreenshot.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 Perso/i3-lockscreenshot.sh diff --git a/Perso/i3-lockscreenshot.sh b/Perso/i3-lockscreenshot.sh new file mode 100755 index 0000000..ff7fe96 --- /dev/null +++ b/Perso/i3-lockscreenshot.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Credit github user iambecomeroot, MIT licence +# https://github.com/iambecomeroot/dotfiles/blob/master/bin/bin/lock +# Modified by trotFunky + +rectangles=" " + +#scrot_options="-scale 5% -scale 2000%" # Pixelate +scrot_options="-blur 0x3" + +SR=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*') +for RES in $SR; do + SRA=(${RES//[x+]/ }) + CX=$((${SRA[2]} + 25)) + CY=$((${SRA[1]} - 80)) + rectangles+="rectangle $CX,$CY $((CX+300)),$((CY-80)) " +done + +TMPBG=/tmp/screen.png +scrot $TMPBG && convert $TMPBG $scrot_options -draw "fill black fill-opacity 0.4 $rectangles" $TMPBG + +i3lock \ + -i $TMPBG \ + -e --force-clock \ + --timepos="ix-100:iy" \ + --datepos="tx:ty+25" \ + --clock --datestr "%A, %d/%m/%Y" \ + --insidecolor=00000000 --ringcolor=ffffffff --line-uses-inside \ + --keyhlcolor=d23c3dff --bshlcolor=d23c3dff --separatorcolor=00000000 \ + --insidevercolor=fecf4dff --insidewrongcolor=d23c3dff \ + --ringvercolor=ffffffff --ringwrongcolor=ffffffff --indpos="x+290:h-120" \ + --radius=20 --ring-width=3 \ + --greetertext="" --veriftext="" --wrongtext="" --noinputtext="" \ + --greetercolor="ffffffff" --timecolor="ffffffff" --datecolor="ffffffff" + +rm $TMPBG From 11e21c10da29e96b7514065ed2bc458648d75447 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 5 Jul 2020 16:36:06 +0100 Subject: [PATCH 089/120] Add service file to run lock script on sleep --- Perso/systemd_timers/sleepLocki3.service | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Perso/systemd_timers/sleepLocki3.service diff --git a/Perso/systemd_timers/sleepLocki3.service b/Perso/systemd_timers/sleepLocki3.service new file mode 100644 index 0000000..c2c7f0c --- /dev/null +++ b/Perso/systemd_timers/sleepLocki3.service @@ -0,0 +1,15 @@ +#/etc/systemd/system/ + +[Unit] +Description=Turning i3lock on before sleep +Before=sleep.target + +[Service] +User=trotfunky +Type=forking +Environment=DISPLAY=:0 +ExecStart=/home/trotfunky/lockscreen.sh +ExecStartPost=sleep 1 + +[Install] +WantedBy=sleep.target From 7216c895b361096aedbab7f76949f41eaa3e5787 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 5 Jul 2020 16:36:06 +0100 Subject: [PATCH 090/120] Add service file to run lock script on sleep --- Perso/systemd_timers/sleepLocki3.service | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Perso/systemd_timers/sleepLocki3.service diff --git a/Perso/systemd_timers/sleepLocki3.service b/Perso/systemd_timers/sleepLocki3.service new file mode 100644 index 0000000..c2c7f0c --- /dev/null +++ b/Perso/systemd_timers/sleepLocki3.service @@ -0,0 +1,15 @@ +#/etc/systemd/system/ + +[Unit] +Description=Turning i3lock on before sleep +Before=sleep.target + +[Service] +User=trotfunky +Type=forking +Environment=DISPLAY=:0 +ExecStart=/home/trotfunky/lockscreen.sh +ExecStartPost=sleep 1 + +[Install] +WantedBy=sleep.target From 694d7d1b84958961357d04700737373cc7c66d7c Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sat, 1 Aug 2020 14:23:42 +0200 Subject: [PATCH 091/120] Add script to add peers to Wireguard config The script is to be run on the VPN host. It extracts the necessary data from the configuration file and asks for some data about the new peer. It then outputs the peer configuration file and updates the host configuration accordingly. --- VPS/WireguardAddPeer.sh | 117 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100755 VPS/WireguardAddPeer.sh diff --git a/VPS/WireguardAddPeer.sh b/VPS/WireguardAddPeer.sh new file mode 100755 index 0000000..a307146 --- /dev/null +++ b/VPS/WireguardAddPeer.sh @@ -0,0 +1,117 @@ +#!/bin/bash + +# Usage : parseConf $fileContent $propertyName +# Retrieves the value of propertyName from fileContent +# And echoes it back +function parseConf() { + result=$(echo "$1" | grep $2 | cut -f2 -d'=') + echo $result +} + + +if [ $EUID -ne 0 ]; then + echo "This script can only be run as root" + exit -1 +fi + +if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then + cat <> $confFile + +[Peer] +PublicKey = $peerPubKey +AllowedIPs = $peerAddress/32 + +EOF + +cat < Date: Sat, 1 Aug 2020 14:23:42 +0200 Subject: [PATCH 092/120] Add script to add peers to Wireguard config The script is to be run on the VPN host. It extracts the necessary data from the configuration file and asks for some data about the new peer. It then outputs the peer configuration file and updates the host configuration accordingly. --- VPS/WireguardAddPeer.sh | 117 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100755 VPS/WireguardAddPeer.sh diff --git a/VPS/WireguardAddPeer.sh b/VPS/WireguardAddPeer.sh new file mode 100755 index 0000000..a307146 --- /dev/null +++ b/VPS/WireguardAddPeer.sh @@ -0,0 +1,117 @@ +#!/bin/bash + +# Usage : parseConf $fileContent $propertyName +# Retrieves the value of propertyName from fileContent +# And echoes it back +function parseConf() { + result=$(echo "$1" | grep $2 | cut -f2 -d'=') + echo $result +} + + +if [ $EUID -ne 0 ]; then + echo "This script can only be run as root" + exit -1 +fi + +if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then + cat <> $confFile + +[Peer] +PublicKey = $peerPubKey +AllowedIPs = $peerAddress/32 + +EOF + +cat < Date: Tue, 15 Sep 2020 19:34:50 +0200 Subject: [PATCH 093/120] Added missing "n" to "Endpoint" --- VPS/WireguardAddPeer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VPS/WireguardAddPeer.sh b/VPS/WireguardAddPeer.sh index a307146..93e5ff3 100755 --- a/VPS/WireguardAddPeer.sh +++ b/VPS/WireguardAddPeer.sh @@ -111,7 +111,7 @@ PrivateKey = $peerKey [Peer] PublicKey = $pubKey AllowedIPs = $peerAllowedIPs -Endpoit = $targetDomain:$listenPort +Endpoint = $targetDomain:$listenPort EOF From bb10cbee0dacbc18a988f0a4c9773cdcd07b671d Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Tue, 15 Sep 2020 19:34:50 +0200 Subject: [PATCH 094/120] Added missing "n" to "Endpoint" --- VPS/WireguardAddPeer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VPS/WireguardAddPeer.sh b/VPS/WireguardAddPeer.sh index a307146..93e5ff3 100755 --- a/VPS/WireguardAddPeer.sh +++ b/VPS/WireguardAddPeer.sh @@ -111,7 +111,7 @@ PrivateKey = $peerKey [Peer] PublicKey = $pubKey AllowedIPs = $peerAllowedIPs -Endpoit = $targetDomain:$listenPort +Endpoint = $targetDomain:$listenPort EOF From 3f7f03ce2802229f46287439cbaa32df89f3e06a Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 14 Mar 2021 21:04:54 +0000 Subject: [PATCH 095/120] Restic : add local copy script, change binary TODO : Change backup script to use environment variables is set, like local copy Local copy script assumes repository already exists. TODO ? Make it create if needed, handle prunes --- VPS/restic-backup.sh | 3 ++- VPS/restic-local-copy.sh | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 VPS/restic-local-copy.sh diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh index 44c969c..3128457 100755 --- a/VPS/restic-backup.sh +++ b/VPS/restic-backup.sh @@ -1,7 +1,8 @@ #!/bin/bash # Use setcap'd binary in home directory -PATH="/home/restic/bin/:$PATH" +#PATH="/home/restic/bin/:$PATH" +# Now uses binary in /usr/bin, which is also setcap'd backup_origin="/backups/restic" backup_container="central-backup" diff --git a/VPS/restic-local-copy.sh b/VPS/restic-local-copy.sh new file mode 100755 index 0000000..fd51479 --- /dev/null +++ b/VPS/restic-local-copy.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -euo pipefail + +backup_origin=${backup_origin:-"/backups/restic/"} + +backup_container=${backup_container:-"central-backup"} +local_repository="$backup_container""-local" + +cd "$backup_origin" + +source openrc.sh + +export RESTIC_PASSWORD_FILE="$backup_container".pass +export RESTIC_PASSWORD_FILE2="$local_repository".pass +export RESTIC_REPOSITORY="swift:$backup_container:/restic" +export RESTIC_REPOSITORY2="$backup_origin""$local_repository" + +# Higher connection count seems to help greatly with copy time +restic copy -o swift.connections=100 -vv From cd7ffa12e4134a88d2e9dcf2c8c7721490778c78 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 14 Mar 2021 21:04:54 +0000 Subject: [PATCH 096/120] Restic : add local copy script, change binary TODO : Change backup script to use environment variables is set, like local copy Local copy script assumes repository already exists. TODO ? Make it create if needed, handle prunes --- VPS/restic-backup.sh | 3 ++- VPS/restic-local-copy.sh | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 VPS/restic-local-copy.sh diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh index 44c969c..3128457 100755 --- a/VPS/restic-backup.sh +++ b/VPS/restic-backup.sh @@ -1,7 +1,8 @@ #!/bin/bash # Use setcap'd binary in home directory -PATH="/home/restic/bin/:$PATH" +#PATH="/home/restic/bin/:$PATH" +# Now uses binary in /usr/bin, which is also setcap'd backup_origin="/backups/restic" backup_container="central-backup" diff --git a/VPS/restic-local-copy.sh b/VPS/restic-local-copy.sh new file mode 100755 index 0000000..fd51479 --- /dev/null +++ b/VPS/restic-local-copy.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -euo pipefail + +backup_origin=${backup_origin:-"/backups/restic/"} + +backup_container=${backup_container:-"central-backup"} +local_repository="$backup_container""-local" + +cd "$backup_origin" + +source openrc.sh + +export RESTIC_PASSWORD_FILE="$backup_container".pass +export RESTIC_PASSWORD_FILE2="$local_repository".pass +export RESTIC_REPOSITORY="swift:$backup_container:/restic" +export RESTIC_REPOSITORY2="$backup_origin""$local_repository" + +# Higher connection count seems to help greatly with copy time +restic copy -o swift.connections=100 -vv From 60a60465236d7430524b2a141c28cbcb9287cdc5 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Tue, 14 Sep 2021 23:43:55 +0100 Subject: [PATCH 097/120] Add joke script to generate triangle messages --- Perso/tri.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 Perso/tri.sh diff --git a/Perso/tri.sh b/Perso/tri.sh new file mode 100755 index 0000000..4e0ffef --- /dev/null +++ b/Perso/tri.sh @@ -0,0 +1,33 @@ +#/bin/bash + +read input +characters=$(echo "$input" | grep -oe ".") + +message="" +for char in $characters; do + message="$message""$char"" " +done + +echo 3 +sleep 1 +echo 2 +sleep 1 +echo 1 +sleep 1 + +xdotool type "$message" +xdotool key shift+enter + +spaces="" +for char in $characters; do + if [ "$spaces" ]; then + xdotool type "$char""$spaces" + if [ "$char" = 'i' ] || [ "$char" = 'I' ] || [ "$char" = '1' ] || [ "$char" = 'J' ] || [ "$char" = 'j' ] || [ "$char" = 't' ] || [ "$char" = 'f' ]; then + xdotool type " " + fi + xdotool type "$char" + xdotool key shift+enter + spaces="$spaces"" " + fi + spaces="$spaces"" " +done From ce261fa71ffca1732584a45d85e037f6e62a07c6 Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Tue, 14 Sep 2021 23:43:55 +0100 Subject: [PATCH 098/120] Add joke script to generate triangle messages --- Perso/tri.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 Perso/tri.sh diff --git a/Perso/tri.sh b/Perso/tri.sh new file mode 100755 index 0000000..4e0ffef --- /dev/null +++ b/Perso/tri.sh @@ -0,0 +1,33 @@ +#/bin/bash + +read input +characters=$(echo "$input" | grep -oe ".") + +message="" +for char in $characters; do + message="$message""$char"" " +done + +echo 3 +sleep 1 +echo 2 +sleep 1 +echo 1 +sleep 1 + +xdotool type "$message" +xdotool key shift+enter + +spaces="" +for char in $characters; do + if [ "$spaces" ]; then + xdotool type "$char""$spaces" + if [ "$char" = 'i' ] || [ "$char" = 'I' ] || [ "$char" = '1' ] || [ "$char" = 'J' ] || [ "$char" = 'j' ] || [ "$char" = 't' ] || [ "$char" = 'f' ]; then + xdotool type " " + fi + xdotool type "$char" + xdotool key shift+enter + spaces="$spaces"" " + fi + spaces="$spaces"" " +done From 61ade804ff0001f3ef2620b592b887d20b17b7f3 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 18 Apr 2022 10:22:53 +0100 Subject: [PATCH 099/120] Small adjustments to restic-backup Reflect status of script from the VPS, mainly add a sleep interval after backup. --- VPS/restic-backup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh index 3128457..19b8b1f 100755 --- a/VPS/restic-backup.sh +++ b/VPS/restic-backup.sh @@ -2,7 +2,7 @@ # Use setcap'd binary in home directory #PATH="/home/restic/bin/:$PATH" -# Now uses binary in /usr/bin, which is also setcap'd +#Not necessary anymore : binary in /usr/bin setcap'd backup_origin="/backups/restic" backup_container="central-backup" @@ -64,6 +64,9 @@ if [ $? -ne 0 ]; then error_message="$error_message""$(cat backup_output.log)" fi +# Sleep to allow time for propagation +sleep 60 + if [ -z "$error_message" ]; then restic check --verbose > check_output.log 2>&1 fi From a278fdd40ab4bdcf708711be62b8794f80ce9adb Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Mon, 18 Apr 2022 10:22:53 +0100 Subject: [PATCH 100/120] Small adjustments to restic-backup Reflect status of script from the VPS, mainly add a sleep interval after backup. --- VPS/restic-backup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh index 3128457..19b8b1f 100755 --- a/VPS/restic-backup.sh +++ b/VPS/restic-backup.sh @@ -2,7 +2,7 @@ # Use setcap'd binary in home directory #PATH="/home/restic/bin/:$PATH" -# Now uses binary in /usr/bin, which is also setcap'd +#Not necessary anymore : binary in /usr/bin setcap'd backup_origin="/backups/restic" backup_container="central-backup" @@ -64,6 +64,9 @@ if [ $? -ne 0 ]; then error_message="$error_message""$(cat backup_output.log)" fi +# Sleep to allow time for propagation +sleep 60 + if [ -z "$error_message" ]; then restic check --verbose > check_output.log 2>&1 fi From f881d50c90b4073170b51e8e93f18ff91aea05a3 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 18 Apr 2022 10:27:49 +0100 Subject: [PATCH 101/120] Add example variables for mail sender/recicipients for backup --- VPS/restic-backup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh index 19b8b1f..dfeb0ac 100755 --- a/VPS/restic-backup.sh +++ b/VPS/restic-backup.sh @@ -7,6 +7,9 @@ backup_origin="/backups/restic" backup_container="central-backup" +mail_sender='"Name"""' +mail_recipients="first@example.com,second@example.com" + if [[ -z "$1" || "$1" != "daily" && "$1" != "weekly" && "$1" != "monthly" ]]; then echo "Usage : backup [daily|weekly|monthly]" exit 1 From 9efacf4f8c2313435306eeb5d4d5cdd7b7c43e6b Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Mon, 18 Apr 2022 10:27:49 +0100 Subject: [PATCH 102/120] Add example variables for mail sender/recicipients for backup --- VPS/restic-backup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh index 19b8b1f..dfeb0ac 100755 --- a/VPS/restic-backup.sh +++ b/VPS/restic-backup.sh @@ -7,6 +7,9 @@ backup_origin="/backups/restic" backup_container="central-backup" +mail_sender='"Name"""' +mail_recipients="first@example.com,second@example.com" + if [[ -z "$1" || "$1" != "daily" && "$1" != "weekly" && "$1" != "monthly" ]]; then echo "Usage : backup [daily|weekly|monthly]" exit 1 From c0a7eaec2a1ad574cfab2880fa3c265d183d9970 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 18 Apr 2022 10:44:21 +0100 Subject: [PATCH 103/120] Run prune before checking the backup repository --- VPS/restic-backup.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh index dfeb0ac..b92cbe2 100755 --- a/VPS/restic-backup.sh +++ b/VPS/restic-backup.sh @@ -70,26 +70,28 @@ fi # Sleep to allow time for propagation sleep 60 +# Remove old and stale data if [ -z "$error_message" ]; then - restic check --verbose > check_output.log 2>&1 + restic forget --verbose --prune --group-by tag --tag "$1" --keep-last "$backup_count" > forget_output.log 2>&1 fi if [ $? -ne 0 ]; then - error_message="Restic check failed ! See log below.\n" - error_message="$error_message""Backup purge will not be run.\n\n" - error_message="$error_message""$(cat check_output.log)" + error_message="Restic forget failed ! See log bellow.\n\n" + error_message="$error_message""$(cat forget_output.log)" +fi + +# Check repository status +if [ -z "$error_message" ]; then + restic check --verbose > check_output.log 2>&1 +fi +if [ $? -ne 0 ]; then + error_message="Restic check failed ! See log below.\n" + error_message="$error_message""Backup purge will not be run.\n\n" + error_message="$error_message""$(cat check_output.log)" fi # Clean up and remove old backups rm -rf temp/* -if [ -z "$error_message" ]; then - restic forget --verbose --prune --group-by tag --tag "$1" --keep-last "$backup_count" > forget_output.log 2>&1 -fi -if [ $? -ne 0 ]; then - error_message="Restic forget failed ! See log bellow.\n\n" - error_message="$error_message""$(cat forget_output.log)" -fi - if [ -n "$error_message" ]; then echo -e "$error_message" | mail -aFrom:"$mail_sender" -s "[$(uname -n)] ⚠️ Backup error $(date +%D-%Hh%M)" "$mail_recipients" From 3c15c5a9f50a5ed40547f8f85137d92d49c1107f Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Mon, 18 Apr 2022 10:44:21 +0100 Subject: [PATCH 104/120] Run prune before checking the backup repository --- VPS/restic-backup.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh index dfeb0ac..b92cbe2 100755 --- a/VPS/restic-backup.sh +++ b/VPS/restic-backup.sh @@ -70,26 +70,28 @@ fi # Sleep to allow time for propagation sleep 60 +# Remove old and stale data if [ -z "$error_message" ]; then - restic check --verbose > check_output.log 2>&1 + restic forget --verbose --prune --group-by tag --tag "$1" --keep-last "$backup_count" > forget_output.log 2>&1 fi if [ $? -ne 0 ]; then - error_message="Restic check failed ! See log below.\n" - error_message="$error_message""Backup purge will not be run.\n\n" - error_message="$error_message""$(cat check_output.log)" + error_message="Restic forget failed ! See log bellow.\n\n" + error_message="$error_message""$(cat forget_output.log)" +fi + +# Check repository status +if [ -z "$error_message" ]; then + restic check --verbose > check_output.log 2>&1 +fi +if [ $? -ne 0 ]; then + error_message="Restic check failed ! See log below.\n" + error_message="$error_message""Backup purge will not be run.\n\n" + error_message="$error_message""$(cat check_output.log)" fi # Clean up and remove old backups rm -rf temp/* -if [ -z "$error_message" ]; then - restic forget --verbose --prune --group-by tag --tag "$1" --keep-last "$backup_count" > forget_output.log 2>&1 -fi -if [ $? -ne 0 ]; then - error_message="Restic forget failed ! See log bellow.\n\n" - error_message="$error_message""$(cat forget_output.log)" -fi - if [ -n "$error_message" ]; then echo -e "$error_message" | mail -aFrom:"$mail_sender" -s "[$(uname -n)] ⚠️ Backup error $(date +%D-%Hh%M)" "$mail_recipients" From 0e92590a63ac6beccec35d3259a0a6001255ff08 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 18 Apr 2022 10:49:25 +0100 Subject: [PATCH 105/120] Small auction tracker script --- Perso/auction_tracker.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 Perso/auction_tracker.sh diff --git a/Perso/auction_tracker.sh b/Perso/auction_tracker.sh new file mode 100755 index 0000000..7a70d98 --- /dev/null +++ b/Perso/auction_tracker.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + echo "Usage : ./auction_tracker.sh \"search terms\"" + exit -1 +fi + +result=$(curl -s https://www.bidspotter.co.uk/en-gb/search-results?searchTerm="$1" | rg -e "

.*

" | rg -oe "([1-9]+[0-9]*) item\(s\)") + +if [ "$result" ]; then + notify-send "Number of $1 listings : $result" +fi From 64a678b53b1c51897fa093c562e4d8b0a3e593aa Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Mon, 18 Apr 2022 10:49:25 +0100 Subject: [PATCH 106/120] Small auction tracker script --- Perso/auction_tracker.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 Perso/auction_tracker.sh diff --git a/Perso/auction_tracker.sh b/Perso/auction_tracker.sh new file mode 100755 index 0000000..7a70d98 --- /dev/null +++ b/Perso/auction_tracker.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + echo "Usage : ./auction_tracker.sh \"search terms\"" + exit -1 +fi + +result=$(curl -s https://www.bidspotter.co.uk/en-gb/search-results?searchTerm="$1" | rg -e "

.*

" | rg -oe "([1-9]+[0-9]*) item\(s\)") + +if [ "$result" ]; then + notify-send "Number of $1 listings : $result" +fi From d28c291279a3c8ac678d98c75eed2d39c9cf3d1d Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 8 May 2022 20:17:17 +0100 Subject: [PATCH 107/120] Add Tandoor containers stop/start for backups --- VPS/restic-backup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh index b92cbe2..adc31ad 100755 --- a/VPS/restic-backup.sh +++ b/VPS/restic-backup.sh @@ -45,6 +45,8 @@ sqlite3 /home/bitwarden/data/db.sqlite3 ".backup $backup_origin/temp/BitWarden_d echo "Backing up Firefly db..." sqlite3 /var/www/firefly-iii/storage/database/database.sqlite ".backup $backup_origin/temp/Firefly_db.sqlite" +systemctl stop tandoor + # Backup apt package list and keys ( cd temp @@ -98,4 +100,6 @@ if [ -n "$error_message" ]; then exit 1 fi +systemctl start tandoor + exit 0 From 629cd1d2c0f76b2a269fede8e6925adc858dc8f1 Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Sun, 8 May 2022 20:17:17 +0100 Subject: [PATCH 108/120] Add Tandoor containers stop/start for backups --- VPS/restic-backup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/VPS/restic-backup.sh b/VPS/restic-backup.sh index b92cbe2..adc31ad 100755 --- a/VPS/restic-backup.sh +++ b/VPS/restic-backup.sh @@ -45,6 +45,8 @@ sqlite3 /home/bitwarden/data/db.sqlite3 ".backup $backup_origin/temp/BitWarden_d echo "Backing up Firefly db..." sqlite3 /var/www/firefly-iii/storage/database/database.sqlite ".backup $backup_origin/temp/Firefly_db.sqlite" +systemctl stop tandoor + # Backup apt package list and keys ( cd temp @@ -98,4 +100,6 @@ if [ -n "$error_message" ]; then exit 1 fi +systemctl start tandoor + exit 0 From a8ef6e04e381709601c910b93b57f401dc0b7b6e Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 26 Feb 2023 19:06:33 +0000 Subject: [PATCH 109/120] Basic script for mic chain This new script sets up a sink for the mic chain and loads the proper configuration. --- Perso/auto_audio.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 Perso/auto_audio.sh diff --git a/Perso/auto_audio.sh b/Perso/auto_audio.sh new file mode 100755 index 0000000..3422eeb --- /dev/null +++ b/Perso/auto_audio.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +module=$(pactl load-module module-null-sink media.class=Audio/Source/Virtual sink_name=Virt_Mic channel_map=front-left,front-right) + +if [ ! $? ]; then + notify-send -a "$0" -i microphone "Failed to set-up null sink" + exit -1 +else + notify-send - "$0" -i microphone "Null sink set-up" +fi + +carla ~/Projects/Audio/Carla/Basic\ Setup.carxp + +pactl unload-module $module From cb341b2adaf14c48d6bc936dd4807bc6040496b1 Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Sun, 26 Feb 2023 19:06:33 +0000 Subject: [PATCH 110/120] Basic script for mic chain This new script sets up a sink for the mic chain and loads the proper configuration. --- Perso/auto_audio.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 Perso/auto_audio.sh diff --git a/Perso/auto_audio.sh b/Perso/auto_audio.sh new file mode 100755 index 0000000..3422eeb --- /dev/null +++ b/Perso/auto_audio.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +module=$(pactl load-module module-null-sink media.class=Audio/Source/Virtual sink_name=Virt_Mic channel_map=front-left,front-right) + +if [ ! $? ]; then + notify-send -a "$0" -i microphone "Failed to set-up null sink" + exit -1 +else + notify-send - "$0" -i microphone "Null sink set-up" +fi + +carla ~/Projects/Audio/Carla/Basic\ Setup.carxp + +pactl unload-module $module From cc61adcb6ef532634dc1058b67cb431ce79db9cd Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 26 Feb 2023 19:19:56 +0000 Subject: [PATCH 111/120] Update audio chain script Add two new sinks to be allow a sidechain compressor of the system audio controlled by discord output, which doesn't get compressed itself. --- Perso/auto_audio.sh | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Perso/auto_audio.sh b/Perso/auto_audio.sh index 3422eeb..c597b88 100755 --- a/Perso/auto_audio.sh +++ b/Perso/auto_audio.sh @@ -1,14 +1,34 @@ #!/bin/bash -module=$(pactl load-module module-null-sink media.class=Audio/Source/Virtual sink_name=Virt_Mic channel_map=front-left,front-right) +mic_sink=$(pactl load-module module-null-sink media.class=Audio/Source/Virtual sink_name=Virt_Mic channel_map=front-left,front-right) if [ ! $? ]; then notify-send -a "$0" -i microphone "Failed to set-up null sink" exit -1 -else - notify-send - "$0" -i microphone "Null sink set-up" fi -carla ~/Projects/Audio/Carla/Basic\ Setup.carxp +discord_sink=$(pactl load-module module-null-sink media.class=Audio/Sink sink_name=Discord channel_map=stereo) + +if [ ! $? ]; then + notify-send -a "$0" -i microphone "Failed to set-up discord sink" + pactl unload-module $mic_sink + exit -1 +fi + +default_sink=$(pactl load-module module-null-sink media.class=Audio/Sink sink_name=Other channel_map=stereo) + +if [ ! $? ]; then + notify-send -a "$0" -i microphone "Failed to set-up discord sink" + pactl unload-module $mic_sink + pactl unload-module $discord_sink + exit -1 +fi + +notify-send - "$0" -i microphone "All sinks set-up" + +carla ~/Projects/Audio/Carla/Sidechain\ comp\ Setup.carxp + +pactl unload-module $mic_sink +pactl unload-module $discord_sink +pactl unload-module $default_sink -pactl unload-module $module From f8ce7759c81230d9c56747881e8f1063c121d95a Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Sun, 26 Feb 2023 19:19:56 +0000 Subject: [PATCH 112/120] Update audio chain script Add two new sinks to be allow a sidechain compressor of the system audio controlled by discord output, which doesn't get compressed itself. --- Perso/auto_audio.sh | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Perso/auto_audio.sh b/Perso/auto_audio.sh index 3422eeb..c597b88 100755 --- a/Perso/auto_audio.sh +++ b/Perso/auto_audio.sh @@ -1,14 +1,34 @@ #!/bin/bash -module=$(pactl load-module module-null-sink media.class=Audio/Source/Virtual sink_name=Virt_Mic channel_map=front-left,front-right) +mic_sink=$(pactl load-module module-null-sink media.class=Audio/Source/Virtual sink_name=Virt_Mic channel_map=front-left,front-right) if [ ! $? ]; then notify-send -a "$0" -i microphone "Failed to set-up null sink" exit -1 -else - notify-send - "$0" -i microphone "Null sink set-up" fi -carla ~/Projects/Audio/Carla/Basic\ Setup.carxp +discord_sink=$(pactl load-module module-null-sink media.class=Audio/Sink sink_name=Discord channel_map=stereo) + +if [ ! $? ]; then + notify-send -a "$0" -i microphone "Failed to set-up discord sink" + pactl unload-module $mic_sink + exit -1 +fi + +default_sink=$(pactl load-module module-null-sink media.class=Audio/Sink sink_name=Other channel_map=stereo) + +if [ ! $? ]; then + notify-send -a "$0" -i microphone "Failed to set-up discord sink" + pactl unload-module $mic_sink + pactl unload-module $discord_sink + exit -1 +fi + +notify-send - "$0" -i microphone "All sinks set-up" + +carla ~/Projects/Audio/Carla/Sidechain\ comp\ Setup.carxp + +pactl unload-module $mic_sink +pactl unload-module $discord_sink +pactl unload-module $default_sink -pactl unload-module $module From c6a8f1eea262e4ddb54d53a81936e073eca13785 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 20 Nov 2023 11:40:25 +0100 Subject: [PATCH 113/120] bootSound: Remove usage of /dev/urandom The bootSound script started to hang on strings /dev/urandom, so replace it with a cleaner random number generation. 24134 could be used for bash, but this would make the script less generic, as it is not available in POSIX. Use awk random() from a suggestion from ShellCheck. Remove the code that was there to control the parsing from /dev/urandom. Other fixes : - Use wc rather than grep to count the files - Use a subshell for proper directory handling --- Perso/bootSound.sh | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/Perso/bootSound.sh b/Perso/bootSound.sh index 9c14a2d..7a6b156 100755 --- a/Perso/bootSound.sh +++ b/Perso/bootSound.sh @@ -1,16 +1,10 @@ #! /bin/sh -cd /home/trotfunky/Documents/Sounds/Startup/ -qty=$(ls | grep -c "" ) +( + cd /home/trotfunky/Documents/Sounds/Startup/ || exit 255 + qty=$(ls | wc -l ) + + file_id=$(awk "BEGIN { srand(); print int(rand()*$qty) }" /dev/null) + mplayer -nogui -softvol -ao alsa,pulse "$file_id"_* +) -if [ $qty -lt 10 ]; then - maxBit=1 - diGrep=[[:digit:]] -elif [ $qty -lt 100]; then - maxBit=2 - diGrep=[[:digit:]][[:digit:]] -fi - -mplayer -nogui -softvol -ao alsa,pulse $(expr $(strings /dev/urandom | cut -b 1-$maxBit | grep $diGrep -m 1 ) % $qty )* & -cd - - -exit 0 \ No newline at end of file +exit 0 From b6bcec6d88b9d5a4db9f644ef9de2ff297f2e9e1 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Mon, 20 Nov 2023 11:40:25 +0100 Subject: [PATCH 114/120] bootSound: Remove usage of /dev/urandom The bootSound script started to hang on strings /dev/urandom, so replace it with a cleaner random number generation. 24134 could be used for bash, but this would make the script less generic, as it is not available in POSIX. Use awk random() from a suggestion from ShellCheck. Remove the code that was there to control the parsing from /dev/urandom. Other fixes : - Use wc rather than grep to count the files - Use a subshell for proper directory handling --- Perso/bootSound.sh | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/Perso/bootSound.sh b/Perso/bootSound.sh index 9c14a2d..7a6b156 100755 --- a/Perso/bootSound.sh +++ b/Perso/bootSound.sh @@ -1,16 +1,10 @@ #! /bin/sh -cd /home/trotfunky/Documents/Sounds/Startup/ -qty=$(ls | grep -c "" ) +( + cd /home/trotfunky/Documents/Sounds/Startup/ || exit 255 + qty=$(ls | wc -l ) + + file_id=$(awk "BEGIN { srand(); print int(rand()*$qty) }" /dev/null) + mplayer -nogui -softvol -ao alsa,pulse "$file_id"_* +) -if [ $qty -lt 10 ]; then - maxBit=1 - diGrep=[[:digit:]] -elif [ $qty -lt 100]; then - maxBit=2 - diGrep=[[:digit:]][[:digit:]] -fi - -mplayer -nogui -softvol -ao alsa,pulse $(expr $(strings /dev/urandom | cut -b 1-$maxBit | grep $diGrep -m 1 ) % $qty )* & -cd - - -exit 0 \ No newline at end of file +exit 0 From e28a0cecabd2b6b394eabadf307261ea63e310be Mon Sep 17 00:00:00 2001 From: trotFunky Date: Wed, 27 Dec 2023 15:47:24 +0100 Subject: [PATCH 115/120] Update i3-lock-colors options --- Perso/i3-lockscreenshot.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Perso/i3-lockscreenshot.sh b/Perso/i3-lockscreenshot.sh index ff7fe96..ef65e96 100755 --- a/Perso/i3-lockscreenshot.sh +++ b/Perso/i3-lockscreenshot.sh @@ -22,15 +22,15 @@ scrot $TMPBG && convert $TMPBG $scrot_options -draw "fill black fill-opacity 0.4 i3lock \ -i $TMPBG \ -e --force-clock \ - --timepos="ix-100:iy" \ - --datepos="tx:ty+25" \ - --clock --datestr "%A, %d/%m/%Y" \ - --insidecolor=00000000 --ringcolor=ffffffff --line-uses-inside \ - --keyhlcolor=d23c3dff --bshlcolor=d23c3dff --separatorcolor=00000000 \ - --insidevercolor=fecf4dff --insidewrongcolor=d23c3dff \ - --ringvercolor=ffffffff --ringwrongcolor=ffffffff --indpos="x+290:h-120" \ + --time-pos="ix-100:iy" \ + --date-pos="tx:ty+25" \ + --clock --date-str "%A, %d/%m/%Y" \ + --inside-color=00000000 --ring-color=ffffffff --line-uses-inside \ + --keyhl-color=d23c3dff --bshl-color=d23c3dff --separator-color=00000000 \ + --insidever-color=fecf4dff --insidewrong-color=d23c3dff \ + --ringver-color=ffffffff --ringwrong-color=ffffffff --ind-pos="x+290:h-120" \ --radius=20 --ring-width=3 \ - --greetertext="" --veriftext="" --wrongtext="" --noinputtext="" \ - --greetercolor="ffffffff" --timecolor="ffffffff" --datecolor="ffffffff" + --greeter-text="" --verif-text="" --wrong-text="" --noinput-text="" \ + --greeter-color="ffffffff" --time-color="ffffffff" --date-color="ffffffff" rm $TMPBG From 61fef8495b724111a59abef1caae73d2dc0b0200 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Wed, 27 Dec 2023 15:47:21 +0100 Subject: [PATCH 116/120] Update i3-lock-colors options --- Perso/i3-lockscreenshot.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Perso/i3-lockscreenshot.sh b/Perso/i3-lockscreenshot.sh index ff7fe96..ef65e96 100755 --- a/Perso/i3-lockscreenshot.sh +++ b/Perso/i3-lockscreenshot.sh @@ -22,15 +22,15 @@ scrot $TMPBG && convert $TMPBG $scrot_options -draw "fill black fill-opacity 0.4 i3lock \ -i $TMPBG \ -e --force-clock \ - --timepos="ix-100:iy" \ - --datepos="tx:ty+25" \ - --clock --datestr "%A, %d/%m/%Y" \ - --insidecolor=00000000 --ringcolor=ffffffff --line-uses-inside \ - --keyhlcolor=d23c3dff --bshlcolor=d23c3dff --separatorcolor=00000000 \ - --insidevercolor=fecf4dff --insidewrongcolor=d23c3dff \ - --ringvercolor=ffffffff --ringwrongcolor=ffffffff --indpos="x+290:h-120" \ + --time-pos="ix-100:iy" \ + --date-pos="tx:ty+25" \ + --clock --date-str "%A, %d/%m/%Y" \ + --inside-color=00000000 --ring-color=ffffffff --line-uses-inside \ + --keyhl-color=d23c3dff --bshl-color=d23c3dff --separator-color=00000000 \ + --insidever-color=fecf4dff --insidewrong-color=d23c3dff \ + --ringver-color=ffffffff --ringwrong-color=ffffffff --ind-pos="x+290:h-120" \ --radius=20 --ring-width=3 \ - --greetertext="" --veriftext="" --wrongtext="" --noinputtext="" \ - --greetercolor="ffffffff" --timecolor="ffffffff" --datecolor="ffffffff" + --greeter-text="" --verif-text="" --wrong-text="" --noinput-text="" \ + --greeter-color="ffffffff" --time-color="ffffffff" --date-color="ffffffff" rm $TMPBG From 4dcc4a954ca9199ddd30156efaf03347f0a0704e Mon Sep 17 00:00:00 2001 From: trotFunky Date: Fri, 29 Mar 2024 12:39:32 +0000 Subject: [PATCH 117/120] Auto_audio: Fix notify-send For some reason the correct option was missing in the last notify-send, replace it to fix the set-up notification not showing up. --- Perso/auto_audio.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Perso/auto_audio.sh b/Perso/auto_audio.sh index c597b88..7363009 100755 --- a/Perso/auto_audio.sh +++ b/Perso/auto_audio.sh @@ -24,7 +24,7 @@ if [ ! $? ]; then exit -1 fi -notify-send - "$0" -i microphone "All sinks set-up" +notify-send -a "$0" -i microphone "All sinks set-up" carla ~/Projects/Audio/Carla/Sidechain\ comp\ Setup.carxp From 62a44829fe1a484286ede809cdea9ebcfad9bc8c Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Fri, 29 Mar 2024 12:38:46 +0000 Subject: [PATCH 118/120] Auto_audio: Fix notify-send For some reason the correct option was missing in the last notify-send, replace it to fix the set-up notification not showing up. --- Perso/auto_audio.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Perso/auto_audio.sh b/Perso/auto_audio.sh index c597b88..7363009 100755 --- a/Perso/auto_audio.sh +++ b/Perso/auto_audio.sh @@ -24,7 +24,7 @@ if [ ! $? ]; then exit -1 fi -notify-send - "$0" -i microphone "All sinks set-up" +notify-send -a "$0" -i microphone "All sinks set-up" carla ~/Projects/Audio/Carla/Sidechain\ comp\ Setup.carxp From ee000bafdb88c7aebe71f9bf1161e8abec54dd7a Mon Sep 17 00:00:00 2001 From: trotFunky Date: Fri, 29 Mar 2024 12:39:32 +0000 Subject: [PATCH 119/120] Auto_audio: Update project file Since switching to a new microphone, a new project file with updated parameters is used. Change the name in the script to match that. --- Perso/auto_audio.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Perso/auto_audio.sh b/Perso/auto_audio.sh index 7363009..096325c 100755 --- a/Perso/auto_audio.sh +++ b/Perso/auto_audio.sh @@ -26,7 +26,7 @@ fi notify-send -a "$0" -i microphone "All sinks set-up" -carla ~/Projects/Audio/Carla/Sidechain\ comp\ Setup.carxp +carla "~/Projects/Audio/Carla/Sidechain comp Setup - AT2040.carxp" pactl unload-module $mic_sink pactl unload-module $discord_sink From 853eacb2fc02e937f59730c76a3693bec4a57f3a Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Fri, 29 Mar 2024 12:39:29 +0000 Subject: [PATCH 120/120] Auto_audio: Update project file Since switching to a new microphone, a new project file with updated parameters is used. Change the name in the script to match that. --- Perso/auto_audio.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Perso/auto_audio.sh b/Perso/auto_audio.sh index 7363009..096325c 100755 --- a/Perso/auto_audio.sh +++ b/Perso/auto_audio.sh @@ -26,7 +26,7 @@ fi notify-send -a "$0" -i microphone "All sinks set-up" -carla ~/Projects/Audio/Carla/Sidechain\ comp\ Setup.carxp +carla "~/Projects/Audio/Carla/Sidechain comp Setup - AT2040.carxp" pactl unload-module $mic_sink pactl unload-module $discord_sink