Echo Snippet

Kick 'n'Dirty



CSS 8 DNS 1 SQL 1 ajax 1 apache 3 bash 11 convert 3 crontab 2 css 1 error 1 fail2ban 2 gogs 1 grav 1 htaccess 3 html 13 ip 8 iptables 2 js 6 mail 2 nano 2 netatmo 1 php 42 php4 1 php5 2 php7 1 plex 1 powershell 1 regex 1 rss 3 secu 1 shell 25 ssl 2 stylus 3 tls 1 windows 1 youtube 2

.

Derniers snippets

# Echo'system' Snippet

Les petits bouts de codes qui sauvent la vie ;)

[CSS] The Black Hexagon

body {
    font-family: 'Share Tech', sans-serif;
    font-size: 68px;
    color: white;
   display: flex;
    jsutify-content: center;
   align-items: center;
   margin: 0;
    width: 100vw;
    height: 100vh;
    text-shadow: 8px 8px 10px #0000008c;
    background-color: #343a40;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%239C92AC' fill-opacity='0.25' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"), linear-gradient(to right top, #343a40, #2b2c31, #211f22, #151314, #000000);
}
 
h1 {
    margin: 20px;
}

//   https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2022/05/1-The-black-hexagon-background-pattern.jpg?q=50&fit=crop&w=1500&dpr=1.5


CSS

https://www.makeuseof.com/css-background-patterns-examples/

<iframe width="100%" height="578" src="https://snippet.echosystem.fr?embed=627cb3ea5ed7f" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 12/05/2022

GRAV CMS - CSS Dark

.CodeMirror-cursor { background: #fff!important; }

.code-mirrored {
    width: 1px;
    background: rgba(255, 255, 255, 0.6) !important;
}


.breadcrumb-node:hover span {
    text-decoration: none;
    color: #242526;
}


.breadcrumb-node  span {
    text-decoration: none;
    color: #242526;
} 

grav css

echosystem.fr

<iframe width="100%" height="506" src="https://snippet.echosystem.fr?embed=6232fe9ad2f57" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 17/03/2022

SQL progress import

Import SQL avec barre de progression

Vous avez un dump sql de 15 Go à remonter sur votre base de données, vous le lancez et pendant de longues minutes vous contemplez quelque chose comme ceci :

$ zcat data-export.gz | mysql -u measuser -p -h db_host -P 3306 mydatabase
Enter password: 

Est-ce que cela fonctionne ? Combien de temps avant la fin ? Est-ce que le terminal à freeze ?
Pipe View

pv est un outil qui permet d’avoir en temps réel l’état d’avancement d’une tache ou d’un flux de données (https://man7.org/linux/man-pages/man1/pv.1.html).

Pour l’installer :

sudo apt install pv

Utilisation

La commande devient alors :

$ zcat data-export.gz | pv --progress --size $(zcat data-export.gz | wc -c) --name '  Importing.. ' \
    | mysql -u measuser -p -h db_host -P 3306 mydatabase
Enter password: 
  Importing.. [=========>                                                             ] 15%

Et voilà ! Une barre de progression qui permet de savoir où en est l’import.

Attention : La commande $(zcat data-export.gz | wc -c) qui permet d’avoir le taille en byte du fichier décompressé est longue. Elle lit tout le fichier. Cela peut être intéressant de la sortir pour ne l’exécuter qu’une seule fois.

Le truc est tiré de stackoverflow.
Edit 2021-12-20

Dans un commentaire hg propose cette syntaxe qui laisse pv gérer la taille du dump. À tester :

pv -pret --name ' Importing.. ' data-export.gz | zcat \
    | mysql -u measuser -p -h db_host -P 3306 mydatabase


------------------------------------------------------

# Choix 1:

zcat data-export.gz | pv --progress --size $(zcat data-export.gz | wc -c) --name ' Importing.. ' | mysql -u measuser -p -h db_host -P 3306 mydatabase

# Choix 2:

pv -pret --name ' Importing.. ' data-export.gz | zcat | mysql -u measuser -p -h db_host -P 3306 mydatabase

SQL

https://www.journalduhacker.net/s/knmp7w/import_sql_avec_barre_de_progression

<iframe width="100%" height="1028" src="https://snippet.echosystem.fr?embed=61c0469ae06eb" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 20/12/2021

RSS-bridge ( filtre perso )

#cat whitelist.txt

AllocineFRBridge
AmazonBridge
AmazonPriceTrackerBridge
Arte7
Bandcamp
BlaguesDeMerde
CNETBridge
DailymotionBridge
DansTonChat
DuckDuckGo
DuckDuckGoBridge
Facebook
Flickr
FlickrExploreBridge
FuturaSciencesBridge
GOG
GogsBridge
GoogleSearch
HDWallpapersBridge
Identica
IdenticaBridge
Instagram
InstagramBridge
LeBonCoinBridge
LesJoiesDuCode
MozillaSecurity
OpenClassrooms
Pinterest
PinterestBridge
Scmb
Soundcloud
Steam
Telegram
TheCodingLoveBridge
ThePirateBayBridge
TheTVDBBridge
TwitchBridge
Twitter
TwitterBridge
WikiLeaksBridge
Wikipedia
WikipediaBridge
WikipediaENBridge
WikipediaEOBridge
WikipediaFRBridge
YGGTorrentBridge
Youtube
ZatazBridge
ZoneTelechargementBridge

whitelist.txt

<iframe width="100%" height="1118" src="https://snippet.echosystem.fr?embed=61b744e414893" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 13/12/2021

[SHELL] FAIL2BAN TIPS

Check ALL ban with fail2ban:

# fail2ban-client -V
0.11.2


# (we removed some character for more visibility)
fail2ban-client banned | tr " " "\n"  | sed "s/',\|'\|{\|\[\|]}\|]\|,//g"

# Or 

fail2ban-client banned | tr "]}" "\n"  | sed "s/',\|'\|{\|\[\|]}\|]\|,//g"


fail2ban shell

<iframe width="100%" height="434" src="https://snippet.echosystem.fr?embed=61add4996e3b9" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 11/12/2021

DNS 2021

# DNS



 - NextDNS: 

Bloquer les publicités et les traqueurs


Serveurs DNS IPV4
45.90.28.91
45.90.30.91

Serveurs DNS IPV6
2a07:a8c0::cf:3a39
2a07:a8c1::cf:3a39

DNS-over-TLS
cf3a39.dns.nextdns.io

DNS-over-HTTPS
https://dns.nextdns.io/cf3a39


--------------------------------


- DNSFILTER

Le réseau mondial anycast s'étend sur 48 centres de données, garantissant une faible latence et une disponibilité de 100 %.

Les adresses des serveurs DNS de DNSFilter (avec DNSSEC) :

    103.247.36.9
    103.247.37.9

-------------------------------



Quelles adresses DNS  ? 💻

    Google propose deux adresses : 8.8.8.8 et 8.8.4.4. Une option efficace mais qui offre vos données sur un plateau à la firme de Mountain View.

    Les serveurs DNS de Cloudflare sont par exemple bien plus protecteurs des données : 1.1.1.1 et 1.0.0.1.

    On peut aussi vous conseiller la solution OpenDNS (208.67.222.222 et 208.67.220.220) qui, on vous prévient, appartient à Cisco.

    Et enfin, les serveurs associatifs et réputés sécurisés FDN (80.67.169.12 et 80.67.169.40), en sachant qu'il en existe beaucoup d'autres.


DNS

https://www.malekal.com/comparatif-meilleurs-dns/

<iframe width="100%" height="1100" src="https://snippet.echosystem.fr?embed=61a3d27fc83d1" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 28/11/2021

REGEX

Pour utiliser ces expression régulières, il vous faudra utiliser en JavaScript les fonctions match et replace et en PHP les fonctions preg_match et preg_replace soit par exemple :

// PHP
function checkMail($email)
{
    return preg_match("/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/", $email);
}
// Javascript
function checkMail(email) {
    return email . match(/^[_a - z0 - 9 -] + (.[_a - z0 - 9 -] +)*@[a - z0 - 9 -] + (.[a - z0 - 9 -] +)*(.[a - z]{
        2,3})$/);
}


Voici quelques unes des expressions régulières que je me garde toujours sous le coude en cas de besoin :

// tester un email
^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})$

// tester une url
^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$

// tester une adresse ip
^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$
^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$

// récupérer le contenu entre deux balises strong (à adapter, en php utilisez preg_match_all )
^(.*)$

// tester un code postale
^((0[1-9])|([1-8][0-9])|(9[0-8])|(2A)|(2B))[0-9]{3}$

// tester sur le texte fait bien entre 4 et 128 caractères
^(.){4,128}$

// tester un numéro de téléphone américain (333-333-3333)
^[0-9]{3,3}[-]{1,1}[0-9]{3,3}[-]{1,1}[0-9]{4,4}$

// tester un numéro de téléphone anglais (01614840484)
^[0-9]{11,11}$

// tester un code postale anglais (55416)
^[0-9]{5,5}$

// tester un code postale américain (AL42PT)
^[A-Z]{1,2}([0-9]{1,2}|[0-9]{1,1}[A-Z]{1,1})( |)[0-9]{1,1}[A-Z]{2,2}$

// tester une adresse IP V6
^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*$



########################################

# Variant


^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-fA-F]|[a-fA-F][a-fA-F0-9\-]*[a-fA-F0-9])\.)*([A-Fa-f]|[A-Fa-f][A-Fa-f0-9\-]*[A-Fa-f0-9])$|^(?:(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){6})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:::(?:(?:(?:[0-9a-fA-F]{1,4})):){5})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})))?::(?:(?:(?:[0-9a-fA-F]{1,4})):){4})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,1}(?:(?:[0-9a-fA-F]{1,4})))?::(?:(?:(?:[0-9a-fA-F]{1,4})):){3})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,2}(?:(?:[0-9a-fA-F]{1,4})))?::(?:(?:(?:[0-9a-fA-F]{1,4})):){2})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,3}(?:(?:[0-9a-fA-F]{1,4})))?::(?:(?:[0-9a-fA-F]{1,4})):)(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,4}(?:(?:[0-9a-fA-F]{1,4})))?::)(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,5}(?:(?:[0-9a-fA-F]{1,4})))?::)(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,6}(?:(?:[0-9a-fA-F]{1,4})))?::)))))$

# ipv4 et ipv6 ?
regex='(?>(?>([a-f\d]{1,4})(?>:(?1)){3}|(?!(?:.*[a-f\d](?>:|$)){})((?1)(?>:(?1)){0,6})?::(?2)?)|(?>(?>(?1)(?>:(?1)){5}:|(?!(?:.*[a-f\d]:){6,})(?3)?::(?>((?1)(?>:(?1)){0,4}):)?)?(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)(?>\.(?4)){3}))\/\d{1,2}'


# JSON
(?(DEFINE)
# Note that everything is atomic, JSON does not need backtracking if it's valid
# and this prevents catastrophic backtracking
(?<json>(?>\s*(?&object)\s*|\s*(?&array)\s*))
(?<object>(?>\{\s*(?>(?&pair)(?>\s*,\s*(?&pair))*)?\s*\}))
(?<pair>(?>(?&STRING)\s*:\s*(?&value)))
(?<array>(?>\[\s*(?>(?&value)(?>\s*,\s*(?&value))*)?\s*\]))
(?<value>(?>true|false|null|(?&STRING)|(?&NUMBER)|(?&object)|(?&array)))
(?<STRING>(?>"(?>\\(?>["\\\/bfnrt]|u[a-fA-F0-9]{4})|[^"\\\0-\x1F\x7F]+)*"))
(?<NUMBER>(?>-?(?>0|[1-9][0-9]*)(?>\.[0-9]+)?(?>[eE][+-]?[0-9]+)?))
)
\A(?&json)\z

regex

https://www.lije-creative.com/regex-le-top-des-expressions-regulieres/

<iframe width="100%" height="1568" src="https://snippet.echosystem.fr?embed=618fc607ef59f" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 13/11/2021

[BASH] Script BAN iptables -ipset V.2

#!/bin/bash
# Script name : Ban/Unban IP with Iptables

# iptables -I INPUT 1 -m set --match-set portsentry src -j DROP

ipsetmyips="/var/log/ipset_Myips_ip.txt"
ipsetips="/var/log/ipset_all_ip.txt"

badips="/var/log/banip.log"
mybadips="/var/log/banip_perso.log"

ipsetlm=`ipset list Myips | grep "$ZTARGET"`
mylistip=`grep "$ZTARGET" $mybadips`


### color
NC=$(tput sgr0)
NOC=$(tput sgr0)
reset=$(tput sgr0)
GREEN=$(tput setaf 2)
PINK=$(tput setaf 5)
BLUE=$(tput setaf 6)
RED=$(tput setaf 1)
YELLOW=$(tput setaf 3)
ORANGE=$(tput setaf 166)
#GRIS="\e[38;5;8m"
GRIS=$(tput setaf 246)
CNoir=$(tput setaf 0)
CRouge=$(tput setaf 1)
CVert=$(tput setaf 2)
Jaune=$(tput setaf 3)
CBeu=$(tput setaf 4)
CRose=$(tput setaf 5)
CCyan=$(tput setaf 6)
CBlanc=$(tput setaf 7)
CGris=$(tput setaf 8)
CFade=$(tput setaf 75)
CGris1=$(tput setaf 235)
On_Red=$(tput setab 124)
On_Green=$(tput setab 28) # ou 40

CALERT="$(tput setaf 0)$(tput setab 124)" # Bold White on red background
CAlert="${CBlanc}${On_Red}"
Cokvb="${CBlanc}${On_Green}"
Cokv="${CNoir}${On_Green}"
Cokvo="${CBlanc}${On_Green} OK $(tput sgr0)"
Cko="$(tput setaf 1)X$(tput sgr0)"
Cok="$(tput setaf 2)✔$(tput sgr0)"
txtred=$(tput setaf 1)
txtyel=$(tput setaf 3)
txtcya=$(tput setaf 6)
txtrst=$(tput sgr0)

ipset_Myips_check(){

IPSET_LIST_NAME="Myips"
# create the ipset if needed (or abort if does not exists and FORCE=no)
if ! ipset list -n|command grep -q "$IPSET_LIST_NAME"; then
  if [[ ${FORCE:-no} != yes ]]; then
    echo >&2 "Error: ipset does not exist yet, add it using:"
    echo >&2 "# ipset create $IPSET_LIST_NAME -exist hash:net family inet hashsize ${HASHSIZE:-16384} maxelem ${MAXELEM:-65536}"
#    exit 1
  fi
#  if ! ipset create "$IPSET_LIST_NAME" -exist hash:net family inet hashsize "${HASHSIZE:-16384}" maxelem "${MAXELEM:-65536}"; then
#    echo >&2 "Error: while creating the initial ipset"
#    exit 1
#  fi
fi

# create the iptables binding if needed (or abort if does not exists and FORCE=no)
if ! iptables -nvL INPUT|command grep -q "match-set $IPSET_LIST_NAME"; then
  # we may also have assumed that INPUT rule n°1 is about packets statistics (traffic monitoring)
  if [[ ${FORCE:-no} != yes ]]; then
    echo >&2 "Error: iptables does not have the needed ipset INPUT rule, add it using:"
    echo >&2 "# iptables -I INPUT ${IPTABLES_IPSET_RULE_NUMBER:-1} -m set --match-set $IPSET_LIST_NAME src -j DROP"
#    exit 1
  fi
#  if ! iptables -I INPUT "${IPTABLES_IPSET_RULE_NUMBER:-1}" -m set --match-set "$IPSET_LIST_NAME" src -j DROP; then
#    echo >&2 "Error: while adding the --match-set ipset rule to iptables"
#    exit 1
#  fi
fi

echo -e "$Cok ipset ${CGris} $IPSET_LIST_NAME $(tput sgr0)   checked"
unset IPSET_LIST_NAME
#echo "test IPSET_LIST_NAME $IPSET_LIST_NAME"
}

ipset_blockip_check(){

IPSET_LIST_NAME="blockip"
# create the ipset if needed (or abort if does not exists and FORCE=no)
if ! ipset list -n|command grep -q "$IPSET_LIST_NAME"; then
  if [[ ${FORCE:-no} != yes ]]; then
    echo >&2 "Error: ipset does not exist yet, add it using:"
    echo >&2 "# ipset create $IPSET_LIST_NAME -exist hash:net family inet hashsize ${HASHSIZE:-16384} maxelem ${MAXELEM:-65536}"
#    exit 1
  fi
#  if ! ipset create "$IPSET_LIST_NAME" -exist hash:net family inet hashsize "${HASHSIZE:-16384}" maxelem "${MAXELEM:-65536}"; then
#    echo >&2 "Error: while creating the initial ipset"
#    exit 1
#  fi
fi

# create the iptables binding if needed (or abort if does not exists and FORCE=no)
if ! iptables -nvL INPUT|command grep -q "match-set $IPSET_LIST_NAME"; then
  # we may also have assumed that INPUT rule n°1 is about packets statistics (traffic monitoring)
  if [[ ${FORCE:-no} != yes ]]; then
    echo >&2 "Error: iptables does not have the needed ipset INPUT rule, I will add it:"
    echo >&2 " iptables -I INPUT ${IPTABLES_IPSET_RULE_NUMBER:-1} -m set --match-set $IPSET_LIST_NAME src -j DROP"
    iptables -I INPUT ${IPTABLES_IPSET_RULE_NUMBER:-1} -m set --match-set $IPSET_LIST_NAME src -j DROP
#    exit 1
  fi
#  if ! iptables -I INPUT "${IPTABLES_IPSET_RULE_NUMBER:-1}" -m set --match-set "$IPSET_LIST_NAME" src -j DROP; then
#    echo >&2 "Error: while adding the --match-set ipset rule to iptables"
#    exit 1
#  fi
fi
echo -e "$Cok ipset ${CGris} $IPSET_LIST_NAME $(tput sgr0) checked"
unset IPSET_LIST_NAME
#echo "test $IPSET_LIST_NAME"
}

ipset_portsentry_check(){

IPSET_LIST_NAME="portsentry"
# create the ipset if needed (or abort if does not exists and FORCE=no)
if ! ipset list -n|command grep -q "$IPSET_LIST_NAME"; then
  if [[ ${FORCE:-no} != yes ]]; then
    echo >&2 "Error: ipset does not exist yet, add it using:"
    echo >&2 "# ipset create $IPSET_LIST_NAME -exist hash:net family inet hashsize ${HASHSIZE:-16384} maxelem ${MAXELEM:-65536}"
#    exit 1
  fi
#  if ! ipset create "$IPSET_LIST_NAME" -exist hash:net family inet hashsize "${HASHSIZE:-16384}" maxelem "${MAXELEM:-65536}"; then
#    echo >&2 "Error: while creating the initial ipset"
#    exit 1
#  fi
fi

# create the iptables binding if needed (or abort if does not exists and FORCE=no)
if ! iptables -nvL INPUT|command grep -q "match-set $IPSET_LIST_NAME"; then
  # we may also have assumed that INPUT rule n°1 is about packets statistics (traffic monitoring)
  if [[ ${FORCE:-no} != yes ]]; then
    echo >&2 "Error: iptables does not have the needed ipset INPUT rule, add it using:"
    echo >&2 "# iptables -I INPUT ${IPTABLES_IPSET_RULE_NUMBER:-1} -m set --match-set $IPSET_LIST_NAME src -j DROP"
#    exit 1
  fi
#  if ! iptables -I INPUT "${IPTABLES_IPSET_RULE_NUMBER:-1}" -m set --match-set "$IPSET_LIST_NAME" src -j DROP; then
#    echo >&2 "Error: while adding the --match-set ipset rule to iptables"
#    exit 1
#  fi
fi

echo -e "$Cok ipset ${CGris} $IPSET_LIST_NAME $(tput sgr0)   checked"
unset IPSET_LIST_NAME
#echo "test IPSET_LIST_NAME $IPSET_LIST_NAME"
}



ipset_check_(){
ipset_Myips_check
ipset_blockip_check
#ipset_portsentry_check
}

save_myips() {

# iptables -I INPUT -m set --match-set Myips src -j DROP
# [ -s `iptables -nL | grep "match-set Myips"` ]  iptables -I INPUT -m set --match-set Myips src -j DROP || echo "Check iptables:"; iptables -nL |  grep "match-set Myips"

 echo -e "iptables rules for Myips: $Cok"
 ipset save Myips | tail -n +2 > $ipsetmyips
 echo -e " ipset save Myips > $ipsetmyips\n"
 ipset save       | tail -n +2 > $ipsetips
 echo -e " ipset save > $ipsetips\n"

# Backup HOME / ipset perso
#    /sbin/ipset -exist create Myips hash:ip hashsize 4096
    /sbin/ipset save > /home/backup/ipset_save_all_$HOSTNAME_$(date "+%d.%m.%Y").txt
    /sbin/ipset save Myips > /home/backup/ipset_Myips_save_$HOSTNAME_$(date "+%d.%m.%Y").txt
    /sbin/ipset -exist create portsentry hash:ip hashsize 4096
    /sbin/ipset save portsentry > /home/backup/ipset_portsentry_save_$HOSTNAME_$(date "+%d.%m.%Y").txt
    /sbin/iptables-save   > /home/backup/iptables-save.$HOSTNAME-$(date "+%d.%m.%Y")

# Backup iptables-persistant reboot
     /sbin/iptables-save  > /etc/iptables/rules.v4
     /sbin/ip6tables-save > /etc/iptables/rules.v6 ;  /usr/sbin/ip6tables-legacy-save  > /etc/iptables/rules_legacy.v6
     /sbin/ipset save     > /etc/iptables/ipsets
     /usr/sbin/netfilter-persistent save
#    /sbin/ipset -exist create blacklist hash:ip hashsize 4096
}


function help {
    echo -e "\nSyntax: $0 -[L][u] target(s)"
    echo -e " ${CGris} Parameters come first. Target is expressed as an IP address.$(tput sgr0)"
    echo -e " ${CGris} No specified parameter will ban the IP.$(tput sgr0)"
    echo -e "  ${txtyel} -L $(tput sgr0)to list currently banned IPs. $(tput sgr0)"
    echo -e "  ${txtyel} -D $(tput sgr0)to De/unban IP(s). $(tput sgr0)"
    echo -e "  ${txtyel} -C $(tput sgr0)Check if ip is already ban. $(tput sgr0)"
    echo -e "  ${txtyel} -U $(tput sgr0)Check Rules & Update ip files & blacklist.$(tput sgr0)"
    echo -e "  ${txtyel} -S $(tput sgr0)Save all IPs.$(tput sgr0)"
    echo -e "  ${txtyel} -B $(tput sgr0)Ban list $(tput sgr0)\n"
    exit 1
}

#/home/tools/SH/banip.sh $(/home/tools/SH/secu-apache-ban-grep.sh -i)
# If no arguments are passed, call the "help" function.
if [ -z "$1" ]; then
    help
fi

# Define some variables
ACTION="-A"

while getopts "hCDLUSBI" OPTION
do
    case $OPTION in
        h)
            help
            ;;
        D)
            ACTION="-D"
            shift $(($OPTIND - 1))
            ;;
        L)
            ACTION="-L"
            shift $(($OPTIND - 1))
            ;;
        I)
            ACTION="-I"
            shift $(($OPTIND - 1))
            ;;
        C)
            ACTION="-C"
            shift $(($OPTIND - 1))
            ;;
        U)
            ACTION="-U"
            shift $(($OPTIND - 1))
            ;;
        S)
            ACTION="-S"
            shift $(($OPTIND - 1))
            ;;
        B)
            ACTION="-B"
            shift $(($OPTIND - 1))
            ;;
        \?)
            help
            ;;
    esac
done



##############################
# Deban ip

if [ $ACTION == "-D" ]; then
 for ZTARGET in "$@"
    do
   ipsetlm=`ipset list Myips | grep "$ZTARGET"`
   mylistip=`grep "$ZTARGET" $mybadips`
if [ "$ZTARGET" = "$ipsetlm" ]
 then
    echo -e " IPSET ${CGris}Myips $(tput sgr0)"
    echo -e " $CRouge IP found ($ZTARGET) $txtrst"
    ipset del Myips "$ZTARGET"; echo -e " ${Cokvb} REMOVED! ($ZTARGET) $(tput sgr0)"
 else
  echo -e "\n IPSET : ${CGris}(Myips)\n $Cokvb No ban IP found or already removed! $(tput sgr0)"
 fi

 echo -en " Myfile: ${CGris}($mybadips)\n"; [ -z "$mylistip" ] && echo -e " $Cokvb ($ZTARGET) NOT found $(tput sgr0)\n" || echo -e " $CRouge IP found ($ZTARGET) $(tput sgr0)\n ${Cokvb} REMOVED! ($ZTARGET) $(tput sgr0)" ; sed -i "/$ZTARGET/d" "$mybadips"
    done
 exit 1
fi

##############################
# Ban list with /home/tools/SH/secu-apache-ban-grep.sh
if [ $ACTION == "-B" ]; then

#  mylistip=$(/home/tools/SH/secu-apache-ban-grep.sh -i)
         mylistip=$(/home/tools/SH/secu-apache-grep-log.sh -i)
 echo  $mylistip

#iptables -I INPUT 1 -m set --match-set Myips src -j DROP
 exit
fi


##############################
#  Save all ip ipset
if [ $ACTION == "-S" ]; then
 /home/tools/SH/iptables-save_all.sh
  exit
fi


###############################
# Check if ip is already ban.

if [ $ACTION == "-C" ]; then
  #ipset_Myips_check
  for ZTARGET in "$@"
    do
  #check_ipset_ip $1
  mylistip=`grep "$ZTARGET" $mybadips | uniq`
#  [ -z "$mylistip" ] && echo -e " $CAlert no IP to check, exit!$(tput sgr0)" ; exit 1 || echo -e " $CAlert IP found $(tput sgr0)"

  ipsetlm=`ipset list Myips | grep "$ZTARGET"`
 if [ "$ZTARGET" = "$ipsetlm" ]
  then
    echo -e " ${Cok} ${Cokvb} IP ALREADY BAN $txtrst "
    echo -e " ${Cok} ${Cokvb} IP FOUND $(tput sgr0) ${CAlert} `ipset list Myips| grep "$ZTARGET"` $(tput sgr0) on ${Jaune} Myips $txtrst "
#        ipset list Myips| grep "$ZTARGET"
  else
    echo -e " ${Cok} ${Cokvb} NO IP found $(tput sgr0) ipset ${CGris}Myips$(tput sgr0)"
 fi

  [  -z "$mylistip" ] && echo -e " ${Cok} ${Cokvb} NO IP found $(tput sgr0) ${Cok} (${CGris}$mybadips$(tput sgr0))" || echo -e " ${Cok} ${Cokvb} IP FOUND $(tput sgr0) ${CAlert} `grep ${ZTARGET} $mybadips | uniq | wc -L` $(tput sgr0) on ${Jaune} $(echo $mybadips) $(tput sgr0)"
    #       sed '/^ $ZTARGET/d'  $mybadips

 done

 [  -z `ipset list | grep $ZTARGET | wc -L` ] &&  echo -e " ${Cok} ${Cokvb} NO IP found on ipset list $(tput sgr0)" ||  echo -e " ${Cok} ${Cokvb} IP FOUND $(tput sgr0) ${CAlert} `ipset list | grep ${ZTARGET} | wc -L` $(tput sgr0) on  ALL ipset list $(tput sgr0)"

#if [ "$ZTARGET" = `ipset list | grep "$ZTARGET"` ]
# then
# echo " Check all list"
# ipset list | grep $ZTARGET

  exit 1
fi


if [ $ACTION == "-I" ]; then
echo
echo "$(tput setaf 166)"
date
echo " $(tput sgr0)"
echo

  echo -e "$CGris\n##################$(tput sgr0)"
  echo -e "$Cokv ipset list Myips $(tput sgr0)\n"
  ipset list Myips
  echo -e "$CGris\n############################$(tput sgr0)"
fi

###############################
if [ $ACTION == "-L" ]; then
echo
echo "$(tput setaf 166)"
date
echo " $(tput sgr0)"
echo
  awk '{print $1}'  $mybadips   | sort | uniq  > $badips
  ipset_check_
  echo -e "$CGris\n################$(tput sgr0)"
  echo -e "$Cokv Rules iptables $(tput sgr0)"
  echo -e "$CCyan"
   # iptables -L INPUT -v -n | grep DROP | uniq -c   | sort
   iptables -L INPUT -v -n  | grep multiport
   iptables -L INPUT -v -n  | grep match-set
   iptables -L INPUT -v -n  | grep "f2b-"

  echo -e "$CGris\n################$(tput sgr0)"
  echo -e "$Cokv ipset list all $(tput sgr0)\n"
  echo -en $txtrst; ipset list | grep "Name:" | head -n1 && echo -en $txtred;  ipset list | grep  "entries:"  | head -n1
  echo -en $txtrst; ipset list | grep "Name:" | head -n2 | tail -n1 && echo -en $txtred; ipset list | grep  "entries:"  | head -n2 | tail -n1
  echo -en $txtrst; ipset list | grep "Name:" | head -n3 | tail -n1 && echo -en $txtred; ipset list | grep  "entries:"  | head -n3 | tail -n1
  echo -en $txtrst; ipset list | grep "Name:" | head -n4 | tail -n1 && echo -en $txtred; ipset list | grep  "entries:"  | head -n4 | tail -n1
#  echo -en $txtrst; ipset list | grep "Name:" | head -n5 | tail -n1 && echo -en $txtred; ipset list | grep  "entries:"  | head -n5 | tail -n1

#  echo -e "$Cokv List of MY Personal ip ban $(tput sgr0)   $badips ( ${CAlert}`awk '{print $1}'  $mybadips  | sort | uniq | wc -l` $(tput sgr0) )\n"


  # remove first line
  # echo -e "$Cokv List of MY Personal ip ban $(tput sgr0)   $badips (${CAlert}`awk '{print $1}'  $mybadips  | sort | uniq | tail -n +2 | wc -l`$(tput sgr0))\n"
#  awk '{print $1}'  $mybadips   | sort | uniq  > $badips
#  cat $badips


else

   # ban work loop
   for ZTARGET in "$@"
    do
   # Check Myips rules in iptables.
#    ipset_check_
   # ADD entry to Myips
    echo -e "$ZTARGET"  >>  $mybadips
    #  ipset -exist create Myips hash:ip hashsize 4096 -!
    # not verbode with -!
    # ipset add Myips "$ZTARGET" -!
    ipsetlm=`ipset list Myips | grep "$ZTARGET"`

  if [ "$ZTARGET" = "$ipsetlm" ]
   then echo -e "$Cok IP  ${Cokvb} Already Banned! $(tput sgr0) -->  $ZTARGET $(tput sgr0)"
   else  ipset add Myips "$ZTARGET" -! && echo -en "$Cok IP Banned: `ipset list Myips | grep  "$ZTARGET"`$(tput sgr0)\n"
  fi
#    iptables -I INPUT -m set --match-set Myips src -j DROP

# let's go to ban (iptables)
# Uncomment this if you want to use iptables!

#    echo $txtcya"Applying action $txtred$ACTION$txtcya to $txtyel$ZTARGET"$txtrst
#    iptables $ACTION INPUT -s $ZTARGET -j DROP
    done

fi


##############################
if [ $ACTION == "-U" ]; then

echo -e "\n"
   ipset_check_
   echo -e "\n${CGris}Make clean log (remove blank line) on$(tput sgr0) $mybadips"
   echo -e "  Before (`cat $mybadips | wc -l`) lines."
   sed -i '/^$/d' $mybadips
   echo -e "$Cok After  (`cat $mybadips | wc -l`) lines.\n"
   echo -e "\n$txtcya Populate Blacklist $txtrst"


   echo -e "$(tput sgr0)\n"
fi


#####################################################

#iptables -I INPUT -m set --match-set Myips src -j DROP
#iptables -I INPUT -m set --match-set blockip src -j DROP
#iptables -I INPUT -m set --match-set portsentry src -j DROP

######################################################
updateblacklist() {
   echo -e "\n$txtcya Populate Date$txtrst"
   /etc/ipset-blacklist/update-blacklist.sh /etc/ipset-blacklist/ipset-blacklist.conf
   echo -e "...$(tput sgr0)"

#   echo $txtcya"Applying action $txtred$ACTION$txtcya to $txtyel$ZTARGET"$txtrst
#        iptables $ACTION INPUT -s $ZTARGET -j DROP
}


secu bash ip iptables

<iframe width="100%" height="8246" src="https://snippet.echosystem.fr?embed=618aaf8632175" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 09/11/2021

[BASH] Script to check in apache log for some BAD requests.

#!/bin/bash
#
# Check-appa-log.sh // Script By E32

# how to run this script: $ bash Check-appa-log.sh

#ADD your own ip or ip you don't want to ban. 
ipowner="82.46.24.92"
ipowner2="202.03.13.20"


varlog(){
loge=/var/log/apache2/error.log
loga=/var/log/apache2/access.log
grepfiltre=" [0-9]\+[.][0-9]\+[.][0-9]\+[.][0-9]\+"
#filterse="alert("
filterse="String\(|passwd|tar|zip|rar|gz|sql|xmlrpc.php|/wp"
#filterse="String|passwd"
filtersa="String\(|/wp|/.env |xmlrpc.php"
}

#####################################
checkip_loga(){
varlog
echo -e "$(tput setaf 1)🌍$(tput setaf 3) IP $(tput setaf 1)💢$(tput setaf 4) ${filtersa} $(tput setaf 3)👉$(tput setaf 2) $loga$(tput sgr0) "
}

checkip_loge(){
varlog
echo -e "$(tput setaf 1)🌍$(tput setaf 3) IP $(tput setaf 1)💢$(tput setaf 4) ${filterse} $(tput setaf 3)👉$(tput setaf 2) $loge$(tput sgr0) "
}

showipa() {
varlog
# grep 404
check_ipa=$(egrep -i "$filtersa" $loga | grep -o "$grepfiltre" | sort | uniq | sed "s/\($ipowner\|$ipowner2\)//g")
echo -e " $check_ipa" | tr "\n" " "
}

showipe() {
varlog
check_ipe=$(egrep -i "$filterse" $loge | grep -o "$grepfiltre" | sort | uniq | sed "s/\($ipowner\|$ipowner2\)//g")
echo -e " $check_ipe" | tr "\n" " "
}

##########


logecount(){
varlog
tbante=`egrep -i $filterse $loge | grep -o "$grepfiltre" | uniq | wc -l`
echo -ne " $(tput setaf 3)»$(tput setaf 1) 🏆$(tput setaf 3) $tbante  $(tput sgr0)"
}

logacount(){
varlog
tbanta=`egrep -i $filtersa $loga | grep -o "$grepfiltre" | uniq | wc -l`
echo -ne " $(tput setaf 3)»$(tput setaf 1) 🏆$(tput setaf 3) $tbanta  $(tput sgr0)"
}

countips() {
  logecount
  checkip_loge

#       echo -e "\n"
  logacount
  checkip_loga

}

checkverboseall(){
  checkip_loge
  logecount
echo -ne "$(tput setaf 3) » $(tput setaf 1)List $(tput sgr0) "
  showipe
echo
echo
  checkip_loga
  logacount
echo -ne "$(tput setaf 3) » $(tput setaf 1)List $(tput sgr0) "
  showipa
echo
}

checkverbose(){
countips
echo
}


checkall(){
echo -e "\n -- CHECK --\n"
  checkip_loge
  logecount
echo
echo -ne "$(tput setaf 3) » $(tput setaf 1)List $(tput sgr0) "
  showipe
echo -e "\n$(tput setaf 3) » $(tput setaf 1)Logs $(tput sgr0) "
egrep -i --color=always ${filterse} $loge  |  grep --color=always "$grepfiltre" | sed "s/\($ipowner\|$ipowner2\)//g"
echo -e " \n  --------------------------------------------------\n"
  checkip_loga
  logacount
echo -ne "$(tput setaf 3) » $(tput setaf 1)List $(tput sgr0) "
  showipa
echo -e "\n$(tput setaf 3) » $(tput setaf 1)Logs $(tput sgr0)\n"
egrep -i --color=always ${filtersa} $loga  |  grep --color=always "$grepfiltre" | sed "s/\($ipowner\|$ipowner2\)//g"
}

 
show_cli() {
        echo -e "\n secu-apache CLI"
        echo -e "$(tput setaf 3) Usage:\n $(realpath $0) [arguments] $(tput sgr0)\n"
        echo -e " Arguments:"
        echo -e "  --help   (-h): Display this help message"
        echo -e "  --all    (-a): Ip list color"
        echo -e "  --ip     (-i): Ip list"
        echo -e "  --count  (-c): Count IPs"
        echo -e "  --check  (-C): Check Logs"
                echo -e "  --Ban    (-B): TEST ban"
                echo ""
}



case "$1" in

-h | --help)
        show_cli
        exit
        ;;
-c | --count)
       countips
       exit
        ;;
-a | --all)
         echo
         checkverboseall
         echo
        exit
        ;;
-i |  --ip)
         showipe
         showipa
         echo
        exit
        ;;
-B | --Ban)
     # need other script to include //
        ;;
-C | --Check)
        checkall
        echo
        exit
        ;;
-F | --Filtre)
         checkverbose
         echo
          exit
        ;;
*)
        echo -ne " \n Check with -h for more option \n\n$(tput setaf 1) 🔍$(tput sgr0) Check "
[  -z "showipe" ] && echo -e "Logs Clean $(tput setaf 4) ✅$(tput sgr0)" || echo -e "$(tput setaf 1)🚨$(tput sgr0) Ban FOUND $(tput setaf 1)⁉️$(tput sgr0) \n   $(tput setaf 3)👉to check:$(tput sgr0) $0 -C\n   $(tput setaf 3)👉to ban  :$(tput sgr0) $0 -B"
    echo
        checkverbose
        echo
        ;;

esac



################################################################
# ignore CTRL+C, CTRL+Z and quit singles using the trap
# trap '' SIGINT SIGQUIT SIGTSTP
trap "clear; exit" SIGHUP SIGINT SIGTERM

bash shell youtube

<iframe width="100%" height="3350" src="https://snippet.echosystem.fr?embed=61866a9c414a1" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 06/11/2021

[SHELL] systemctl list-timers



#  Timer on Debian

# in shell:
$  systemctl list-timers



# Result

```
NEXT                        LEFT          LAST                        PASSED       UNIT                         ACTIVATES
Tue 2021-11-02 21:39:00 CET 28min left    Tue 2021-11-02 21:09:01 CET 1min 50s ago phpsessionclean.timer        phpsessionclean.service
Tue 2021-11-02 23:13:38 CET 2h 2min left  Tue 2021-11-02 12:26:38 CET 8h ago       apt-daily.timer              apt-daily.service
Wed 2021-11-03 00:00:00 CET 2h 49min left Tue 2021-11-02 00:00:01 CET 21h ago      atop-rotate.timer            atop-rotate.service
Wed 2021-11-03 00:00:00 CET 2h 49min left Tue 2021-11-02 00:00:01 CET 21h ago      logrotate.timer              logrotate.service
Wed 2021-11-03 00:00:00 CET 2h 49min left Tue 2021-11-02 00:00:01 CET 21h ago      man-db.timer                 man-db.service
Wed 2021-11-03 03:18:50 CET 6h left       Tue 2021-11-02 17:57:50 CET 3h 13min ago certbot.timer                certbot.service
Wed 2021-11-03 06:01:35 CET 8h left       Tue 2021-11-02 06:32:35 CET 14h ago      apt-daily-upgrade.timer      apt-daily-upgrade.service
Wed 2021-11-03 15:24:59 CET 18h left      Tue 2021-11-02 15:24:59 CET 5h 45min ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Sun 2021-11-07 03:10:57 CET 4 days left   Sun 2021-10-31 03:10:33 CET 2 days ago   e2scrub_all.timer            e2scrub_all.service

9 timers listed.
Pass --all to see loaded but inactive timers, too.
```

shell

<iframe width="100%" height="650" src="https://snippet.echosystem.fr?embed=61819a4a75c78" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 06/11/2021

[fail2ban] EXCLUDE your ip in jail

#!/bin/sh

# debaniptuff.sh
# by E32


monipamoi="66.66.66.66"
MONFILE="/etc/fail2ban/jail.local"

echo -e "\n Script:  $0 \n"

[[ -z "$1" ]] && echo " [ADD IP] $monipamoi to $MONFILE" || monipamoi=$1
# && echo  "  ADD IP: $monipamoi"

# Check si le fichier existe !
if [[ -f $MONFILE ]];then
    echo " ✅$MONFILE exists"
else
    echo " ⛔️$MONFILE doesn't exist"
   exit 1
fi


pyestonsed() {
sed -i "/ignoreip /c\ignoreip = 127.0.0.1 192.168.1.0/24    $monipamoi" /etc/fail2ban/jail.local
}

backupfile() {
#On backup avant de tout nicker
cp /etc/fail2ban/jail.local /etc/fail2ban/jail.local_backup
}

# On execute le bourdel

#      Check si la ligfne à modifier exist
# -x, --line-regexp
#      Select only those matches that exactly match the whole line.
# -q, --quiet, --silent

if grep -q ignoreip "$MONFILE"
then
    echo " ✅ OK  let's go Baby"
    [[ -z "$monipamoi"  ]] && echo " NO IP provided ... exit script !" ; exit 1 || echo "  ADD IP: $monipamoi"
    backupfile
    pyestonsed
else
    echo " ⛔️ NO  code to modify  found"
   exit 1
fi

#
echo -e "\n ✅remplacement IP: ${monipamoi} [OK]\n"

fail2ban ip shell

<iframe width="100%" height="1118" src="https://snippet.echosystem.fr?embed=618145aa31373" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 03/11/2021

[BASH] SET -debug | error

Catch all errors in your script:


## debug
set -e -u -o pipefail
IFS=$'\n\t'
on_error() { echo "Error on or near line $1; exiting with status $2"; exit "$2"; }


# Trap error exit possible 
#trap 'on_error ${LINENO} $?' ERR


# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root" 1>&2
    exit 1
fi

shell

<iframe width="100%" height="506" src="https://snippet.echosystem.fr?embed=6135dff27e94e" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 02/11/2021

PLEX init-d debian

 cp  /usr/lib/plexmediaserver/lib/plexmediaserver.init /etc/init.d/plexmediaserver

#!/bin/sh
### BEGIN INIT INFO
# Provides:          plexmediaserver
# Required-Start:    $remote_fs $local_fs $all $syslog $networking
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Plex Media Server
# Description:       Plex Media Server for Linux,
#                    More information at http://www.plexapp.com
# Author:            Plex Packaging team
# Version:           1.06
### END INIT INFO

# Set Crash Reporting identification variables
export PLEX_MEDIA_SERVER_INFO_VENDOR="$(grep ^NAME= /etc/os-release | awk -F= '{print $2}' | tr -d \" )"
export PLEX_MEDIA_SERVER_INFO_DEVICE="PC"
export PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)"
export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$(grep ^VERSION= /etc/os-release | awk -F= '{print $2}' | tr -d \" )"

# Default values prior to ingesting and validating contents of /etc/default/plexmediaserver
PlexUser="plex"
PlexHome="/usr/lib/plexmediaserver"
PlexAppSuppDir="/var/lib/plexmediaserver/Library/Application Support"
PlexTempDir="/tmp"
PlexStackSize=3000
PlexPluginProcs=6

# Read configuration variable file if it is present
[ -r /etc/default/plexmediaserver ] && . /etc/default/plexmediaserver

Running=$(ps -ef | grep 'Plex Media Server'| grep -v grep | wc -l)

case "$1" in
  start)
    if [ $Running -gt 0 ]; then
      echo "Plex is already running."
      exit 0
    fi

    if [ -f /etc/default/locale ]; then
      export LANG="$(cat /etc/default/locale | awk -F '=' '/LANG=/{print $2}' | sed 's/"//g')"
      export LC_ALL="$LANG"
    fi

    # Use Read-Writeback approach to handle when variables aren't global.

    # Check PLEX_USER
    if   [ "$PLEX_USER" != "" ]; then
      if [ "$(getent passwd "$PLEX_USER")" != "" ]; then
        PlexUser="$PLEX_USER"
      else
        echo "${0}: No such username: \"$PLEX_USER\". Retaining \"$PlexUser\" as default username."
      fi
    fi

    # Check PLEX_MEDIA_SERVER_USER (Supersedes PLEX_USER)
    if   [ "$PLEX_MEDIA_SERVER_USER" != "" ]; then
      if [ "$(getent passwd "$PLEX_MEDIA_SERVER_USER")" != "" ]; then
        PlexUser="$PLEX_MEDIA_SERVER_USER"
      else
        echo "${0}: No such username: \"$PLEX_MEDIA_SERVER_USER\".  Retaining \"$PlexUser\" as default username."
      fi
    fi

    # Prevent "UNKNOWN" when in IPA/LDAP environments  (revert to default)
    if [ "$PlexUser" = "UNKNOWN" ]; then
      echo "${0}: Illegal username:  'UNKNOWN'.  Retaining \"plex\" as username."
      PlexUser="plex"
    fi

    # PlexUser's HOME directory is the default location. Supersede if specified
    PlexAppSuppDir="$(getent passwd "$PlexUser" | awk -F: '{print $6}')/Library/Application Support"

    # If user specified AppSuppDir, it must already exist.  This overrides the $PlexUser's "$HOME"
    if   [    "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" != "" ]; then
      if [ -d "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" ]; then
        PlexAppSuppDir="$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR"
      else
        echo "${0}: Given Application Support Directory \"$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR\" does not exist.  Ignoring."
      fi
    fi

    # Check TempDir
    Candidate=""
    # Be generous with TEMP DIR specification
    if [ "$TMPDIR" != "" ]; then
      Candidate="$TMPDIR"

    elif [ "$TEMP" != "" ]; then
      Candidate="$TEMP"

    elif [ "$TMP" != "" ] && [ -d "$TMP" ]; then
      Candidate="$TMP"
    fi

    # Validate TempCandidate
    if [ "$Candidate" != "" ]; then
      if [ -d "$Candidate" ]; then
        PlexTempDir="$Candidate"
      else
        echo "${0}: Temp Directory does not exist: \"$Candidate\".  Using default location."
      fi
    fi

    # Plug-in Procs  (No checking.  PMS handles internally)
    if [ "$PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS" != "" ]; then
      Candidate="$(echo $PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS | grep -x -E '[[:digit:]]+' )"
      if [ "$Candidate" != "" ]; then
        PlexPluginProcs="$Candidate"
      else
        echo "${0}: Non-numeric Max Plug-in Procs given: \"$PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS\".  Using default value."
      fi
    fi

    # Stack Size
    if [ "$PLEX_MEDIA_SERVER_MAX_STACK_SIZE" != "" ]; then
      Candidate="$(echo $PLEX_MEDIA_SERVER_MAX_STACK_SIZE | grep -x -E '[[:digit:]]+' )"
      if [ "$Candidate" != "" ]; then
        PlexStackSize="$Candidate"
      else
        echo "${0}: Non-numeric Max Stack Size given: \"$PLEX_MEDIA_SERVER_MAX_STACK_SIZE\".  Using default value."
      fi
    fi

    # Verify Plex Media Server is indeed where it says it is
    if [ "$PLEX_MEDIA_SERVER_HOME" != "" ]; then
      if [ -d "$PLEX_MEDIA_SERVER_HOME" ]; then
        PlexHome="$PLEX_MEDIA_SERVER_HOME"
      else
        echo "${0}: Given application location \"${PLEX_MEDIA_SERVER_HOME}\" does not exist.  Using default location."
      fi
    fi

    # Create AppSuppDir if not present and set ownership
    if [ ! -d "$PlexAppSuppDir" ]; then
      mkdir -p "$PlexAppSuppDir"
      if [ $? -eq 0 ]; then
        chown "${PlexUser}"."${PlexUser}" "$PlexAppSuppDir"
      else
        echo "ERROR: Could not create \"$PlexAppSuppDir\".  System error code $?"
        exit 1
      fi
    fi

    # Build the final runtime environment variables.  Specify these parameters in /etc/default/plexmediaserver
    export PLEX_MEDIA_SERVER_USER="$PlexUser"
    export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="$PlexPluginProcs"
    export PLEX_MEDIA_SERVER_HOME="$PlexHome"
    export PLEX_MEDIA_SERVER_MAX_STACK_SIZE="$PlexStackSize"
    export PLEX_MEDIA_SERVER_TMPDIR="$PlexTempDir"
    export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="$PlexAppSuppDir"

    export TMPDIR="${PlexTempDir}"
    ulimit -s "$PLEX_MEDIA_SERVER_MAX_STACK_SIZE"

    # Add sleep - for those who launch with this script
    echo "Starting Plex Media Server."

    su -m "$PLEX_MEDIA_SERVER_USER" -s /bin/sh -c "exec ${PLEX_MEDIA_SERVER_HOME}/Plex\ Media\ Server &" >/dev/null 2>&1
    sleep 3
    ;;

  stop)
    if [ $Running -eq 0 ]; then
      echo "Plex Media Server is not running."
      exit 0
    fi
    echo "Shutting down Plex Media Server: "

    # Ask nicely
    pids="$(ps -ef | grep 'Plex Media Server' | grep -v grep | awk '{print $2}')"
    kill -15 $pids

    sleep 5

    # Stuck
    pids="$(ps -ef | grep /usr/lib/plexmediaserver | grep -v grep | awk '{print $2}')"

    if [ "$pids" != "" ]; then
      kill -9 $pids
    sleep 2
    fi
    ;;

  restart)
    $0 stop
    sleep 5
    $0 start
    ;;

  status)
    if [ $Running -gt 0 ]; then
      echo "Plex Media Server is running."
    else
      echo "Plex Media Server is stopped."
    fi
    ;;

  *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
        ;;
esac

exit 0

shell

<iframe width="100%" height="3944" src="https://snippet.echosystem.fr?embed=610d16888dc88" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 02/11/2021

[CSS] Media Query

CSS media Query tips



/* Extra small devices (phones, 600px and down) */
@media (max-width: 600px) {...}

/* Small devices (portrait tablets and large phones, 600px and up) */
@media (min-width: 600px) {...}

/* Medium devices (landscape tablets, 768px and up) */
@media (min-width: 768px) {...}

/* Large devices (laptops/desktops, 992px and up) */
@media (min-width: 992px) {...}

/* Extra large devices (large laptops and desktops, 1200px and up) */
@media (min-width: 1200px) {...}



##################################################################
--> depending on where you start you might have for desktop first:

    @media (max-width: 1200px)
    @media (max-width: 992px)
    @media (max-width: 768px)
    @media (max-width: 576px)

--> while for mobile first you can have:

    @media (min-width: 576px)
    @media (min-width: 768px)
    @media (min-width: 992px)
    @media (min-width: 1200px)

CSS

<iframe width="100%" height="830" src="https://snippet.echosystem.fr?embed=60eff22e560d4" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 15/07/2021

[BASH] SSH_CLIENT warning connection

#!/bin/bash

# called from login scripts such as /etc/profile

if [ "${SSH_CLIENT%.*}" != "10.3.38" ]
 then 
 logger -t warn -p info.warn "$SSH_CLIENT connnection"
fi

bash shell

<iframe width="100%" height="326" src="https://snippet.echosystem.fr?embed=60e3329491fc9" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 02/11/2021

[AJAX] Loading screen waiting on php exec

<html>
<head>
    <title>loading please wait</title>
</head>
<body>    
    <div id="loading_div" style="display:none; width: 500px; margin:auto; margin-top: 50px; text-align: center">Veuiller patientez pendant l'execution du script <br /><br /><img src="ajax-loader.gif" /></div>

<script type="text/javascript" src="jquery-1.8.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $.ajax({
        url: 'newpage.php',
        type: "POST",
        beforeSend: function(){
         $("#loading_div").show();
       },
        success: function(retour){
            $('#loading_div').html(retour);
         }
    });
});
</script>
</body>
</html>

source: https://forum.alsacreations.com/profile-40255-Apoooo.html

ajax php

<iframe width="100%" height="650" src="https://snippet.echosystem.fr?embed=5fc78800af765" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 02/12/2020

[PHP] get data from div on external page.

<?php

// GET content from div  
$getcontents = "https://steamcommunity.com/sharedfiles/filedetails/?id=2116151222";
 
$data_scrapped = file_get_contents($getcontents);

$the_start = explode('<div class="detailsStatsContainerRight">', $data_scrapped);

$the_end = explode('</div>',$the_start[1]);

echo $the_end[0];

?>

php

<iframe width="100%" height="452" src="https://snippet.echosystem.fr?embed=5fc41cdb22bc6" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 29/11/2020

[PHP] load time execution on page

Put the following code at the very top of your PHP page (if you measure the time needed for particular part of the code put this right before that PHP code part)

<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
?>
The following code has to be put at the very end of the web page (or the end of the PHP code part)

<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo 'Page generated in '.$total_time.' seconds.';
?>




source : https://stackoverflow.com/a/25231173/8396238

php

https://stackoverflow.com/a/25231173/8396238

<iframe width="100%" height="596" src="https://snippet.echosystem.fr?embed=5fc41c4f404f2" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 29/11/2020

[Bash] Duration execution script

#!/bin/bash


# Stats run script
function time_executiom_script() {
echo "This script took $SECONDS seconds to execute"
}

# your function / stuff here

time_executiom_script



##########################################################



#!/bin/bash


# your function / stuff here

format_time() {
  ((h=${1}/3600))
  ((m=(${1}%3600)/60))
  ((s=${1}%60))
  printf "%02d:%02d:%02d\n" $h $m $s
 }

echo "Script completed in $(format_time $SECONDS)"


##########################################################


#!/bin/bash
START1="$(date +%s)"
sleep 2 
END1="$(date +%s)"
sleep 2
START2="$(date +%s)"
sleep 3
END2="$(date +%s)"
DURATION1=$[ ${END1} - ${START1} ]
DURATION2=$[ ${END2} - ${START2} ]
echo "The 1st part of the code took: ${DURATION1}"
echo "The 2nd part of the code took: ${DURATION2}"



##########################################################

#!/bin/bash
my_sleep_function(){
  sleep 1
}
OVERALL_START="$(date +%s)"
FUNCTION_START="$(date +%s)"
my_sleep_function
FUNCTION_END="$(date +%s)"
sleep 2
OVERALL_END="$(date +%s)"
echo "The function part of the code took: $[ ${FUNCTION_END} - ${FUNCTION_START} ] seconds to run"
echo "The overall code took: $[ ${OVERALL_END} - ${OVERALL_START} ] seconds to run"

bash shell

<iframe width="100%" height="1352" src="https://snippet.echosystem.fr?embed=5fa2bdafdd9fd" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 02/11/2021

[CSS] FIX Footer in bottom page

#footer {
   position:absolute;
   bottom:0;
   width:100%;
   height:40px;   /* Height of the footer */
}

CSS html

<iframe width="100%" height="290" src="https://snippet.echosystem.fr?embed=5fa1747218012" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 03/11/2021

[stylus] nextcloud fix color add file

/* new file text Yellow */
.oc-dialog .fileexists th label {
    font-weight: normal;
    color: #f2e923;
}

CSS stylus

<iframe width="100%" height="272" src="https://snippet.echosystem.fr?embed=5f0e082a5f8f4" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 02/11/2021

[stylus] GOGS

// Full WIDTH
/*full width*/
 
.ui.container:not(.fluid) {
    width: 90% !important;
}
 
.full.height {
    padding: 0;
    margin: 0 0 -80px 0;
    min-height: 100%;
}

.ui.container {
    width: 1327px;
    margin-left: auto !important;
    margin-right: auto !important;
}



// Dark theme

:root {
  --body-bg: white;
  --body-color: black;
  --anchor-color: red;
  --letter-spacing: 0;
}
@media (prefers-color-scheme: dark) {
    html {
        filter: invert(1) hue-rotate(.5turn);
    }
    img {
        filter: invert(1) hue-rotate(.5turn);
    }
    img:not(:hover) {
        opacity: .7;
        transition: opacity .25s ease-in-out;
    }
    :root {
        --body-bg: #403e3e;
        --body-color: white;
        --anchor-color: salmon;
        --letter-spacing: 0;
    }

}

body:not(.full-width) {
    background-color: var(--body-bg);
     
    letter-spacing: var(--letter-spacing);
}

.ui.menu .ui.dropdown .menu > .item:hover {
    background: rgba(0,0,0,.05) !important;
   /* color: rgba(85, 162, 200, .95) !important;*/
     color: #1e70bf !important;
}
.following.bar .top.menu a.item:hover {
   color: #bf611e !important;
}

.ui.secondary.pointing.menu .active.item:hover {
    border-color: #1b1c1d;
    color: #bf611e !important;
}
.ui.card > .extra a:not(.ui) , .ui.cards > .card > .extra a:not(.ui)  {
    color: #1e70bf;
}
.ui.card > .extra a:not(.ui):hover, .ui.cards > .card > .extra a:not(.ui):hover {
    color: #989da2;
}
.markdown:not(code) pre {
    word-wrap: normal;
    background-color: #cbcbcb; 
}

CSS gogs stylus

git.echosystem.fr

<iframe width="100%" height="1586" src="https://snippet.echosystem.fr?embed=5f0e078848690" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 02/11/2021

[HTML/JS] Copy boutton

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 140px;
  background-color: #555;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px;
  position: absolute;
  z-index: 1;
  bottom: 150%;
  left: 50%;
  margin-left: -75px;
  opacity: 0;
  transition: opacity 0.3s;
}

.tooltip .tooltiptext::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #555 transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}
</style>
</head>
<body>

<p>  Copy text</p>
<input type="text" value="Hello World" id="myInput">

<div class="tooltip">
<button onclick="myFunction()" onmouseout="outFunc()">
  <span class="tooltiptext" id="myTooltip">Copy to clipboard</span>
  Copy text
  </button>
</div>

 

<script>
function myFunction() {
  var copyText = document.getElementById("myInput");
  copyText.select();
  copyText.setSelectionRange(0, 99999);
  document.execCommand("copy");
  
  var tooltip = document.getElementById("myTooltip");
  tooltip.innerHTML = "Copied: " + copyText.value;
}

function outFunc() {
  var tooltip = document.getElementById("myTooltip");
  tooltip.innerHTML = "Copy to clipboard";
}
</script>

</body>
</html>

html js

https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_copy_clipboard2

<iframe width="100%" height="1568" src="https://snippet.echosystem.fr?embed=5efb6768b98c5" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 02/11/2021

[stylus] netatmo css

/* ==UserStyle==
@name           Netatmo - Dark theme
@namespace      USO Archive
@author         St3v32
@description    `Dark theme for netatmo security cameraValid on:https://my.netatmo.com/--------------------------------https://my.netatmo.com/app/securityorhttps://my.netatmo.com/app/camera`
@version        20200806.16.47
@license        CC0-1.0
@preprocessor   uso
==/UserStyle== */
@-moz-document url("https://my.netatmo.com/app/camera"), url("https://my.netatmo.com/app/security"), url-prefix("https://my.netatmo.com/"), url("https://my.netatmo.com/app/weather") {
/*  Large screen  */
.h-fullh {
    height: 100%;
    background-color: #222222;
    color: #308009;
}

/*  Body  theme  */
body {
    background-color: #222222;
    font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
    font-weight: normal;
    font-style: normal;
    line-height: 1.5;
    cursor: auto;
}

/* center */
.flex-center {
    color: #4fd70b;
    background-color: #222222;
}

.camera-app #home-view .home-wrapper {
    font-size: 16px;
    position: relative;
    width: 100%;
    color: #4fd70b;
    background-color: #222222;
}

.page-container {
    margin-top: 60px;
    height: calc(100% - 60px);
    overflow: auto;
    position: relative;
    color: #4fd70b;
    background-color: #222222;
}
#persons .person-list {
    height: 75%;
    background-color: #090808;
    border-radius: 0 0 5px 5px;
}

/* flech arrow camera right */
#timeline #timelineList .event .event-selectable.outdoor .presence-images .vignettes-wrapper .next {
    filter: invert(1);
}

.controlBar > .button:enabled:hover {
    fill: #48a0f7;
}

.controlBar > .button:enabled:hover:active {
    fill: #2d89e6;
}


/*  header menu black  */
.common-header .block-content.category a:hover p {
    color: #4078f8;
    font-size: 16px;
    font-family: ProximaNova-Semibold;
    padding: 5px 25px;
    border-radius: 2px;
}
.common-header .header-app .logo-wrapper .logo {
    filter: invert(1);
}
.common-header .header-app {
    background: #151515;
    border-bottom: 1px solid #87a662;
}
/* logo negatif */
.common-header .right-content {
    filter: invert(1);
}

/*  header camera name  */
.home-selector {
    z-index: 10;
    height: 60px;
    box-shadow: 0 0 203px 3px rgba(181, 185, 179, 0.24);
    color: #5f0;
    background-color: #222222;
}


/* cadre camera  */
#timeline #timelineList .event .event-selectable.active:hover {
    background-color: #7a7676;
}

#timeline #timelineList .event .event-selectable.active {
    background-color: #2d2b2b;
}

#timeline #timelineList .event .event-selectable:hover {
    background-color: #605e5e;
    color: white;
}


#timeline #timelineList .event .event-selectable.active .event-time span {
    color: #4fd70b;
    font-size: 22px;
}

#timeline #timelineList .event .day-event.fixed {
    background-color: #090808;
    position: absolute;
    top: 0;
    left: 0;
    border-top: none;
}
#timeline #timelineList .event .event-selectable.active .event-message span {
    color: #d7d9d5;
    font-family: ProximaNova-Light;
    font-size: 18px;
}
#timeline #timelineList .event .event-selectable .event-message span {
    color: #acaaaa;
    font-family: ProximaNova-Light;
    font-size: 13px;
}
#timeline #timelineList .event .event-selectable .event-time span {
    font-family: ProximaNova-Regular;
    font-size: 16px;
    color: #c8c7c7;
}

#timeline #timelineList .event .event-selectable.active .event-message span.liveevent {
    color: #d0021b;
    background-color: #2d2b2b;
    text-transform: uppercase;
    font-family: ProximaNova-Medium;
    font-size: 22px;
}

#timeline #timelineList .event .event-selectable .event-message span.liveevent {
    color: #d0021b;
    background-color: #2d2b2b00;
    text-transform: none;
    font-family: ProximaNova-Medium;
    font-size: 22px;
}
#timeline #timelineList .event .day-event .day-number {
    color: #44ec8e;
    margin: 0 10px;
}
#timeline #timelineList .event .day-event .day-name {
    color: #6bb142;
}

#timeline {
    height: 100%;
    position: relative;
   /*width: 50;*/
    padding-left: 15px;
    overflow: hidden;
    color: #4fd70b;
    background-color: #222222;
}

#timeline #timelineList {
    width: 100%;
    padding: 40px 0 0 0;
    position: relative;
    background-color: #090808;
}

#persons .person-mode-selector {
    background-color: #000;
    border-radius: 5px 5px 0 0;
    border-bottom: 1px solid #e7e7e7;
    height: 25%;
}
#persons .person-list .person-thumbnail-container span .person_last_seen {
    font-size: 12px;

    margin-right: auto;
    color: #8f958d;
}

#timeline #timelineList .event .event-selectable .event-image-wrapper .hide-line-first-event-of-day,
#timeline #timelineList .event .event-selectable .event-image-wrapper .hide-line-last-event-of-day {
    position: absolute;
    width: 100%;
    height: calc(50% + 15px);
    background-color: #090808;
}

/* info camera + option  */
.home-info p {
    font-family: ProximaNova-SemiBold;
    font-size: 18px;
    color: #72d03d;
    line-height: inherit;
}

.common-subheader .param .icon.settings-admins,
.icon.settings,
.icon.camerasettings {
    filter: invert(1);
}
}

.main-panel{
    background-color: #090808;
}
.flot-base{
    filter: invert(1);
}
#app-dashboard{
    filter: invert(1);
}

CSS netatmo stylus

https://my.netatmo.com/app/security

<iframe width="100%" height="4268" src="https://snippet.echosystem.fr?embed=5ea0068999df0" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 02/09/2021

[js] Date update with JS only

# Use this to update Year ( footer) with javascript , no php ;)


<script>document.write(new Date().getFullYear())</script>



# That will work in all browsers I've run across.
#    You can just call getFullYear directly on the newly-created Date, no need for a variable. new Date().getFullYear() may look a bit odd, but it's reliable: the new Date() part is done first, then the .getFullYear().
#    You can drop the type, because JavaScript is the default; this is even documented as part of the HTML5 specification, which is likely in this case to be writing up what browsers already do.
#    You can drop the semicolon at the end for one extra saved character, because JavaScript has "automatic semicolon insertion," a feature I normally despise and rail against, but in this specific use case it should be safe enough.

#It's important to note that this only works on browsers where JavaScript is enabled. Ideally, this would be better handled as an offline batch job (sed script on *nix, etc.) once a year, but if you want the JavaScript solution, I think that's as short as it gets. (Now I've gone and tempted fate.)


source : https://stackoverflow.com/posts/4562604/revisions

js

<iframe width="100%" height="470" src="https://snippet.echosystem.fr?embed=5db70f0c699a2" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 02/11/2021

[PHP] show_source() Function

#  PHP show_source() Function


<html> 
<body> 
<?php 
show_source("show_source.php"); 
?> 
</body> 
</html> 

php

<iframe width="100%" height="380" src="https://snippet.echosystem.fr?embed=5db084f26f5a0" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 02/11/2021

[CSS] Centrer image with text vertical

<div>
    <img src="https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.svg" style="vertical-align: middle;" width="100px"/>
    <span style="vertical-align: middle;">Here is some text.</span>
</div>

CSS html

<iframe width="100%" height="254" src="https://snippet.echosystem.fr?embed=5daf451ece633" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 22/10/2019

[BASH] updater-netdata.sh

#!/bin/bash
#
# Script Updater for netdata
#
#   - Dependencies: Wring package (NPM)
#
#  By Erreur32 - 2018
#


service=netdata
releasehub=https://github.com/netdata/netdata/releases

VERT="\\033[1;32m"
NORMAL="\\033[0;39m"
ROUGE="\\033[1;31m"
ROSE="\\033[1;35m"
BLEU="\\033[1;34m"
BLANC="\\033[0;02m"
BLANCLAIR="\\033[1;08m"
JAUNE="\\033[1;33m"
CYAN="\\033[1;36m"
NOC=$(tput sgr0)
NC=$(tput sgr0)


## Check if wring is installed
if [ -f "/usr/bin/wring" ] ||  [ -f "/usr/local/bin/wring" ]
     then
      echo -e "\n\e[34m - Wring package \e[0m>> founded.\e[0m\n"
     else
      echo -e "\n\e[92m - Install Wring with NPM \e[0m\n"
      npm install --global wring  && echo "Success install  Wring" || echo "failure to install Wring"
      echo -e "\n\e[34m - .\e[0m\n"
     fi

# need to check in other way...   /usr/sbin/netdata -V | cut -c"9-" |  cut -c "1-6"
VersionInstalled="$(/usr/sbin/netdata -v | cut -c"9-" |  cut -c "1-6")"
VersionAvailable="$(curl -s $releasehub | wring text - '.css-truncate-target' |  sed -n 5p)"

echo -e "$ROSE Checking $service version ... "
echo -e "$JAUNE Version installed = v$VersionInstalled"
echo -e "$JAUNE Version Available = $VersionAvailable"
echo  ""


if [ -z "$VersionInstalled" ]
then
   echo -e "$service is not installed - exit "
   exit
fi

if [[ "$VersionAvailable" = "v$VersionInstalled" ]]
then
    echo -e "$service  is already up-to-date (version $VersionInstalled) ... Bye! "
    exit
fi


echo -e "$VERT Start install New Updater from Netdata $NC"
if [ -f  "/opt/netdata-last-installer.sh" ]
  then
     rm /opt/netdata-last-installer.sh -f
     wget  https://my-netdata.io/kickstart.sh -O /opt/netdata-last-installer.sh --no-verbose  && echo -e "$CYAN Get success last installer " || echo "failure"
     chmod +x /opt/netdata-last-installer.sh
  else
     wget  https://my-netdata.io/kickstart.sh -O /opt/netdata-last-installer.sh --no-verbose   && echo -e "$CYAN Get success last installer " || echo "failure"
     chmod +x /opt/netdata-last-installer.sh
  fi
echo -e " $NC"
echo -e "$JAUNE Start Updating Netdata..."
/bin/bash /opt/netdata-last-installer.sh  && echo -e "  Updating Netdata Successfully!" || echo "failure"
echo ""
echo -e " $VERT   Update ✔   Netdata..."
echo -e " $NC"

bash shell

https://gist.github.com/Erreur32/64108b6fa940bb93654a205503b36f76

<iframe width="100%" height="1550" src="https://snippet.echosystem.fr?embed=5be81b20c9972" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 02/11/2021

Aide Crontab

  ┌────────── minute (0 - 59)
  │ ┌──────── hour (0 - 23)
  │ │ ┌────── day of month (1 - 31)
  │ │ │ ┌──── month (1 - 12)
  │ │ │ │ ┌── day of week (0 - 6 => Sunday - Saturday, or  1 - 7 => Monday - Sunday)
  │ │ │ │ │
  ↓ ↓ ↓ ↓ ↓
  * * * * *      command to be executed
         
         
  58 23 * * *    /sbin/iptables-save  > /etc/firewall.iptables-cron 2>&1

string         meaning
------         -------
@reboot        Run once, at startup.
@yearly        Run once a year, "0 0 1 1 *".
@annually      (same as @yearly)
@monthly       Run once a month, "0 0 1 * *".
@weekly        Run once a week, "0 0 * * 0".
@daily         Run once a day, "0 0 * * *".
@midnight      (same as @daily)
@hourly        Run once an hour, "0 * * * *".

#####

Hope it will help ;)


crontab shell

<iframe width="100%" height="686" src="https://snippet.echosystem.fr?embed=5bdf4d0790a8e" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 03/11/2021

update-plex.sh

#!/bin/bash

#####
#
# This Script will update Plex Media Server to the latest version for Ubuntu
#
# To automatically check & update plex, run "crontab -e" and add the following lines
#
# # Check for Plex Media Server Updates every day @6:00 am
# 0 6 * * * /root/update-plexmediaserver.sh
#
#  2018 - Original by Matthieu Guerry
#       - Customised by erreur32
###

# Check Current installed version and exit if latest is already installed
service=plex
VersionInstalled=$(dpkg -s plexmediaserver | grep -Po '(?<=Version\: )(\S+)')
if [[ -z $VersionInstalled ]]; then echo " Plex is not installed - exit "; exit; fi
VersionAvailable=$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=(\" version=\"))(\S+)(?=(\"))')
echo -e " Checking Plex version ... "
echo -e " Version installed = $VersionInstalled"
echo -e " Version Available = $VersionAvailable"

if [ $VersionAvailable = $VersionInstalled ]; then echo "Plex Media Server is already up-to-date (version $VersionInstalled) ... Bye! "; exit; fi

echo -e " Download new Version  $VersionAvailable"
# Download latest installation package to /tmp folder
curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=url=\")(\S+)(?=\")' | xargs wget -P /tmp/

if [[ -z $(ps -ef |grep ${service}) ]]
then
   print "Hum service down !?! , anyway Service will updating\n"
else
   print "Plex is running, service will stop before Update...\n"
fi
# Stop Plex Service
sudo service plexmediaserver stop
# Install latest version
sudo dpkg -i /tmp/$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=fileName=\")(\S+)(?=\")')


ps -ef | grep plex | grep -v grep
[ $?  -eq "0" ] && echo "Plex is running back :)" || echo "Plex is not running ... ;("

# Start Plex Service
echo -e " restart service Plex"
sudo service plexmediaserver start

# Remove installation package from /tmp folder
rm /tmp/plexmediaserver_*

plex shell

<iframe width="100%" height="1118" src="https://snippet.echosystem.fr?embed=5bdf3936ae288" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 02/11/2021

1234

Flux RSS de cette page


Echo Snippet 1.84 par Bronco - Page générée en 0.006 s