[rEFInd] Mise à jour automatique des fichiers rEFInd.

Applications, problèmes de configuration réseau
gil76mg
Daikyu
Messages : 78
Inscription : sam. 14 janv. 2012, 17:40

[rEFInd] Mise à jour automatique des fichiers rEFInd.

Message par gil76mg »

Bonjour,

j'ai suivi le wiki concernant la mise des jours des fichiers de rEFInd suite à une mise à jour notamment la mise ne place des scripts.

Cependant, je constate une différence de version de fichiers entre d'une part le répertoire /usr/share/refind et ma partition /boot.

Code : Tout sélectionner

ls -l /boot/efi/EFI/refind/
total 3152
drwxr-xr-x 2 root root    8192  9 sept. 16:42 icons
-rwxr-xr-x 1 root root 3014132  9 sept. 18:30 plage.png
-rwxr-xr-x 1 root root   17920  9 sept. 18:33 refind.conf
-rwxr-xr-x 1 root root   17924  9 sept. 18:32 refind.conf~
-rwxr-xr-x 1 root root  162624  9 sept. 14:10 refind_x64.efi
et

Code : Tout sélectionner

ls -l /usr/share/refind/
total 212
drwxr-xr-x 4 root root   4096 15 sept. 18:22 docs
drwxr-xr-x 2 root root   4096 15 sept. 18:22 drivers_x64
drwxr-xr-x 2 root root   4096 15 sept. 18:22 fonts
drwxr-xr-x 2 root root   4096 15 sept. 18:22 icons
drwxr-xr-x 2 root root   4096 15 sept. 18:22 images
drwxr-xr-x 2 root root   4096 15 sept. 18:22 keys
-rw-r--r-- 1 root root  18306 12 sept. 16:57 refind.conf-sample
-rw-r--r-- 1 root root    378 12 sept. 16:57 refind_linux.conf-sample
-rw-r--r-- 1 root root 163840 12 sept. 16:57 refind_x64.efi
drwxr-xr-x 2 root root   4096 15 sept. 18:22 tools_x64
Une idée. Merci d'avance.
jean_no
yeomen
Messages : 285
Inscription : dim. 09 sept. 2007, 12:19

Re: [rEFInd] Mise à jour automatique des fichiers rEFInd.

Message par jean_no »

Salut

Donnes nous le contenu de tes scripts qui doivent faire la maj automatique de rEFInf.
Je pense que tu n'as pas dû changer les chemins des différents fichers...

A+
gil76mg
Daikyu
Messages : 78
Inscription : sam. 14 janv. 2012, 17:40

Re: [rEFInd] Mise à jour automatique des fichiers rEFInd.

Message par gil76mg »

Voilà:

Code : Tout sélectionner

/usr/lib/systemd/scripts/refind_name_patchv2 
#!/usr/bin/env bash
## COPYRIGHT 2013 : MARK E. LEE (BLUERIDER) : mlee24@binghamton.edu; mark@markelee.com

## LOG
## 1/17/2013 : Version 2 of refind_name_patch is released
##           : Supports long subdirectory location for refind
##           : Updates nvram when needed
##           : 10% speed boost
## 7/15/2013 : Changed arch to match 32-bit (ia32) and 64-bit (x64) naming scheme
##           : Changed directory copying in update-efi-dir to copy tools and drivers directories explicitly
##           : Changed efibootmgr writing code to be more concise and added (-w) to write the entry as per dusktreader's excellent guide : https://docs.google.com/document/d/1pvgm3BprpXoadsQi38FxqMOCUZhcSqFhZ26FZBkmn9I/edit
##           : Function to check if NVRAM boot entry was already listed was fixed to use awk and an if then clause
##           : ref_bin_escape was modified from : ref_bin_escape=${ref_bin//\//\\\\} to remove extra backslashes (error does not show up when using cmdline)
## 7/29/2013 : Changed location of tools,drivers, and binary directory to match capricious upstream move to /usr/share/refind

function main () {  ## main insertion function
  declare -r refind_dir="/boot/efi/EFI/refind"; ## set the refind directory
  arch=$(uname -m | awk -F'_' '{if ($1 == "x86") {print "x"$2} else if ($1 == "i686") {print "ia32"}}') &&  ## get bit architecture
  update-efi-dir;  ## updates or creates the refind directory
  update-efi-nvram;  ## updates nvram if needed
}

function update-efi-dir () {  ## setup the refind directory
  if [ ! -d $refind_dir ]; then  ## check if refind directory exists
    echo "Couldn't find $refind_dir";
    mkdir $refind_dir &&  ## make the refind directory if needed
    echo "Made $refind_dir";
  fi;
  if [ "$arch" ]; then  ## check if anything was stored in $arch
    cp -r /usr/share/refind/{refind_$arch.efi,keys,images,icons,fonts,docs,{tools,drivers}_$arch} $refind_dir/  && ## update the bins and dirs
    echo "Updated binaries and directory files for refind at $refind_dir";
   else
    echo "Failed to detect an x86 architecture";
    exit;
  fi;
}

function update-efi-nvram () { ## update the nvram with efibootmgr
  declare -r ref_bin=${refind_dir/\/boot\/efi}/refind_$arch.efi;  ## get path of refind binary (without /boot/efi)
  declare -r ref_bin_escape=${ref_bin//\//\\};  ## insert escape characters into $ref_bin
  modprobe efivars && ## grab the efi variables for efibootmgr
  [ "$(efibootmgr -v | awk "/${ref_bin_escape//\\/\\\\}/")" ] && ( ## check if boot entry is in nvram \
    echo "Found boot entry, no need to update nvram";
    ) || ( ## if boot entry is not in nvram; add it
    declare -r esp=$(mount -l | awk '/ESP/ {print $1}') &&  ## get ESP partition
    efibootmgr -cgw -d ${esp:0:8} -p ${esp:8} -L "rEFInd" -l $ref_bin_escape && ## update nvram
    echo "
    Updated nvram with entry rEFInd to boot $ref_bin
    Did not copy configuration files, please move refind.conf to $refind_dir/";
    )
}
main;  ## run the main insertion function
et

Code : Tout sélectionner

 /usr/lib/systemd/system/refind_update.path
[Unit]
Description=Update rEFInd bootloader files

[Path]
PathChanged=/usr/share/refind/refind_x64.efi
Unit=refind_update.service

[Install]
WantedBy=multi-user.target
et

Code : Tout sélectionner

 /usr/lib/systemd/system/refind_update.service
[Unit]
Description=Update rEFInd directories, binaries, and nvram

[Service]
Type=oneshot
ExecStart=/usr/bin/bash /usr/lib/systemd/scripts/refind_name_patchv2
RemainAfterExit=no
Merci.
jean_no
yeomen
Messages : 285
Inscription : dim. 09 sept. 2007, 12:19

Re: [rEFInd] Mise à jour automatique des fichiers rEFInd.

Message par jean_no »

Salut

Il y a eu une maj de efibootmgr le 16/09/2013 qui rend efibootmgr compatible avec efivarfs.
(Recommandé depuis le kernel 3.10 ).
Et qui ne nécessite plus le recours au module efivars ( à ne pas confondre avec efivarfs ).

Essaies d'autres méthodes pour mettre à jour rEFInd. Pour info, voici ce que j'ai ( à adapter ) :
refind_update.path :

Code : Tout sélectionner

[Unit]
Description=Check update rEFInd

[Path]
PathChanged=/usr/share/refind/refind_x64.efi
PathChanged=/usr/share/refind/drivers_x64/ext4_x64.efi
PathChanged=/usr/share/refind/drivers_x64/iso9660_x64.efi

Unit=refind_update.service

[Install]
WantedBy=multi-user.target
refind_update.service :

Code : Tout sélectionner

[Unit]
Description=Copy rEFInd files to UEFISYS Partition
# Requires=boot-efi.mount

[Service]
Type=oneshot
ExecStart=/usr/bin/cp -f /usr/share/refind/refind_x64.efi /boot/efi/EFI/refind/refind_x64.efi
Vérifies aussi dans le journal de systemd si une erreur apparait.

A+
Répondre