Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Adapted from the debian package
- parse_iscsi_ops () {
- [ -e /etc/iscsi/iscsi.initramfs ] && . /etc/iscsi/iscsi.initramfs
- for x in $(cat /proc/cmdline); do
- case ${x} in
- iscsi_auto)
- ISCSI_AUTO=true
- ;;
- iscsi_initiator=*)
- ISCSI_INITIATOR="${x#iscsi_initiator=}"
- ;;
- iscsi_target_name=*)
- ISCSI_TARGET_NAME="${x#iscsi_target_name=}"
- ;;
- iscsi_target_ip=*)
- ISCSI_TARGET_IP="${x#iscsi_target_ip=}"
- ;;
- iscsi_target_port=*)
- ISCSI_TARGET_PORT="${x#iscsi_target_port=}"
- ;;
- iscsi_target_group=*)
- ISCSI_TARGET_GROUP="${x#iscsi_target_group=}"
- ;;
- iscsi_username=*)
- ISCSI_USERNAME="${x#iscsi_username=}"
- ;;
- iscsi_password=*)
- ISCSI_PASSWORD="${x#iscsi_password=}"
- ;;
- iscsi_in_username=*)
- ISCSI_IN_USERNAME="${x#iscsi_in_username=}"
- ;;
- iscsi_in_password=*)
- ISCSI_IN_PASSWORD="${x#iscsi_in_password=}"
- ;;
- esac
- done
- }
- do_iscsi_login () {
- modprobe crc32c
- modprobe iscsi_tcp
- if [ -z $ISCSI_AUTO ]; then
- if [ -z $ISCSI_INITIATOR ]; then
- . /etc/iscsi/initiatorname.iscsi
- ISCSI_INITIATOR=$InitiatorName
- fi
- [ -z $ISCSI_TARGET_PORT ] && ISCSI_TARGET_PORT=3260
- [ -z $ISCSI_TARGET_GROUP ] && ISCSI_TARGET_GROUP=1
- for i in $ISCSI_TARGET_IP; do
- iscsistart -i $ISCSI_INITIATOR -t $ISCSI_TARGET_NAME \
- -g $ISCSI_TARGET_GROUP -p $ISCSI_TARGET_PORT \
- -a $i ${ISCSI_USERNAME:+-u "$ISCSI_USERNAME"} \
- ${ISCSI_PASSWORD:+-w "$ISCSI_PASSWORD"} \
- ${ISCSI_IN_USERNAME:+-U "$ISCSI_IN_USERNAME"} \
- ${ISCSI_IN_PASSWORD:+-W "$ISCSI_IN_PASSWORD"}
- done
- else
- modprobe iscsi_ibft
- iscsistart -N
- iscsistart -b
- fi
- }
- run_hook() {
- parse_iscsi_ops
- if [ $ISCSI_AUTO ]; then
- msg "Arch kernel does not compile iscsi_ibft module"
- msg "The auto_detection will not work (see FS#30110)"
- elif ( [ -z $ISCSI_TARGET_NAME ] || [ -z $ISCSI_TARGET_IP ] ) ; then
- msg "Not enough data to connect an iscsi rootfs"
- else
- do_iscsi_login
- udevadm settle
- fi
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement