Table des matières
- 2026:
- 2025:
4 billet(s) pour septembre 2026
| Notes HTTP Strict Transport Security - HSTS | 2026/09/18 11:04 | Jean-Baptiste |
| Notes GNU Linux GPU carte graphiques | 2026/09/08 15:49 | Jean-Baptiste |
| Notes GNU Linux graphique | 2026/09/08 15:42 | Jean-Baptiste |
| Notes urlencoding - passer des mots de passe en HTTPS | 2026/09/03 17:58 | Jean-Baptiste |
psh Perl Shell
Une shell interactif pour Perl REPL (Read-Eval-Print-Loop)
perl -MCPAN -e 'install BSD::Resource' export PERL5LIB=~/perl5/lib/perl5/ git clone https://github.com/gnp/psh cd psh perl Makefile.PL make make install ~/perl5/bin/psh
ou encore
perl -de0
Un MakeFile pour rpmbuild
Voir aussi :
- Python invoke https://www.pyinvoke.org/
- o-task https://taskfile.dev/
- Make.rules
Makefile
clean: SHELL:=/bin/bash build: SHELL:=/bin/bash FicSpec = $(shell echo *.spec) RpmName = $(shell grep -e '^%define name' $(FicSpec) | awk '{print $$3}') RpmVersion = $(shell grep -e '^%define version' $(FicSpec) | awk '{print $$3}') RpmRelease = $(shell grep -e '^%define release' $(FicSpec) | awk '{print $$3}') StringRpmFullname = $(RpmName)-$(RpmVersion)-$(RpmRelease).$(shell uname -m) all: build clean clean: rm -rf $$HOME/rpmbuild cleanall: clean rm -f *.rpm copy: cleanall mkdir -p $$HOME/rpmbuild/{BUILDROOT,SPECS} mkdir -p $$HOME/rpmbuild/BUILDROOT/$(StringRpmFullname) cp -a ROOT/* $$HOME/rpmbuild/BUILDROOT/$(StringRpmFullname) cp -p $(FicSpec) ~/rpmbuild/SPECS/ build: copy rpmbuild -bb ~/rpmbuild/SPECS/*.spec mv ~/rpmbuild/RPMS/*/*.rpm .
Le clean se fait bien avant, mais pas après le build.
C'est comme si :
all: build clean
Etait
all: build
Solution :
Makefile
clean: SHELL:=/bin/bash build: SHELL:=/bin/bash FicSpec = $(shell echo *.spec) RpmName = $(shell grep -e '^%define name' $(FicSpec) | awk '{print $$3}') RpmVersion = $(shell grep -e '^%define version' $(FicSpec) | awk '{print $$3}') RpmRelease = $(shell grep -e '^%define release' $(FicSpec) | awk '{print $$3}') StringRpmFullname = $(RpmName)-$(RpmVersion)-$(RpmRelease).$(shell uname -m) all: build cleanagain clean: rm -rf $$HOME/rpmbuild cleanall: clean rm -f *.rpm cleanagain: ${MAKE} clean copy: cleanall mkdir -p $$HOME/rpmbuild/{BUILDROOT,SPECS} mkdir -p $$HOME/rpmbuild/BUILDROOT/$(StringRpmFullname) cp -a ROOT/* $$HOME/rpmbuild/BUILDROOT/$(StringRpmFullname) cp -p $(FicSpec) ~/rpmbuild/SPECS/ build: copy rpmbuild -bb ~/rpmbuild/SPECS/*.spec mv ~/rpmbuild/RPMS/*/*.rpm .
Exemple avec le paquet Python mycli
mkdir -p ~/rpm/ROOT cd ~/rpm
Déposez le Makefile dans ~/rpm/
~/rpm/mycli.spec
%define name mycli
%define version 1.21.1
%define release 1
%define debug_package %{nil}
Summary: CLI for MySQL/MariaDB
Name: %{name}
Version: %{version}
Release: %{release}
Vendor: NC
Group: Database
License: MIT License
URL: https://www.mycli.net
Source0: https://github.com/dbcli/mycli
BuildRequires: rpm-build
Requires: python38
#BuildArch: noarch
%description
This is a command line interface for MySQL, MariaDB, and Percona with
auto-completion and syntax highlighting. The CLI is also capable of pretty
printing tabular data.
#%post
#set -e
%doc
#%changelog
%files
%defattr(755,root,root,644)
export http_proxy=http://127.0.0.1:3128 export https_proxy=http://127.0.0.1:3128 pip3 install --user mycli mkdir -p ~/rpm/ROOT/opt/mycli cp -a ~/.local/* ~/rpm/ROOT/opt/mycli/ mkdir -p ~/rpm/ROOT/usr/local/bin/ find /home/etudes/rpm/ROOT/ -type f -name "*.pyc" -delete
~/rpm/ROOT/usr/local/bin/mycli
#!/bin/sh env PYTHONPATH=/opt/mycli/lib/python3.8/site-packages/ /opt/mycli/bin/mycli "$@"
cd ~/rpm/ROOT find . -type f | sed -e 's/^\.//' >> ../mycli.spec cd ~/rpm/ make
Pb
did you mean TAB instead of 8 spaces?
$ make Makefile:18: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.
Solution
sed -i.bak -e 's/^[ ]\+/\t/g' Makefile
Umask par defaut - Droits des fichiers par defaut
Pour Debian Jessie
Voir :
Voir aussi :
/etc/login.defs
#UMASK 022 UMASK 027
/etc/pam.d/common-session
session optional pam_umask.so
Infos
umask 27 umask -S
Source : http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html
| umask | Niveau de sécurité | Permission effectives (sur les dossiers) |
|---|---|---|
| 022 | Permissif | 755 |
| 026 | Modéré | 751 |
| 027 | Modéré | 750 |
| 077 | Sévère | 700 |
Changer le umask par défaut d'un utilisateur
Voir http://stackoverflow.com/questions/10220531/how-to-set-system-wide-umask
Il est possible d'utiliser
- le champ GECOS de /etc/passwd
- de modifier le fichier .profile, .barshrc etc… de l'utilisateur
- d'utiliser pam
Champ GECOS de /etc/passwd
#chfn --other='umask=002' username chfn -o 'umask=0002' username
NOTE : A tester en console tty & xterm, et aussi en scp, sftp.
Changer le umask pour un service Systemd
/etc/systemd/system/plop.service
[Service] UMask=006
/etc/systemd/system/httpd.service
.include /lib/systemd/system/httpd.service [Service] UMask = 0002
Autres
Exemple
source /var/lib/awx/venv/ansible/bin/activate umask 0022 pip install --upgrade pywinrm deactivate
Script shell interactif avec boîtes de dialogue (dialog boxes) - Whiptail
Voir :
Voir aussi :
- dialog
Whiptail est inclus par défaut dans Debian
Exemple de script
dialogBoxes.sh
#! /bin/bash set -o nounset WHIPTAIL='env LANG=C whiptail' #exec 2> /tmp/dlg-log-"$(date +%Y%m%d%H%M)".err menu1() { $WHIPTAIL --title "NODE" --menu "Choose a hostname" 25 78 16 \ srv-1 "" \ srv-2 "" \ MAIN_MENU "" \ 2>/tmp/dlg-choix } menu2() { $WHIPTAIL --title "APP ON/OFF" --menu "On / Off" 25 78 16 \ 1_App_On "" \ 2_App_Off "" \ MAIN_MENU "" \ 2>/tmp/dlg-choix } main_menu() { $WHIPTAIL --title "MAIN MENU" --menu "Select an option" 25 78 16 \ 1_Node "" \ 2_App_Activation "" \ 2>/tmp/dlg-choix } sortir() { rm -f /tmp/dlg-choix echo -e "\\n\\tBye !" exit 0 } test_menu_option() { CHOIX=$(cat /tmp/dlg-choix) rm -f /tmp/dlg-choix case $CHOIX in 1_Node) menu1 ;; 2_App_Activation) menu2 ;; 1_App_On) echo "App_On ${HOST_SRV:-x}" sortir ;; 2_App_Off) echo "App_Off ${HOST_SRV:-x}" sortir ;; MAIN_MENU) main_menu ;; srv-1) HOST_SRV=1 menu2 ;; srv-2) HOST_SRV=2 menu2 ;; "") echo "Cancelled by user" sortir ;; *) echo -e "Option unknown : \"${CHOIX}\"" exit 2 ;; esac } main_menu while true do test_menu_option done
Dialog
Exemples
(pv -n image.iso | dd of=/dev/sdb bs=1M && sync) 2>&1 | dialog --gauge "la commande dd est en cours d'exécution, merci de patienter..." 10 70 0
