admin:services:apt-dater
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
admin:services:apt-dater [2020/04/25 23:30] – klafyvel | admin:services:apt-dater [2020/04/26 00:13] (Version actuelle) – klafyvel | ||
---|---|---|---|
Ligne 2: | Ligne 2: | ||
Chaque serveur de FedeRez est configuré pour être mis à jour via [[http:// | Chaque serveur de FedeRez est configuré pour être mis à jour via [[http:// | ||
+ | ======= Comment faire les mises à jour ? ======= | ||
- | ====== Infos générales ====== | + | {{page> |
- | ===== En speed ==== | + | ======= Installation sur les hosts ======= |
- | ==== Ajouter une clef pour un admin sur une machine managée par apt-dater | + | {{page>admin:services:apt-dater: |
- | Sur **chaque** machine(s) concernée(s) (en gros [[admin: | + | {{page>admin:services: |
- | + | ||
- | :!: Attention ici exemples de zertrin et David_5.1, adapter **les clefs et les IP autorisées** à votre cas ! | + | |
- | + | ||
- | # en tant que root | + | |
- | cat << EOF >> ~aptdater/ | + | |
- | no-agent-forwarding, | + | |
- | no-agent-forwarding, | + | |
- | EOF | + | |
- | + | ||
- | ==== Installer apt-dater sur une machine de management ==== | + | |
- | + | ||
- | Installation du paquet (exemple Debian, pour les autres distros, débrouillez vous !): | + | |
- | + | ||
- | apt-get install apt-dater | + | |
- | + | ||
- | En tant qu' | + | |
- | + | ||
- | Modifier '' | + | |
- | + | ||
- | Ajouter (ou remplacer l' | + | |
- | + | ||
- | [FedeRez] | + | |
- | Hosts=aptdater@hexagon.federez.net; | + | |
- | + | ||
- | Relancer apt-dater, les serveurs seront dans la section '' | + | |
- | + | ||
- | ====== Mise en place initiale d' | + | |
- | + | ||
- | Note: toutes les étapes ci-dessous se font en tant que superutilisateur. | + | |
- | ===== Installation ===== | + | |
- | + | ||
- | Installation du paquet : | + | |
- | + | ||
- | apt-get install apt-dater-host | + | |
- | + | ||
- | ===== Configuration initiale ===== | + | |
- | + | ||
- | La config suivie ici s' | + | |
- | + | ||
- | ==== Ajout d'un utilisateur dédié ==== | + | |
- | + | ||
- | adduser --quiet --system --home / | + | |
- | adduser aptdater ssh | + | |
- | + | ||
- | ==== Configuration de SSH pour apt-dater ==== | + | |
- | + | ||
- | On n' | + | |
- | + | ||
- | mkdir -m 0700 ~aptdater/ | + | |
- | + | ||
- | Ajout de la clef d' | + | |
- | + | ||
- | :!: Attention ici exemple de David_5.1, adapter la clef et les IP autorisées à votre cas ! | + | |
- | + | ||
- | touch ~aptdater/ | + | |
- | chown aptdater: -R ~aptdater/ | + | |
- | cat << EOF >> ~aptdater/ | + | |
- | no-agent-forwarding, | + | |
- | EOF | + | |
- | + | ||
- | ==== Configuration de sudo pour apt-dater | + | |
- | + | ||
- | cat << " | + | |
- | # package installation is denied | + | |
- | aptdater ALL = (root) NOPASSWD: / | + | |
- | aptdater ALL = (root) NOPASSWD: / | + | |
- | aptdater ALL = (root) NOPASSWD: / | + | |
- | aptdater ALL = (root) NOPASSWD: / | + | |
- | aptdater ALL = (root) NOPASSWD: / | + | |
- | aptdater ALL = (root) NOPASSWD: / | + | |
- | aptdater ALL = (root) NOPASSWD: / | + | |
- | aptdater ALL = (root) NOPASSWD: / | + | |
- | EOF | + | |
- | + | ||
- | chmod 0440 / | + | |
- | + | ||
- | ==== Demande de validation des mise à jour ==== | + | |
- | + | ||
- | Pour qu'une demande de confirmation de la liste des paquets à mettre à jour soit faite, il faut modifier ''/ | + | |
- | sed -i ' | + | |
- | ==== Limitation de la priorité d' | + | |
- | + | ||
- | printf " | + | |
- | + | ||
- | ==== Création d' | + | |
- | + | ||
- | <WRAP center round important 60%> | + | |
- | Ce qui suit n'a jamais été aperçu en état de marche, il est donc déconseillé de l' | + | |
- | </ | + | |
- | + | ||
- | À placer dans ''/ | + | |
- | + | ||
- | <code bash> | + | |
- | #!/bin/sh | + | |
- | + | ||
- | set -e | + | |
- | set -u | + | |
- | + | ||
- | # Explicitly set the PATH to that of ENV_SUPATH in / | + | |
- | # various other variables. For details, see: | + | |
- | # https:// | + | |
- | export PATH=/ | + | |
- | export ENV= | + | |
- | export CDPATH= | + | |
- | + | ||
- | LOGGER="/ | + | |
- | APT_DATER_HOST=" | + | |
- | KILL="/ | + | |
- | SLEEP="/ | + | |
- | + | ||
- | # Install command allowed? | + | |
- | INSTALL_ALLOWED=" | + | |
- | if [ " | + | |
- | if [ " | + | |
- | INSTALL_ALLOWED=" | + | |
- | fi | + | |
- | fi | + | |
- | + | ||
- | illegal_command() { | + | |
- | # Do not log SSH_ORIGINAL_COMMAND for security reasons | + | |
- | $LOGGER " | + | |
- | # Default deny | + | |
- | $KILL -9 $PPID | + | |
- | exit 0 | + | |
- | } | + | |
- | + | ||
- | check_ssh_command() { | + | |
- | if [ " | + | |
- | # not in the form of apt-dater-host upgrade | + | |
- | illegal_command | + | |
- | fi | + | |
- | + | ||
- | if [ " | + | |
- | # not invoking apt-dater-host | + | |
- | illegal_command | + | |
- | else | + | |
- | # Remove the 1st arg with later replace it with the | + | |
- | # fully qualified path to apt-dater-host | + | |
- | shift | + | |
- | fi | + | |
- | + | ||
- | COMMAND=" | + | |
- | shift | + | |
- | + | ||
- | if [ " | + | |
- | $APT_DATER_HOST $COMMAND | + | |
- | elif [ " | + | |
- | # Don't kill the shell session right away when | + | |
- | # upgrading/ | + | |
- | $APT_DATER_HOST $COMMAND && $SLEEP 0.5 | + | |
- | elif [ " | + | |
- | if [ " | + | |
- | # Don't kill the shell session right away when | + | |
- | # upgrading/ | + | |
- | $APT_DATER_HOST $COMMAND $* && $SLEEP 0.5 | + | |
- | else | + | |
- | illegal_command | + | |
- | fi | + | |
- | fi | + | |
- | } | + | |
- | + | ||
- | if [ -z " | + | |
- | illegal_command | + | |
- | fi | + | |
- | + | ||
- | case " | + | |
- | *\&*) | + | |
- | illegal_command | + | |
- | ;; | + | |
- | *\(*) | + | |
- | illegal_command | + | |
- | ;; | + | |
- | *\{*) | + | |
- | illegal_command | + | |
- | ;; | + | |
- | *\;*) | + | |
- | illegal_command | + | |
- | ;; | + | |
- | *\>*) | + | |
- | illegal_command | + | |
- | ;; | + | |
- | *\`*) | + | |
- | illegal_command | + | |
- | ;; | + | |
- | *\|*) | + | |
- | illegal_command | + | |
- | ;; | + | |
- | apt-dater-host\ refresh) | + | |
- | check_ssh_command $SSH_ORIGINAL_COMMAND | + | |
- | ;; | + | |
- | apt-dater-host\ upgrade) | + | |
- | check_ssh_command $SSH_ORIGINAL_COMMAND | + | |
- | ;; | + | |
- | apt-dater-host\ install\ *) | + | |
- | check_ssh_command $SSH_ORIGINAL_COMMAND | + | |
- | ;; | + | |
- | apt-dater-host\ kernel) | + | |
- | check_ssh_command $SSH_ORIGINAL_COMMAND | + | |
- | ;; | + | |
- | *) | + | |
- | illegal_command | + | |
- | ;; | + | |
- | esac | + | |
- | </ | + | |
- | + | ||
- | En oubliant pas de le rendre exécutable: | + | |
- | + | ||
- | chmod 0755 / | + | |
======= Le contrôleur ======= | ======= Le contrôleur ======= | ||
Ligne 223: | Ligne 16: | ||
{{page> | {{page> | ||
- | ===== Liens (potentiellement) utiles ===== | + | ====== Liens (potentiellement) utiles |
* Site officiel : http:// | * Site officiel : http:// |
admin/services/apt-dater.1587850222.txt.gz · Dernière modification : 2020/04/25 23:30 de klafyvel