Outils pour utilisateurs

Outils du site


blog

Notes TCL

Voir :

  • tclx (TclX, or Extended Tcl, provides access to the features exposed by API of POSIX systems such Unix)

Voir aussi :

  • LUA

tclsh

Equivalent de bash -c

runner.tcl

#!/usr/bin/tclsh
 
eval $argv
tclsh runner.tcl puts hello

FIXME

2025/03/24 15:06

Notes Tahoe-LAFS

https://www.digitalocean.com/community/tutorials/tahoe-lafs

Brouillon. (source http://killyourtv.i2p/tahoe-lafs/running/)

If you're not using a multi-introducer capable Tahoe installation, most are using killyourtv's introducer to connect to the grid so that would be a good choice to use as a primary introducer. Updating your Tahoe-LAFS installation is recommended. If you're using the multi-introducer build, copy and paste the following into ~/.tahoe/introducers:

apt-get install tahoe-lafs
tahoe --version
Warning: dependency 'cryptography' (version '0.6.1') found by pkg_resources not found by import.
Warning: dependency 'six' (version '1.8.0') found by pkg_resources not found by import.
Warning: dependency 'cffi' (version '0.8.6') found by pkg_resources not found by import.
Warning: dependency 'pycparser' (version '2.10') found by pkg_resources not found by import.

For debugging purposes, the PYTHONPATH was
  None
install_requires was
  ['setuptools >= 0.6c6', 'zfec >= 1.1.0', 'simplejson >= 1.4', 'zope.interface == 3.6.0, == 3.6.1, == 3.6.2, >= 3.6.5', 'Twisted >= 11.0.0', 'foolscap >= 0.6.3', 'pyOpenSSL', 'Nevow >= 0.6.0', 'pycrypto == 2.1.0, == 2.3, >= 2.4.1', 'pyasn1 >= 0.0.8a', 'mock >= 0.8.0', 'pycryptopp >= 0.6.0']
sys.path after importing pkg_resources was
  /usr/bin:
  /usr/lib/python2.7:
  /usr/lib/python2.7/plat-x86_64-linux-gnu:
  /usr/lib/python2.7/lib-tk:
  /usr/lib/python2.7/lib-old:
  /usr/lib/python2.7/lib-dynload:
  /usr/local/lib/python2.7/dist-packages:
  /usr/lib/python2.7/dist-packages:
  /usr/lib/pymodules/python2.7

Voilà ce qui se passe quand on install des paquets de Debian Stretch sur Debian Jessie. C'est moche. Vive les virtualenv

Activer les dêpots de Debian Stretch

apt-get install tahoe-lafs python-cryptography python-pyasn1  python-cffi python-ply python-pycparser python-numpy

Autre solution

virtualenv tahoenv
cd tahoenv
source bin/activate
pip install --upgrade allmydata-tahoe
tahoe create-node
Node created in '/home/exploit/.tahoe'
 Please set [client]introducer.furl= in tahoe.cfg!
 The node cannot connect to a grid without it.
 Please set [node]nickname= in tahoe.cfg

Client node

A client node is used to communicate with storage nodes in order to store and retrieve files on the grid. There is a web interface (default on http://127.0.0.1:3456/) and a command line interface (via tahoe) for accessing this data. Other interfaces are available, see the Tahoe-LAFS site for details.

tahoe --version

tahoe create-client

Specify a nickname for your node. This is shown to all nodes in the grid so choose the nickname carefully. Edit the configuration file ~/.tahoe/tahoe.cfg. Modify the following options, the other values should be left at the defaults for now:

[node] nickname = yourclientnodename web.port = tcp:3456:interface=127.0.0.1 http_proxy = 127.0.0.1:4444 tub.location =

~/.tahoe/tahoe.cfg

uncomment tub.location otherwise your (at worse external!) IP will be leaked to introducers: In client section remove None word in introducer.furl,

Uncomment tub.location but leave it empty. This will prevent your other interfaces besides 127.0.0.1 from being broadcast to the introducer. /!\ WARNING: Make sure that you do this to avoid leaking your IP address! /!\

[node] nickname = YourRandomNickname web.port = tcp:3456:interface=127.0.0.1 web.static = public_html http_proxy = 127.0.0.1:4444

**IMPORTANT**

You NEED to configure tub.location when running

an I2P-enabled Tahoe-LAFS node. Otherwise your IP

can be leaked to the introducers!

Read the docs and/or come to #tahoe-lafs on Irc2P for assistence.

#tub.port = tub.location = #log_gatherer.furl = #timeout.keepalive = #timeout.disconnect = #ssh.port = 8022 #ssh.authorized_keys_file = ~/.ssh/authorized_keys

[client]

Which services should this client connect to?

introducer.furl = helper.furl = #key_generator.furl = #stats_gatherer.furl =

Create introducers file (without .txt extension) and paste the list of introducers from http://killyourtv.i2p/tahoe-lafs/introducers/

Upload

tahoe create-alias YOURALIAS

Upload your website into grid using tahoe cp command:

tahoe cp -r -v “C:\pathtoyourdeepsite” YOURALIAS

This is very time consuming process, uploading a single 50MB files could be faster than uploading 150 files of 5MB total, so consider for example converting all small images into base64 and embedding them into html file.

After uploading, check if all files are uploaded:

tahoe ls YOURALIAS

Type

tahoe list-aliases

or open .tahoe\private\aliases file to get your private keys, and go into website: http://127.0.0.1:3456/uri/URI:DIR2:<yourprivatekey>.

Click More info on this directory and copy your public key from Directory readcap, so your website address is: http://127.0.0.1:3456/uri/URI:DIR2-RO:<yourpublickey>/index.htm.

Never share address without URI:DIR2-RO (read only) otherwise others can vandalize/delete your site! Older files will be deleted from the network (grid). To prevent this, run the following command from time to time (once per 2 months):

tahoe deep-check -v --repair --add-lease YOURALIAS

Introducer

Setting up and running your own introducer on I2P involves a few simple steps. 
The first of these steps is to create the introducer node:

$ tahoe create-introducer ~/.tahoe/introducer

The introducer can exist anywhere on your filesystem. If you don't want it to be contained within your ~/.tahoe directory, simply specify a different directory.

Next, edit ~/.tahoe/introducer/tahoe.cfg. Fill out the web.port. In this example we'll use 3460:

[node]
web.port = tcp:3460:interface=127.0.0.1
web.static = public_html

Start your introducer:

$ tahoe start ~/.tahoe/introducer

$ cat introducer.port
17337


Choose Type: Standard (don't pick HTTP; it won't work). Point it to the port listed in introducer.port (in the example above, 17337). 
Start the server tunnel and take note of the Base32 destination. Edit ~/.tahoe/introducer/tahoe.cfg once more and set the tub.location to the introducer's Base32 destination. Restart your introducer node once more.

$ tahoe restart ~/.tahoe/introducer

At this point you have an introducer running and a tunnel pointing to it so it can be used on I2P. Of course, no one will be able to use your introducer without its existence being known. You will find the introducer.furl to give to others in the file ~/.tahoe/introducer/private/introducer.furl

$ cat ~/.tahoe/introducer/private/introducer.furl
pb://c6w5ernw7y7rp3uwmdyu5clujyt2y4m4@w2zrwz5gplkkufix7cb4gmxfbrkwg2abnsgk62bm5iifzlahe7kq.b32.i2p/introducer
Introducers on Tahoe-LAFS define the grid and their addresses should be published to everyone who wishes to connect to this grid. The example below points to a test introducer operated by KillYourTV. To use KYTV's introducer, add the following introducer.furl to tahoe.cfg.

[client]
introducer.furl = pb://c6w5ernw7y7rp3uwmdyu5clujyt2y4m4@w2zrwz5gplkkufix7cb4gmxfbrkwg2abnsgk62bm5iifzlahe7kq.b32.i2p/introducer

Add each introducer that you want to use to ~/.tahoe/introducers -- one per line! For example, I currently have

$ cat ~/.tahoe/introducers
pb://c6w5ernw7y7rp3uwmdyu5clujyt2y4m4@w2zrwz5gplkkufix7cb4gmxfbrkwg2abnsgk62bm5iifzlahe7kq.b32.i2p/introducer
pb://exupps5kk3amc5iq4q6f5ahggkm4s5fl@oj7cffq5fnk46iw3i3h2sdgncxrqbxm7wh6i4h2cbpmqsydygkcq.b32.i2p/introducer
pb://md2tltfmdjvzptg4mznha5zktaxatpmz@5nrsgknvztikjxnpvidlokquojjlsudf7xlnrnyobj7e7trdmuta.b32.i2p/introducer
pb://fmcbgy7zd6ubrbphilmrlocvb7f327z5@gdr3tt5uewgnm7r7xn54k2qikf2kuwwegjjsnkz44pjticcacsua.b32.i2p/introducer
pb://tq7rx35yopkvodmsxkqra4qqkbho3yaa@6ga2r2h2fyq6tzcyh6bf3hpio3i7r4edadbq7l4wnh4y62taj6ia.b32.i2p/introducer
pb://cys5w43lvx3oi5lbgk6liet6rbguekuo@sagljtwlctcoktizkmyv3nyjsuygty6tpkn5riwxlruh3f2oze2q.b32.i2p/introducer
pb://r3bs6joub24gtsofe7ohnnjcnwfmo2jy@qaihdh5z7osn7tc3326ahv3z46badiuaulff43wchmap7skg7euq.b32.i2p/42mrbm7zxmjemz6hzejo3i7aunx4eoun

You will need to restart your tahoe node after editing ~/.tahoe/introducers with tahoe restart. Any existing introducer.furl entries in tahoe.cfg will be automatically copied to ~/.tahoe/introducers.

Node Operation

To start your node as a daemon:

$ tahoe start

You can now access your node via the web interface at http://127.0.0.1:3456.

To stop your node if running as daemon:

$ tahoe stop

Storage node

~/.tahoe/tahoe.cfg

[node] tub.port = tcp:3459:interface=127.0.0.1 tub.location = n6k7tu37diq4obmcmv3f144oxxxnehp6njz5lwu4hllp5gp6hbga.b32.i2p

[storage] enabled = true

Optionally you may define how much disk space is reserved with reserved_space:

reserved_space = 5GB

2025/03/24 15:06

Notes SystemD

Voir :

Hardening Security focused systemd configuration

Lister les services

systemctl list-unit-files
systemctl list-units

Lister les services inactifs

systemctl list-units -all --state=inactive

Lister les services KO

systemctl -a | grep dead

Lister les services actifs

# SystemD
systemctl list-units --type service --state active
 
# Avant SystemD
chkconfig --list | grep -E '[1-5]:on'

Savoir si le service est activé ou désactivé

systemctl is-active httpd
systemctl is-enabled httpd

Relire la conf

systemctl daemon-reload

Les différents types de services

Runlevel et Target

Runlevel Target
0 poweroff.target
1 rescue.target
2, 3, 4 multi-user.target
5 graphical.target
6 reboot.target

Contrôler des services (Units) SystemD distants avec Hirte

Debug

systemctl show --property=Environment docker

Autres

If you don't like systemctl's auto-paging feature

export SYSTEMD_PAGER=
Logs entre deux date
journalctl --since "2019-10-16 06:00" --until "2019-10-16 10:00" 
Disable systemd redirection
export _SYSTEMCTL_SKIP_REDIRECT=1
tmpfile
[Service]
PrivateTmp=true

man -k tmpfiles

/etc/tmpfiles.d

/etc/tmpfiles.d/python.conf

x   /tmp/pymp-*
reboot
systemctl reboot
Lang Locale

Voir Notes langue lang locale - SystemD

#timedatectl list-timezones
timedatectl set-timezone Europe/Paris

Pb

RemoveIPC - Quand Poettering fait des siennes

Problème si compte UID > 1000 à cause de RemoveIPC

https://linuxfr.org/users/neologix/journaux/systemd-attention-a-removeipc

RemoveIPC Directive \ A new option called RemoveIPC was introduced in RHEL 7.2 through Systemd v219. When set to yes, this option forces a cleanup of all allocated inter-process communication (IPC) resources linked to a user leaving his last session. If a daemon is running as a user with a uid number >=1000, it may crash.

This option should always be set to no by default but, due to the logic of package upgrade, it is highly advisable to set RemoveIPC=no in the /etc/systemd/logind.conf file followed by # systemctl restart systemd-logind (source).

Source : https://www.certdepot.net/rhel7-changes-between-versions/

2025/03/24 15:06

Notes Systemd udev

Source https://askubuntu.com/questions/25071/how-to-run-a-script-when-a-specific-flash-drive-is-mounted

Voir :

Exemples :

lsusb

0a81:0101

/etc/udev/rules.d/100-mount-videos.rules

ACTION=="add", ATTRS{idVendor}=="0a81", ATTRS{idProduct}=="0101", RUN+="/home/your_username/bin/mount_videos.sh"

Exemple :

lsusb |grep -i touch
Bus 001 Device 009: ID 04e7:00c0 Elo TouchSystems

/etc/udev/rules.d/100-touchscreen-calibr.rules

ACTION=="add", ATTRS{idVendor}=="04e7", ATTRS{idProduct}=="00c0", RUN+="/bin/bash -c 'echo /usr/local/bin/touchscreencfg.sh | at now'"

Je ruse en uilisant at car l'appel directe au script ne fonctionne pas ( le xinput list ne fionctione pas)

/usr/local/bin/touchscreencfg.sh

#! /bin/bash
 
export DISPLAY=:0
 
NAME=$(xinput list  --name-only | grep -i touch | grep -iv ' pen')
ID=$(xinput list --id-only "$NAME")
SCREEN=$(xrandr 2>&1 | grep ' connected primary' | awk '{print $1}')
/usr/bin/xinput --map-to-output $ID $SCREEN
( sleep 5 ; /usr/bin/xinput --map-to-output $ID $SCREEN ) &

Pb

Pb 1
Solution

Utiliser at

2025/03/24 15:06

Notes sysstat sar

Install

apt-get update
apt-get install sysstat

/etc/default/sysstat

ENABLED="true"
# service sysstat restart
Starting the system activity data collector: sadc.

Utilisation

$ dpkg -L sysstat | grep 'bin/'
/usr/bin/nfsiostat
/usr/bin/pidstat
/usr/bin/sadf
/usr/bin/iostat
/usr/bin/mpstat
/usr/bin/sar.sysstat
/usr/bin/cifsiostat

Report CPU utilization

sar -u ALL

Report per-processor CPU utilization

sar -P ALL

Display all CPU utilization per 2 seconds 3 times

mpstat -P ALL 2 3
 
# mpstat -A 1

Report memory utilization

sar -r ALL

Report swap space utilization

sar -S

Report hugepages utilization

sar -H

Report paging statistics

sar -B

Report swapping statistics

sar -W

Report I/O and transfer rate statistics

sar -b

Report block device activity

sar -d

Report process creation and system switching activity

sar -w

Report queue length and load averages

sar -q

Display I/O disk with Mega bytes per 2 seconds

iostat -mx -d 2 

Report network utilization

sar -n ALL

Display I/O and network per 2 seconds 5 times

sar -b -n DEV 2 5

Display data in human readable way

sar -r -h

Display memory utilization of specific process per a second 3 times

pidstat -r -p 21090 1 3 

Charge sur une période donnée

sar -q -f /var/log/sa/sa27 -s 16:00:00 -e 17:00:00
sar -A -f /var/log/sa/sa27 -s 16:00:00 -e 17:00:00

Un peu de couleurs

env S_COLORS=always sar -A | less -R -S
env S_COLORS=always sar -n DEV | grep --color=never eth0

Voir aussi :

  • dircolors
Autres

Réseaux

sar -n ALL
sar -n DEV
sar -n TCP
sar -n ETCP
sar -n IP
sar -n EIP

Disques

iostat -p -x

Configuration

Timer
# systemctl edit --full sysstat-collect.timer
 
systemctl cat sysstat-collect.timer

/usr/lib/systemd/system/sysstat-collect.timer

# /usr/lib/systemd/system/sysstat-collect.timer
# (C) 2014 Tomasz Torcz <tomek@pipebreaker.pl>
#
# sysstat-11.7.3 systemd unit file:
#        Activates activity collector every 10 minutes
 
[Unit]
Description=Run system activity accounting tool every 10 minutes
 
[Timer]
OnCalendar=*:00/10
 
[Install]
WantedBy=sysstat.service
systemctl edit sysstat-collect.timer

/etc/systemd/system/sysstat-collect.timer.d/override.conf

[Unit]
Description=Run system activity accounting tool every 5 minutes
 
[Timer]
OnCalendar=
OnCalendar=*:5/5

Pb

# sar -n TCP
Requested activities not available in file /var/log/sa/sa31

/etc/sysconfig/sysstat

# Parameters for the system activity data collector (see sadc(8) manual page)
# which are used for the generation of log files.
# By default contains the `-S DISK' option responsible for generating disk
# statisitcs. Use `-S XALL' to collect all available statistics.
SADC_OPTIONS="-S XALL"

Important note: The activities (including optional ones) saved in an existing data file prevail over those selected with option -S. As a consequence, appending data to an existing data file will result in option -S being ignored.

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