Outils pour utilisateurs

Outils du site


blog

Notes Syncthing

Voir :

Voir aussi :

  • rclone bisync
  • Ksync qui utilise Syncthing pour synchroniser les containers (containers ou k8s)
apt-get update
apt-get install syncthing
 
adduser --group --system syncthing --home /usr/local/var/lib/syncthing

Sur A

syncthing --device-id

Sur B

syncthing --device-id

Sur A

syncthing cli config devices add --device-id $DEVICE_ID_B

Sur B

syncthing cli config devices add --device-id $DEVICE_ID_A
#syncthing cli config folders $FOLDER_ID devices add --device-id $DEVICE_ID_B

Sur A

mkdir ~/DATA_SYNCALL
 
fid=$(uuidgen)
fid=${fid%%-*}
# syncthing cli config folders add --id $fid --label "DATA_SYNCALL" --path /data/syncall/
syncthing cli config folders add --id $fid --label "DATA_SYNCALL" --path ~/DATA_SYNCALL
 
syncthing cli config folders $fid devices add --device-id $DEVICE_ID_B
 
syncthing cli config folders list

Sur B

syncthing cli config folders list
#syncthing cli config devices $DEVICE_ID_A auto-accept-folders set true
 
syncthing cli show pending folders
##syncthing cli config folders add --label DATA_SYNCALL  devices add --device-id $DEVICE_ID_A
 
syncthing cli config folders $FOLDER_ID devices add --device-id $DEVICE_ID_A

Service

Service SystemD Lingering

Source : https://github.com/syncthing/syncthing/blob/main/etc/linux-systemd/user/syncthing.service

~/.config/systemd/user/syncthing.service

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization
Documentation=man:syncthing(1)
StartLimitIntervalSec=60
StartLimitBurst=4
 
[Service]
ExecStart=/usr/bin/syncthing serve --no-browser --no-restart --logflags=0
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
 
# Hardening
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true
 
# Elevated permissions to sync ownership (disabled by default),
# see https://docs.syncthing.net/advanced/folder-sync-ownership
#AmbientCapabilities=CAP_CHOWN CAP_FOWNER
 
[Install]
WantedBy=default.target

Autres

[ZUPOI] 13:18:34 INFO: TCP listener ([::]:22000) starting
2024/10/01 13:18:34 connection doesn't allow setting of receive buffer size. Not a *net.UDPConn?. See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details.
[ZUPOI] 13:18:34 INFO: QUIC listener ([::]:22000) starting

/etc/sysctl.d/80-net-core-xmem_max.conf

# Bump maximum receive buffer size to roughly 7.5 MB for Syncthing - as per
# https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size
net.core.rmem_max=7500000
net.core.wmem_max=7500000
 
#fs.inotify.max_user_watches=409600

Activer inotify

curl –s http://ipduserveur:port/rest/system | json_pp
{
"alloc": 32147752, # allocated memory, in use "cpuPercent": 0.669829340548344,
"extAnnounceOK": true, # true if we are registered with the global announce server, false on failure, absent if disabled "goroutines": 34,
"myID": "P56IOI7MZJNU2IQGDREYDM2MGTMGL3BXNPQ6W5BTBBZ4TJXZWICQ",
"sys": 66463976 # allocated memory, total
}

Source : https://www.it-connect.fr/installation-et-configuration-de-syncthing/

Dans la web UI (127.0.0.1:8384) → menu Actions → Configuration → Connexions → décocher “Découverte globale” et cocher “Découverte locale”

Ensuite, pour chaque appareil, vérifier dans → Gérer → Avancé → Adresses = “dynamic”

~/.config/syncthing/config.xml and find relaysEnabled. Set its value false.

<!-- Changer à false -->
<relaysEnabled>false</relaysEnabled>
<globalAnnounceEnabled>false</globalAnnounceEnabled>
<crashReportingEnabled>false</crashReportingEnabled>
<crashReportingEnabled>false</crashReportingEnabled>
<startBrowser>false</startBrowser>
<natEnabled>false</natEnabled>
 
<!-- Supprimer -->
<urURL>https://data.syncthing.net/newdata</urURL>
<releasesURL>https://upgrades.syncthing.net/meta.json</releasesURL>
<crashReportingURL>https://crash.syncthing.net/newcrash</crashReportingURL>
 
<!-- Changer partout "10" à "1" -->
fsWatcherDelayS="1"
 
<!-- Changer gui enabled à "false" -->
<gui enabled="false" tls="false" debugging="false">
env GOMAXPROCS=2 syncthing -no-browser
find /path/to/folder/to/force/sync -type f -print0 | xargs -0 -n1 touch

Ignore

.stignore

.git/
2025/03/24 15:06

Notes swap mémoire

Voir :

Voir aussi :

systemctl --type swap
cat /proc/swaps
cat /proc/vmstat
echo 0 > /proc/sys/vm/swappiness
# cat /proc/sys/vm/vfs_cache_pressure
# sysctl -w vm.vfs_cache_pressure=50
# Allocate storage and restrict access
fallocate --length 4GiB /swapfile
chmod 600 /swapfile
 
# Format the swap space
mkswap /swapfile
 
# Activate the swap space for paging
swapon /swapfile

Analyse consommation

Consommation de la SWAP par utilisateur

smem -u -s swap

Consommation de la SWAP par process

smem -s swap

ou

echo -e "SWAP_KB\tPPID\tPID\tEXE"
 
for S_FILE in /proc/[0-9]*/ ; 
do 
  S_PPID="$(awk '/^PPid:/ { print $2}' ${S_FILE}/status)" ;
  S_PID="$(echo ${S_FILE}/status | cut -d'/' -f3)" ;  
  S_EXE="$(readlink $S_FILE/exe)" ; 
  S_SWAPKB="$(awk '/VmSwap/ { print $2}' ${S_FILE}/status)" ; 
  [ ! -z $S_SWAPKB ] && echo -e "$S_SWAPKB\t${S_PPID}\t${S_PID}\t${S_EXE}" ; 
done | sort -n

ou

for file in /proc/*/status ; do awk '/Tgid|VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | grep kB | sort -k 3 -n

dphys-swapfile

dphys-swapfile swapoff 

Recommandations SWAP

Prereq Oracle
RAM Swap Space
Between 1 GB and 2 GB 1.5 times the size of the RAM
Between 2 GB and 16 GB Equal to the size of the RAM
More than 16 GB 16GB
RAM Swap Space
Between 8 GB and 16 GB Equal to the size of the RAM
More than 16 GB 16GB
Recommandations RedHat

Source : https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_storage_devices/getting-started-with-swap_managing-storage-devices

Amount of RAM in the system Recommended swap space Recommended swap space if allowing for hibernation
⩽ 2 GB 2 times the amount of RAM 3 times the amount of RAM
> 2 GB – 8 GB Equal to the amount of RAM 2 times the amount of RAM
> 8 GB – 64 GB At least 4 GB 1.5 times the amount of RAM
> 64 GB At least 4 GB Hibernation not recommended

Utilisation de SWAP alors que la RAM n'est que partiellement utilisé

En anglais sur les forums :

  • Why is Swap used when there is RAM available?
  • Swap being used when RAM is almost half free
  • Why linux has enough memory but swap is used
  • Why is Linux not using RAM but only Swap ?
  • System suddenly using all available swap, but plenty of free memory
  • High swap usage in spite of low RAM usage

Voir :

Voir aussi :

  • Shared Memory
  • zramctl
cat /proc/meminfo
 
cat /proc/sys/vm/swappiness
cat /proc/sys/vm/dirty_ratio
cat /proc/sys/vm/dirty_background_ratio
cat /proc/sys/vm/overcommit_ratio

Voir VmSwap ou VmSize

ps -eo pmem,pcpu,rss,vsize,args --sort rss
grep VmSwap /proc/*/status | sort -n -r --key=2.1 | head -5
grep Vm /proc/3593/status

Tests SWAP

Utiliser 2 giga de mémoire

stress --vm 1 --vm-bytes 2G --timeout 30

Vérif

journalctl -k | grep -i "out of memory"

Autres test

#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
 
int main()
{
    char *p;
    size_t s = 100 * 1024 * 1024;
 
    for (;;)
    {
        p = malloc(s);
        bzero(p, s);
        sleep(1);
    }
 
    /* unreached */
}

Source : https://bbs.archlinux.org/viewtopic.php?id=212750

2025/03/24 15:06

Notes SVN Subversion

Client

Voir : Svn erreur svn cannot negotiate authentication mechanism

Voir aussi : Git

svn status
svn revert plop/foo
svn rm plop/
svn commit -m "* message"

“svn unadd”

svn revert --recursive folder_name

Mode non interactif

svn --non-interactive --trust-server-cert --username toto --password 'P@ssw0rd' --no-auth-cache checkout https://srv-svn/projet

Changer les droits posix. Equivalent à chmod +x

svn propset svn:executable ON plop.sh

Revert all

svn revert -R .

Undo commit

svn update
 
# Undo range
svn merge -r UPREV:LOWREV .
 
# Undo single revision
svn merge -c -REV .

Proxy

~/.subversion/servers

[global]
# http-proxy-exceptions = *.exception.com, www.internal-site.org
# http-proxy-host = defaultproxy.whatever.com
# http-proxy-port = 7000
# http-proxy-username = defaultusername
# http-proxy-password = defaultpassword
 
http-proxy-host = 192.168.56.1
http-proxy-port = 3128

Ou voir /etc/subversion/servers

SVN diff avec Vimdiff

~/.local/bin/svnvimdiff.sh

#!/bin/sh
 
/usr/bin/vimdiff ${6} ${7}
chmod +x ~/.local/bin/svnvimdiff.sh

Utilisation

svn diff  --diff-cmd ~/.local/bin/svnvimdiff.sh README.md 

Source : https://stackoverflow.com/questions/7866286/how-to-view-svn-diff-in-vimdiff-style-in-svn

Pb

Pb - svn demande le mot de passe à chaque commande - linux svn keeps asking for password
Solution 1

~/.subversion/config ou /etc/subversion/config

[auth]
password-stores =

Le mot de passe est enregistré en clair ici : ~/.subversion/auth/svn.simple/

Ou sinon

~/.bashrc

# gpg-agent is used by svn (svn keep asking for password if GPG_TTY is not set)
GPG_TTY=$(tty)
export GPG_TTY
Solution 2

Utiliser l'option --no-auth-cache

svn --non-interactive --trust-server-cert --username toto --password 'P@ssw0rd' --no-auth-cache checkout https://srv-svn/projet

Serveur

Install serveur Subversion

Voir : https://doc.ubuntu-fr.org/subversion

Voir aussi :

Source : https://stackoverflow.com/questions/4797242/install-subversion-on-ubuntu-with-nginx-not-apache

Si pas besion de HTTP

svnadmin create /path/to/repository

Puis Then you can check out local copies directly:

svn co /path/to/repository /path/to/my/checkout

Ou over ssh:

svn co svn+ssh://server/path/to/repository
Notes install avec Apache

Source : http://hikage.developpez.com/linux/tutoriels/subversion/?page=page_2

apt-get install subversion libapache2-mod-svn libapache2-svn apache2 apache2-utils #subversion-tools
a2enmod dav_svn
mkdir -p /var/subversion/depot/
svnadmin create /var/subversion/depot/projet1/

/etc/apache2/mods-available/dav_svn.conf

<Location /svn>
        DAV svn
        Require valid-user
        SVNParentPath /var/subversion/depot/
        AuthType Basic
        AuthName "Mon dépôt"
        AuthUserFile /var/subversion/conf/htpasswd
        AuthzSVNAccessFile /var/subversion/conf/access
</Location>
mkdir /var/subversion/conf/
htpasswd -c /var/subversion/conf/htpasswd jibe
htpasswd /var/subversion/conf/htpasswd utilisateur2

/var/subversion/conf/access

[groups]
devfoo  = jean, utilisateur2
 
[projet1:/]
@devfoo = rw
 
[projetprivejean:/]
jean = rw
* = r
 
[projetprivejean:/documentation/utilisateur]
auteurdoc = rw
chown www-data: -R /var/subversion/
mkdir /tmp/plop
cd /tmp/plop
mkdir trunk tags branches
svn import file:///var/subversion/depot/projet1 -m 'Initial project directories'
Notes install sans Apache
cd /var/
mkdir svn
svnadmin create /var/svn/projet1
#chmod o-r /var/svn/projet1/conf/authz
#chmod o-r /var/svn/projet1/conf/passwd
 
cd /var/svn/projet1
mkdir trunk tags branches
#svn import /var/svn/projet1/tags  file:///var/svn/projet1/ -m 'Initial project directories'

/var/svn/projet1/conf/svnserve.conf

[general]
anon-access = none
password-db = passwd
realm = Projet 1

/var/svn/projet1/conf/passwd

[users]
jibero = jibe
jiberw = jibe

/var/svn/projet1/conf/authz

[/plop]
jibe = rw
sudo addgroup svn --system
sudo adduser svn --system --home /var/svn --no-create-home --ingroup svn
sudo chown -R svn: /var/svn
 
su - svn  -s /bin/bash -c 'svnserve -d --foreground -T -r /var/svn/projet1 --listen-port=3690 --listen-host=localhost'
2025/03/24 15:06

Notes Supervisor

Voir Notes PID1 conteneurs

[program:plop]
directory=/home/plop/front-website/
command=/home/plop/front-website/front-website -bind=":8081"
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/var/log/plop/stdout.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/plop/stderr.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
user = plop
[program:gogs]
directory=/home/git/gogs/
command=/home/git/gogs/gogs web
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/var/log/gogs/stdout.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/gogs/stderr.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
environment = HOME="/home/git", USER="git"
user = git
/usr/bin/supervisorctl -c /opt/etc/supervisord.conf

Si modif config

reread
update

Relacement du service supervisor

reload

Docker no logs

[supervisord]
nodaemon=true
logfile=/dev/null
logfile_maxbytes=0
2025/03/24 15:06

Changer le mot de passe root via script sur RedHat / CentOS

echo 'root:P@ssw0rd' | chpasswd
#echo "utilisateur:P@ssw0rd|chpasswd -cSHA512
echo "password" | passwd hacluster --stdin

Attention : ce n'est pas sécurisé.

Autres

read -s PASS
 
# Ou
set +o history
export PASS=P@ssw0rd
set -o history
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki