scripts/gestion/iscsi/udev-update-symlinks.sh
Pierre-Elliott Bécue b7a333074d [DHCP tools + random] Pour que tout marche mieux.
Ignore-this: 590aacb4887da39fd62052c13508c65b

darcs-hash:20120808150616-b6762-4d571c82be02d5cdaa6f275d2518eddd0061a42f.gz
2012-08-08 17:06:16 +02:00

41 lines
1.1 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# udev-update-symlinks.sh
# -----------------------
# Modifié par : Pierre-Elliott Bécue <peb@crans.org> (8 août 2012)
# Copyright : (c) 2012, Olivier Iffrig <iffrig@crans.org>
# Copyright : (c) 2008, Jeremie Dimino <jeremie@dimino.org>
# Licence : BSD3
# Ce script met à jour les liens symboliques dans /dev
if [[ $1 = "" ]]; then
BAIE="slon"
else
BAIE="$1"
fi
# On repère les disques montés depuis la baie dans le dossier
# /dev/disk/by-path/ip-*
cd /dev/disk/by-path/
for dev in ip-*; do
# /dev/disk/by-path/ip-blabla est un lien vers /dev/sdkr
# on utilise readlink pour avoir ce lien.
dev=$(readlink $dev | awk -F "/" '{print $3}')
symlink=iscsi_$(python /usr/scripts/gestion/iscsi/udev-get-iscsi-name.py $dev $BAIE)
# On linke dans /dev
cd /dev
if [ ! -e $symlink ]; then
echo "création du lien /dev/$symlink -> /dev/$dev"
ln -s $dev $symlink
elif [ -h $symlink -a $(readlink $symlink) != $dev ]; then
echo "mise à jour du lien /dev/$symlink -> /dev/$dev"
rm -f $symlink
ln -s $dev $symlink
fi
cd /dev/disk/by-path/
done