Linux-os lin_tape tape device-ok 'persistent binding'-jat beállító udev konfig fájl generáló szkript

lnx_lin_tape_rules_conf_generate.sh
#!/bin/bash
tsm_inst_user='root'
echo "# Generated by $0 on $(date)"
UDEVAPP=`which udevadm 2>/dev/null`
UDEVPARAM='ATTR'
if [ "${UDEVAPP:0:1}" != '/' ]; then
        UDEVAPP=`which udevinfo 2>/dev/null`;
        UDEVPARAM='SYSFS'
fi
if [ "${UDEVAPP:0:1}" != '/' ]; then
        echo "# Nincs a PATH-ban sem 'udevadm', sem 'udevinfo' parancs."
        exit 1
fi
echo "# Hasznalt udev parancs: $UDEVAPP"
echo
echo "# Changers"
for dev in `ls -r /dev/IBMchanger*[^n]`; do
        devi=`echo $dev | sed 's#/dev/##g'`
        if [[ "$UDEVAPP" =~ "udevadm" ]]; then
                SERIAL=`udevadm info --attribute-walk --name $dev | grep 'ATTR.serial_num.' | grep -o '"[0-9A-F]*"' | sed 's/"//g'`
        else
#               DPATH=`udevinfo -q path -n $dev 2>/dev/null`
                DPATH="/class/lin_tape/$devi"
#               if [ "${DPATH:0:1}" != '/' ]; then continue; fi
                SERIAL=`udevinfo -a -p $DPATH | grep 'serial_num.' | grep -o '"[0-9A-F]*"' | sed 's/"//g'`
                if [ ${#SERIAL} -lt 6 ]; then continue; fi
        fi
        echo "KERNEL==\"IBMchanger*[0-9]\", ${UDEVPARAM}{serial_num}==\"$SERIAL\", OWNER=\"$tsm_inst_user\", MODE=\"0666\", SYMLINK=\"lin_tape/${devi}\""
done
echo
echo "# Tapes"
for dev in `ls /dev/IBMtape*[^n]`; do
        devi=`echo $dev | sed 's#/dev/##g'`
        if [[ "$UDEVAPP" =~ "udevadm" ]]; then
                SERIAL=`udevadm info --attribute-walk --name $dev | grep 'ATTR.serial_num.' | grep -o '"[0-9A-F]*"' | sed 's/"//g'`
                WW_PORT=`udevadm info --attribute-walk --name $dev | grep 'ATTR.ww_port_name.' | grep -o '"[0-9A-Fx]*"' | sed 's/"//g'`
        else
#               DPATH=`udevinfo -q path -n $dev 2>/dev/null`
                DPATH="/class/lin_tape/$devi"
#               if [ "${DPATH:0:1}" != '/' ]; then continue; fi
                SERIAL=`udevinfo -a -p $DPATH | grep 'serial_num' | grep -o '"[0-9A-F]*"' | sed 's/"//g'`
                if [ ${#SERIAL} -lt 6 ]; then continue; fi
                WW_PORT=`udevinfo -a -p $DPATH | grep 'ww_port_name' | grep -o '"[0-9A-Fx]*"' | sed 's/"//g'`
        fi
        echo "KERNEL==\"IBMtape*[0-9]\", ATTR{ww_port_name}==\"$WW_PORT\", ${UDEVPARAM}{serial_num}==\"$SERIAL\", OWNER=\"$tsm_inst_user\", MODE=\"0666\", SYMLINK=\"lin_tape/${devi}\""
done
shell/device_management/lnx_lin_tape_rules_conf_generate.txt · Utolsó módosítás: 2019/10/25 14:58 szerkesztette: admin
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0