User

Difference between revisions of "Clément Démoulins"

From LRDE

(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
  +
 
== Extraire des sous dossiers d'un dépôt git ==
 
== Extraire des sous dossiers d'un dépôt git ==
   
 
Exemple, on veut extraire les papiers de Vaucanson du dépôt commun ''lrde-publis''.
 
Exemple, on veut extraire les papiers de Vaucanson du dépôt commun ''lrde-publis''.
   
<syntaxhighlight lang="bash" enclose="div">
+
<syntaxhighlight lang="bash">
 
# Clone du dépôt
 
# Clone du dépôt
 
git clone git@git:lrde-publis.git
 
git clone git@git:lrde-publis.git
Line 23: Line 24:
 
Compilation classique d'un paquet :
 
Compilation classique d'un paquet :
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
  +
source /lrde/dev/profile \
source /lrde/dev/profile && ./configure CXXFLAGS="-O3" CFLAGS="-O3" --prefix=/lrde/dev/$(uname -m)/stow/$(basename $PWD) && make && make install
 
  +
&& ./configure CXXFLAGS="-O3" CFLAGS="-O3" --prefix=/lrde/dev/$(lsb_release -i | sed -rn 's/.*:\s*(.*)$/\1/p')/$(lsb_release -r | sed -rn 's/.*:\s*(.*)$/\1/p')/$(uname -m)/stow/$(basename $PWD) \
  +
&& make -j8 && make install
 
</syntaxhighlight>
 
</syntaxhighlight>
   
Line 59: Line 62:
 
apt-get update
 
apt-get update
 
apt-get install -y vim-nox htop tree git tmux curl zsh
 
apt-get install -y vim-nox htop tree git tmux curl zsh
mkdir -p /root/.ssh;
+
mkdir -p ~/.ssh;
curl http://sao-paulo.lrde.epita.fr/cluster/files/admin-ssh-key.pub -o /root/.ssh/authorized_keys;
+
curl http://sao-paulo.lrde.epita.fr/cluster/files/admin-ssh-key.pub -o ~/.ssh/authorized_keys;
curl http://sao-paulo.lrde.epita.fr/cluster/files/known_hosts -o /root/.ssh/known_hosts;
+
curl http://sao-paulo.lrde.epita.fr/cluster/files/known_hosts -o ~/.ssh/known_hosts;
curl http://sao-paulo.lrde.epita.fr/cluster/files/id_rsa-dotfiles -o /root/.ssh/id_rsa-dotfiles;
+
curl http://sao-paulo.lrde.epita.fr/cluster/files/id_rsa-dotfiles -o ~/.ssh/id_rsa-dotfiles;
curl http://sao-paulo.lrde.epita.fr/cluster/files/id_rsa-dotfiles.pub -o /root/.ssh/id_rsa-dotfiles.pub;
+
curl http://sao-paulo.lrde.epita.fr/cluster/files/id_rsa-dotfiles.pub -o ~/.ssh/id_rsa-dotfiles.pub;
curl http://sao-paulo.lrde.epita.fr/cluster/files/ssh_config -o /root/.ssh/config;
+
curl http://sao-paulo.lrde.epita.fr/cluster/files/ssh_config -o ~/.ssh/config;
chmod 600 /root/.ssh/id_rsa-dotfiles;
+
chmod 600 ~/.ssh/id_rsa-dotfiles;
git clone --quiet dotfiles:clement/dotfiles.git /root/.dotfiles;
+
git clone --quiet dotfiles:clement/dotfiles.git ~/.dotfiles;
(cd /root/.dotfiles && ./install.sh);
+
(cd ~/.dotfiles && ./install.sh);
chsh root -s /usr/bin/zsh;
+
chsh $USER -s /usr/bin/zsh;
 
</syntaxhighlight>
 
</syntaxhighlight>
   
Line 112: Line 115:
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
 
apt-get update
 
apt-get update
apt-get install -y autofs autofs-ldap nslcd
+
apt-get install -y autofs autofs-ldap nslcd libnss-ldapd nfs-common glusterfs-client
 
apt-get purge nscd
 
apt-get purge nscd
 
wget http://sao-paulo.lrde.epita.fr/cluster/files/autofs.default -O /etc/default/autofs;
 
wget http://sao-paulo.lrde.epita.fr/cluster/files/autofs.default -O /etc/default/autofs;
Line 121: Line 124:
 
wget http://sao-paulo.lrde.epita.fr/cluster/files/nsswitch.conf -O /etc/nsswitch.conf;
 
wget http://sao-paulo.lrde.epita.fr/cluster/files/nsswitch.conf -O /etc/nsswitch.conf;
 
wget http://sao-paulo.lrde.epita.fr/cluster/files/nslcd.conf -O /etc/nslcd.conf;
 
wget http://sao-paulo.lrde.epita.fr/cluster/files/nslcd.conf -O /etc/nslcd.conf;
  +
</syntaxhighlight>
  +
  +
== Docker ==
  +
  +
=== Commandes ===
  +
  +
; docker build -t TAG_NAME .
  +
: Construit une image docker à partir d'un Dockerfile
  +
; docker run -t -i IMAGE CMD
  +
: Démarre un container intéractif à partir d'une image, si aucune commande n'est spécifiée, la commande définie par l'image est exécutée.
  +
; docker run -d IMAGE
  +
: Démarrage classique d'un container en mode daemon.
  +
; docker ps -a
  +
: Liste les containers
  +
; docker images -a
  +
: Liste les images
  +
; docker rm $(docker ps -a -q)
  +
: Delete all stopped containers
  +
; docker rmi $(docker images -q)
  +
: Delete ALL images
  +
; docker rmi $(docker images -q --filter "dangling=true")
  +
: Delete untagged images
  +
  +
=== Liens ===
  +
  +
* [http://docs.docker.com/reference/commandline/cli/ CLI documentation]
  +
* [http://docs.docker.com/reference/run/ Run documentation]
  +
* [http://docs.docker.com/reference/builder/ Dockerfile syntax]
  +
* [https://registry.hub.docker.com/repos/lrde/ Docker group lrde]
  +
  +
=== Outils tiers ===
  +
  +
* [https://wiki.archlinux.org/index.php/Systemd-nspawn systemd-nspawn], similaire à docker mais basé sur systemd
  +
* [https://linuxcontainers.org/ LXC], technologie équivalente à docker mais prévu pour "booter" le container
  +
* [https://github.com/coreos/rocket Rocket]
  +
* [https://github.com/docker/swarm/ Swarm], orchestrateur pour docker
  +
* [https://github.com/docker/compose/ Compose], orchestrateur pour docker (≠ de Swarm ?)
  +
* [https://coreos.com/ CoreOS], OS serveur basé sur des containers
  +
  +
  +
== Récupération de disques ==
  +
  +
* [http://linuxfr.org/news/ddrescue-dd_rescue-myrescue-recuperer-ses-donnees-apres-un-crash-disque recuperer-ses-donnees-apres-un-crash-disque]
  +
  +
== Paquet Debian ==
  +
  +
<syntaxhighlight lang=bash>
  +
# Création d'une image 'cow' pour jessie
  +
cowbuilder --create --basepath /var/cache/pbuilder/base-jessie.cow --distribution jessie
  +
# Mise à jour
  +
cowbuilder --update --basepath /var/cache/pbuilder/base-jessie.cow --distribution jessie
  +
  +
# Création du paquet avec gbp (si tout va bien)
  +
gbp buildpackage
  +
</syntaxhighlight>
  +
  +
== Ré-encodage vidéo ==
  +
  +
<syntaxhighlight lang=bash>
  +
ffmpeg -i "concat:$(echo *.MTS | sed 's/ /|/g')" -c copy raw.mp4
  +
ffmpeg -i raw.mp4 -codec:v h264_nvenc -gpu 2 -crf 25 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart output_1080p_crf25.mp4
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 15:27, 19 July 2018

Extraire des sous dossiers d'un dépôt git

Exemple, on veut extraire les papiers de Vaucanson du dépôt commun lrde-publis.

# Clone du dépôt
git clone git@git:lrde-publis.git
git clone --no-hardlinks lrde-publis vcsn-publis
cd vcsn-publis

# Filtre tout sauf ce qui match la pattern : (\.fsmnlp|\.ciaa|\.poosc|\.vaucanson|\.gitignore|\.gitmodules)$
git filter-branch --prune-empty --index-filter "git rm -r --cached --ignore-unmatch $(git log -p | sed -rne 's/^diff --git a\/([^/]+)\/?.* b\/.*$/\1/ p' | sort -u | egrep -v '(\.fsmnlp|\.ciaa|\.poosc|\.vaucanson|\.gitignore|\.gitmodules)$' | xargs echo)" HEAD

# Nettoyage du dépôt
git remote rm origin
git update-ref -d refs/original/refs/heads/master
git reflog expire --expire=now --all
git repack -ad

Compilation dans /lrde/dev

Compilation classique d'un paquet :

source /lrde/dev/profile \
&& ./configure CXXFLAGS="-O3" CFLAGS="-O3" --prefix=/lrde/dev/$(lsb_release -i | sed -rn 's/.*:\s*(.*)$/\1/p')/$(lsb_release -r | sed -rn 's/.*:\s*(.*)$/\1/p')/$(uname -m)/stow/$(basename $PWD) \
&& make -j8 && make install

Compilation de gcc :

Compilation de clang :

source /lrde/dev/profile
CC=gcc-4.9 CXX=g++-4.9 ./configure CXXFLAGS="-O3" CFLAGS="-O3" --prefix=/lrde/dev/$(uname -m)/stow/$(basename $PWD)
make

Compilation de opencv :

source /lrde/dev/profile
cmake \
    -D WITH_OPENCL=ON \
    -D WITH_OPENGL=ON \
    -D BUILD_TESTS=OFF \
    -D BUILD_EXAMPLES=OFF \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_INSTALL_PREFIX=/lrde/dev/$(uname -m)/stow/$(basename $PWD) \
    -D CMAKE_SKIP_RPATH=ON \
    .
make

Commandes bien pratique de post installation

Déploiement de ma config

apt-get update
apt-get install -y vim-nox htop tree git tmux curl zsh
mkdir -p ~/.ssh;
curl http://sao-paulo.lrde.epita.fr/cluster/files/admin-ssh-key.pub       -o ~/.ssh/authorized_keys;
curl http://sao-paulo.lrde.epita.fr/cluster/files/known_hosts             -o ~/.ssh/known_hosts;
curl http://sao-paulo.lrde.epita.fr/cluster/files/id_rsa-dotfiles         -o ~/.ssh/id_rsa-dotfiles;
curl http://sao-paulo.lrde.epita.fr/cluster/files/id_rsa-dotfiles.pub     -o ~/.ssh/id_rsa-dotfiles.pub;
curl http://sao-paulo.lrde.epita.fr/cluster/files/ssh_config              -o ~/.ssh/config;
chmod 600 ~/.ssh/id_rsa-dotfiles;
git clone --quiet dotfiles:clement/dotfiles.git ~/.dotfiles;
(cd ~/.dotfiles && ./install.sh);
chsh $USER -s /usr/bin/zsh;

sources.list

wget http://sao-paulo.lrde.epita.fr/cluster/files/sources.list                  -O /etc/apt/sources.list;
wget http://sao-paulo.lrde.epita.fr/cluster/files/security.sources.list         -O /etc/apt/sources.list.d/security.sources.list;
apt-get update;

cron-apt

apt-get update;
apt-get install -y cron-apt;
wget http://sao-paulo.lrde.epita.fr/cluster/files/cron-apt-config               -O /etc/cron-apt/config;
wget http://sao-paulo.lrde.epita.fr/cluster/files/cron-apt-2-security-upgrade   -O /etc/cron-apt/action.d/2-security-upgrade;
wget http://sao-paulo.lrde.epita.fr/cluster/files/cron-apt-security.conf        -O /etc/cron-apt/apt-security-upgrade.conf;

deb-multimedia + ffmpeg

echo "deb http://www.deb-multimedia.org wheezy main non-free" > /etc/apt/sources.list.d/deb-multimedia.list
apt-get update
apt-get install deb-multimedia-keyring
apt-get update
apt-get install libav{filter,format,util,device,codec}-dev libav{codec54,util52,filter3,device54} libswscale-dev

glusterfs 3.5

wget -O - http://download.gluster.org/pub/gluster/glusterfs/3.5/3.5.0/Debian/pubkey.gpg | apt-key add -
echo 'deb [ arch=amd64 ] http://download.gluster.org/pub/gluster/glusterfs/3.5/3.5.0/Debian/apt wheezy main' > /etc/apt/sources.list.d/gluster.list
apt-get update
apt-get install glusterfs-client

LDAP

apt-get update
apt-get install -y autofs autofs-ldap nslcd libnss-ldapd nfs-common glusterfs-client
apt-get purge nscd
wget http://sao-paulo.lrde.epita.fr/cluster/files/autofs.default          -O /etc/default/autofs;
wget http://sao-paulo.lrde.epita.fr/cluster/files/autofs.if-up            -O /etc/network/if-up.d/autofs;
chmod +x /etc/network/if-up.d/autofs;
wget http://sao-paulo.lrde.epita.fr/cluster/files/ldap.conf               -O /etc/ldap/ldap.conf;
wget http://sao-paulo.lrde.epita.fr/cluster/files/cacert.pem              -O /etc/ssl/certs/lrde-cacert.pem;
wget http://sao-paulo.lrde.epita.fr/cluster/files/nsswitch.conf           -O /etc/nsswitch.conf;
wget http://sao-paulo.lrde.epita.fr/cluster/files/nslcd.conf              -O /etc/nslcd.conf;

Docker

Commandes

docker build -t TAG_NAME .
Construit une image docker à partir d'un Dockerfile
docker run -t -i IMAGE CMD
Démarre un container intéractif à partir d'une image, si aucune commande n'est spécifiée, la commande définie par l'image est exécutée.
docker run -d IMAGE
Démarrage classique d'un container en mode daemon.
docker ps -a
Liste les containers
docker images -a
Liste les images
docker rm $(docker ps -a -q)
Delete all stopped containers
docker rmi $(docker images -q)
Delete ALL images
docker rmi $(docker images -q --filter "dangling=true")
Delete untagged images

Liens

Outils tiers

  • systemd-nspawn, similaire à docker mais basé sur systemd
  • LXC, technologie équivalente à docker mais prévu pour "booter" le container
  • Rocket
  • Swarm, orchestrateur pour docker
  • Compose, orchestrateur pour docker (≠ de Swarm ?)
  • CoreOS, OS serveur basé sur des containers


Récupération de disques

Paquet Debian

# Création d'une image 'cow' pour jessie
cowbuilder --create --basepath /var/cache/pbuilder/base-jessie.cow --distribution jessie
# Mise à jour
cowbuilder --update --basepath /var/cache/pbuilder/base-jessie.cow --distribution jessie

# Création du paquet avec gbp (si tout va bien)
gbp buildpackage

Ré-encodage vidéo

ffmpeg -i "concat:$(echo *.MTS | sed 's/ /|/g')" -c copy raw.mp4
ffmpeg -i raw.mp4 -codec:v h264_nvenc -gpu 2 -crf 25 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart output_1080p_crf25.mp4