Outils pour utilisateurs

Outils du site


blog

Notes Lazarus

Voir :

Voir aussi :

  • Pascal
  • Delphi Community Edition

Exemple de projet :

Installation

apt-get install lazarus
 
apt-file search /usr/share/fpcsrc/ |awk '{print $1}' |sort -u
apt-get install fpc-source-3.2.2
 
apt-cache search fppkg
apt-get install fp-units-misc

Configuration

Juste après le premier lancement : \ “Restore Fppkg configuration” \ /usr/lib/x86_64-linux-gnu/fpc

Tools - Options… - Editor - Display - Colors \ Forground : Silver \ Background : Black

Compilation

lazbuild --ws=qt6 project1.lpi

Fichiers utilisées :

  • project1.lpi
  • project1.ico
  • project1.lpr
  • unit1.pas
Notes crosscompilation

/usr/share/doc/fp-compiler/3.2.2/wince/testemu/win32-i386-win32-build.cmd

rem windres --preprocessor fprcp -v -i my.rc -o my.res
fpc -va  OPT="-gl -Xs -WC" -Twin32 -Pi386 -FE.\exe\ wcetemu.pp >i386-win32.log
pause
Error: ppc386 can't be executed, error message: Failed to execute "ppc386", error code: 127
# /usr/lib/i386-linux-gnu/fpc/3.2.2/ppc386
apt-get install fp-compiler-3.2.2:i386

Langages Pascal

2025/03/24 15:06

Notes langue lang locale Temps timezone TZ

SystemD

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

Avant SystemD

echo "Europe/Helsinki" > /etc/timezone
 
#dpkg-reconfigure tzdata
dpkg-reconfigure --frontend noninteractive tzdata
Debian / Ubuntu

/etc/locale.gen

fr_FR.UTF-8 UTF-8
export LANG=fr_FR.UTF-8 
export LANGUAGE=fr_FR:fr
export LC_ALL=fr_FR.UTF-8
# LC_ALL=C.UTF-8
 
locale-gen
dpkg-reconfigure locales
update-locale LANG=fr_FR.UTF-8

Ou

locale-gen fr_FR.UTF-8 UTF-8 && dpkg-reconfigure locales

/etc/default/keyboard

# KEYBOARD CONFIGURATION FILE
 
# Consult the keyboard(5) manual page.
 
XKBMODEL="pc105"
XKBLAYOUT="fr"
XKBVARIANT="latin9"
XKBOPTIONS=""
 
BACKSPACE="guess"
sudu setupcon
Redhat / CentOS

Source :

Fichier de conf

/etc/locale.conf

LANG=en_US.utf8

Afficher les infos

localectl status

Langue

localectl list-locales
#localedef set-locale LANG=en_US.utf8
localedef set-locale LANG=fr_FR.utf8

Clavier\ Voir Comment mater le clavier sous Linux?

localectl list-keymaps
#localectl set-keymap us
localectl set-keymap fr
#localectl set-x11-keymap fr

Pb

Pb 1
# loadkeys fr
cannot open file fr

Solution

apt-get install kbd console-data
Pb 2

Debian 9

localectl set-keymap fr

Après reboot, lightdm est bien en français par défaut (même si c'est en_US.utf8 qui est affiché)

Par contre la console TTY est toujours en querty.

Il faut à chaque fois faire

loadkeys fr
 
# idem pour X11
setxkbmap fr

loadkeys persistent, loadkeys permanent

Il est possible d'ajouter cette commande dans le bashrc, mais existe-il un autre moyen de rendre pour loadkeys persistent

Solution :

apt-get install console-setup

Si cela ne marche toujours pas

apt-get install console-data
apt-get install console-setup
apt-get install keyboard-configuration
 
dpkg-reconfigure console-data
dpkg-reconfigure console-setup
dpkg-reconfigure keyboard-configuration
 
reboot

Debian - set locale

WARNING! Your environment specifies an invalid locale.
 The unknown environment variables are:
   LC_CTYPE=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_ALL=
 This can affect your user experience significantly, including the
 ability to manage packages. You may install the locales by running:

   sudo apt-get install language-pack-en
     or
   sudo locale-gen en_US.UTF-8

To see all available language packs, run:
   apt-cache search "^language-pack-[a-z][a-z]$"
To disable this message for all users, run:
   sudo touch /var/lib/cloud/instance/locale-check.skip

Autres

a

/etc/initramfs-tools/initramfs.conf

#KEYMAP=n
KEYMAP=y
update-initramfs -u -k all

b

GRUB_CMDLINE_LINUX=”rd.lvm.lv=centos/swap vconsole.keymap=us crashkernel=auto rd.lvm.lv=centos/root vconsole.font=latarcyrheb-sun16 rhgb quiet net.ifnames=0 biosdevname=0″
grub2-mkconfig -o /boot/grub2/grub.cfg

autres

locale-gen fr_FR.UTF-8 UTF-8

Ce qui revient à créer

/etc/locale.gen

# This file lists locales that you wish to have built. You can find a list
# of valid supported locales at /usr/share/i18n/SUPPORTED, and you can add
# user defined locales to /usr/local/share/i18n/SUPPORTED. If you change
# this file, you need to rerun locale-gen.

en_US.UTF-8 UTF-8
fr_FR.UTF-8 UTF-8
update-locale LANG=fr_FR.UTF-8

Ce qui revient à

/etc/default/locale

#  File generated by update-locale
LANG=fr_FR.UTF-8
dpkg-reconfigure -f noninteractive locales
env DEBIAN_FRONTEND=noninteractive apt-get install console-setup
2025/03/24 15:06

Notes langage C

Voir :

Voir aussi :

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
 
int main(int argc, char **argv)
{
    int i, size;
 
 
#define SEPARATEUR " "
 
    char *cmdline;
 
    for (i=1; i < argc; i++)
       size +=  strlen(SEPARATEUR) + strlen(argv[i]);
 
    cmdline = malloc(size);
 
    if (cmdline ) {
        memset(cmdline, 0, size);
        for (i=1; i < argc; i++) {
            strcat(cmdline, argv[i]);
            strcat(cmdline, SEPARATEUR);
        }
    }
 
    printf("-- %s --", cmdline);
 
    system(cmdline);
 
}

Erreur - implicit declaration of function

$ gcc plop.c 
plop.c: In function ‘main’:
plop.c:29:5: error: implicit declaration of function ‘system’ [-Wimplicit-function-declaration]
   29 |     system(cmdline);
      |     ^~~~~~

Solution : Ajouter #include <stdlib.h>

Compilation

gcc plop.c
zig cc plop.c

Surcharger un symbole

Voir : https://stackoverflow.com/questions/2146059/limiting-syscall-access-for-a-linux-application

Is the application linked statically?

If not, you may override some symbols, for example, let's redefine socket:

int socket(int domain, int type, int protocol)
{
        write(1,"Error\n",6);
        return -1;
}

Then build a shared library:

gcc -fPIC -shared test.c -o libtest.so

Let's run:

nc -l -p 6000

Ok.

And now:

$ LD_PRELOAD=./libtest.so nc -l -p 6000
Error
Can't get socket

What happens when you run with variable LD_PRELOAD=./libtest.so? It overrides with symbols defined in libtest.so over those defined in the C library.

Sécurité

$ man gets

...
(DEPRECATED)
Never use this function.

BUGS
       Never  use  gets().   Because  it is impossible to tell without knowing the data in advance how many characters gets() will read, and because gets() will continue to store characters past the end of the
       buffer, it is extremely dangerous to use.  It has been used to break computer security.  Use fgets() instead.

       For more information, see CWE-242 (aka "Use of Inherently Dangerous Function") at http://cwe.mitre.org/data/definitions/242.html
...
C double free prevention
// Source - https://stackoverflow.com/a/50786505
// Posted by Weather Vane
// Retrieved 2026-05-07, License - CC BY-SA 4.0
 
char* ptr = malloc(sizeof(char));
 
*ptr = 'a';
free(ptr);
ptr = NULL;         // add this
free(ptr);
2025/03/24 15:06

Notes SQL

Voir :

FIXME

Requêtes SQL imbriquées :

SELECT unifiedjob_ptr_id FROM main_job WHERE unifiedjob_ptr_id IN (SELECT id FROM main_unifiedjob WHERE execution_environment_id=3 );
2025/03/24 15:06

Notes Kubernetes k8s - Utilisation

Voir :

kubectl api-resources -o wide
kubectl explain deploy
 
kubectl get nodes
kubectl get pods --all-namespaces
kubectl --namespace=kube-system get all
kubectl --kubeconfig .kube/config  get nodes
export KUBECONFIG=/etc/kubernetes/admin.conf
#export KUBECONFIG=~/.kube/config
cp /etc/kubernetes/admin.conf ~/.kube/config
 
kubectl --server=https://192.168.56.21:6443 get nodes -o wide
kubectl get deployment --all-namespaces
kubectl get svc

Administration

Diagnostiquer le dysfonctionnement d'un pod Kubernetes

# Voir les logs
kubectl logs monpod
# Si le pod est en erreur
kubectl describe po monpod
# Si le pod n'existe pas, voir le replicaset qui devrait le créer (s'il y en a un)
kubectl describe rs monreplicaset
# Si le replicaset n'existe pas, voir son déploiement/statefulset/autre
kubectl describe deploy mondeploiement
kubectl describe sts mon statefulset

Vous pouvez consulter ce diagramme pour le troubleshooting d'un déploiement Consulter les logs de l'api server Kubernetes

On y trouvera notamment les requêtes récentes des utilisateurs et leur droits RBAC

kubectl -n kube-system logs -l component=kube-apiserver --tail 1000

Consulter les logs de plop

Peut permettre d'avoir des détails sur les messages d'erreurs de plop

kubectl -n plop logs -l app=plop -c plop --tail 1000

Note: on pourra passer plop en mode debug pour avoir des informations plus complètes (kubectl -n plop edit ds plop, puis “- --log-level=debug” dans les arguments du container) Lister les pvs de chaque node

Permet de voir les pvs (persistent volumes) disponibles sur chaque node, par exemple pour débugger un statefulset dont un pvc est en état “Pending”

export JSONPATH='{range .items[*]}{@.metadata.name}  {@.spec.nodeAffinity.required.nodeSelectorTerms[*].matchExpressions[*].values[]}  {@.status.phase}  {@.spec.capacity.storage};{end}'
kubectl get pv -o jsonpath="$JSONPATH" | tr ";" "\n"

Objets Kubernetes

Commandes pour retrouver le pod / daemonset / deploiement responsable du container “plop”:

# À utiliser sur un master, les noeuds n'ont pas la commande "kubectl"
kubectl get pod -A | grep plop
kubectl get ds -A | grep plop
kubectl get deploy -A | grep plop

Attendre un état - ex que les pods soient prêts

 
An alternative approach is to use kubectl wait
 
You could:
~~~bash
kubectl wait pod --all --for=condition=Ready --namespace=${ns}
 
kubectl wait pod --all --for=condition=Ready -A

Procédures Restart des pods

Se placer dans le namespace des frontaux valplop

kubectl config set-context $(kubectl config current-context) --namespace=zzz-valplop

Vérifier qu'on accède bien au cluster k8s en listant les pods

kubectl get pods

Résultat attendu

NAME                          READY   STATUS    RESTARTS   AGE
bac-valplop-8686574455-bnplq   4/4     Running   0          6d21h
bac-valplop-8686574455-ddxcf   4/4     Running   0          4d3h
bac-valplop-8686574455-dr25b   4/4     Running   0          6d21h
[...]

Vérifier quelle ressource deployment on veut relancer

kubectl get deployments.apps

Lancer un rollout (= restart des pods du deployment ciblé)

kubectl rollout restart deployment <nom du deployment>

On peut surveiller le restart séquentiel des pods avec l'utilitaire k9s, les nouveaux pods passeront successivement les états Pending, ContainerCreating, Running… les anciens passeront en Terminated et disparaitront

Restart pod récalcitrant

kubectl delete pod cassandra-cl02livebgl-a-0 --grace-period=0 --force

Je veux savoir ma conso sur mon namespace

kubectl -n $namespace get ResourceQuota kaas-compute-resources-$namespace -o yaml
Restart a resource

Resource rollout will be restarted.

kubectl rollout restart RESOURCE

Examples

# Restart all deployments in the test-namespace namespace
kubectl rollout restart deployment -n test-namespace

# Restart a deployment
kubectl rollout restart deployment/nginx

# Restart a daemon set
kubectl rollout restart daemonset/abc

# Restart deployments with the app=nginx label
kubectl rollout restart deployment --selector=app=nginx

Notes install nodes

Clef SSH /root/.ssh/

apt-get install curl

Install kubectl Install kubeadm Install Docker

kubectl get nodes -o wide
kubectl version
kubectl cluster-info

To further debug and diagnose cluster problems, use kubectl cluster-info dump

kubectl get namespaces
kubectl api-resources
# kubectl run hello --image=hello-world
pod/hello created
# kubectl get pods
NAME    READY   STATUS             RESTARTS     AGE
hello   0/1     CrashLoopBackOff   1 (4s ago)   10s

CrashLoopBackOff signifit que le container fait que de cracher, ce qui est normal pour le 'hello-word' qui se termine systématiquement

kubectl run nginx --image=nginx
kubectl describe pod nginx

Get a shell to the running container

kubectl exec -ti nginx -- /bin/bash

Get a shell to a specific running container

# Get containers list
kubectl get pod awx-task-777db545b8-7npjl -o jsonpath='{.spec.containers[*].name }{"\n"}'
 
kubectl exec -ti awx-task-777db545b8-7npjl --container awx-ee -- /bin/bash

Port mapping

kubectl port-forward nginx 8080:80
kubectl create deployment nginx-deployment --image=nginx
 
kubectl expose deployment nginx-deployment --port=8080 --target-port=80
kubectl get services
# kubectl describe deployment nginx-deployment | grep ^Replicas:
Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable

# kubectl scale deployment nginx-deployment --replicas=2
deployment.apps/nginx-deployment scaled

Création d'un pod

nginx.yaml

apiVersion: v1
kind: Pod
metadata:
  name: www
spec:
  containers:
    - name: nginx
      image: nginx:1.12.2
kubectl create -f pod.yaml

Autres

export POD_NAME=$(kubectl get pods --namespace kube-system -l "app.kubernetes.io/name=headlamp,app.kubernetes.io/instance=my-headlamp" -o jsonpath="{.items[0].metadata.name}")
 
export CONTAINER_PORT=$(kubectl get pod --namespace kube-system $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
 
kubectl --namespace kube-system port-forward $POD_NAME 8080:$CONTAINER_PORT
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