scripts/gestion/iscsi/udev-update-symlinks.sh
Pierre-Elliott Bécue 86df83ee01 [Iscsi] Je croyais avoir changé la baie par défaut.
Ignore-this: ef4d0e9e5645a49d7eb2f5b76f61804a

darcs-hash:20120903225053-b6762-0ca0087ee10d1d92fe50e09deb54f9bab9ec29d6.gz
2012-09-04 00:50:53 +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="nols"
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