Skip to content

Commit

Permalink
iscsi: Add new feature
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Chernonog <[email protected]>
  • Loading branch information
Mikhail Chernonog authored and legionus committed Apr 9, 2021
1 parent 8af6cb6 commit d6345c3
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
14 changes: 14 additions & 0 deletions features/iscsi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Feature: iscsi-boot

Feature adds you to perform a diskless system boot using pxe and iSCSI.

## Parameters
- **ISCSI_TARGET_NAME** -- Target name iSCSI, required parameter
- **ISCSI_TARGET_IP** -- Target IP address iSCSI, required parameter
- **ISCSI_TARGET_PORT** -- Target port iSCSI
- **ISCSI_TARGET_LUN** -- Target group tag iSCSI
- **ISCSI_INITIATOR** -- Initiator name iSCSI
- **ISCSI_USERNAME** -- Username for initiator authentication by the target(s)
- **ISCSI_PASSWORD** -- Password for initiator authentication by the target(s)
- **ISCSI_IN_USERNAME** -- Username for target(s) authentication by the initiator
- **ISCSI_IN_PASSWORD** -- Password for target(s) authentication by the initiator
12 changes: 12 additions & 0 deletions features/iscsi/config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ISCSI_MODULES = iscsi-ibft \
iscsi-tcp \
iscsi-boot-sysfs \
iscsi-target-mod \
target-core-mod \
libiscsi \
libiscsi-tcp \
scsi-transport-iscsi \
sd_mod \
sr_mod

ISCSI_DATADIR = $(FEATURESDIR)/iscsi/data
9 changes: 9 additions & 0 deletions features/iscsi/data/etc/initrd/cmdline.d/iscsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
register_parameter string ISCSI_TARGET_NAME
register_parameter string ISCSI_TARGET_IP
register_parameter number ISCSI_TARGET_PORT
register_parameter number ISCSI_TARGET_LUN
register_parameter string ISCSI_INITIATOR
register_parameter string ISCSI_USERNAME
register_parameter string ISCSI_PASSWORD
register_parameter string ISCSI_IN_USERNAME
register_parameter string ISCSI_IN_PASSWORD
41 changes: 41 additions & 0 deletions features/iscsi/data/etc/rc.d/init.d/iscsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: iscsi
# Required-Start: cmdline modules network-up
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: 3 4 5
# Default-Stop:
### END INIT INFO

[ -z "${1-}" ] || [ "$1" = start ] || exit 0

if [ -z "$ISCSI_TARGET_NAME" ] || [ -z "$ISCSI_TARGET_IP" ]; then
exit 0
fi

if [ -z "$ISCSI_INITIATOR" ]; then
if [ ! -f /etc/iscsi/initiatorname.iscsi ]; then
mkdir -p /etc/iscsi
iscsi-gen-initiatorname
fi
. /etc/iscsi/initiatorname.iscsi
ISCSI_INITIATOR="$InitiatorName"
fi

if [ -z "$ISCSI_TARGET_PORT" ]; then
ISCSI_TARGET_PORT=3260
fi

if [ -z "$ISCSI_TARGET_GROUP" ]; then
ISCSI_TARGET_GROUP=1
fi

iscsistart -i "$ISCSI_INITIATOR" -t "$ISCSI_TARGET_NAME" \
-g "$ISCSI_TARGET_GROUP" -a "$ISCSI_TARGET_IP" \
-p "$ISCSI_TARGET_PORT" \
"${ISCSI_USERNAME:+-u "$ISCSI_USERNAME"}" \
"${ISCSI_PASSWORD:+-w "$ISCSI_PASSWORD"}" \
"${ISCSI_IN_USERNAME:+-U "$ISCSI_IN_USERNAME"}" \
"${ISCSI_IN_PASSWORD:+-W "$ISCSI_IN_PASSWORD"}"
5 changes: 5 additions & 0 deletions features/iscsi/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MODULES_LOAD += $(ISCSI_MODULES)

PUT_PROGS += iscsistart iscsi-gen-initiatorname iscsi-iname
PUT_FILES += $(wildcard /etc/iscsi/initiatorname.iscsi)
PUT_FEATURE_DIRS += $(ISCSI_DATADIR)

0 comments on commit d6345c3

Please sign in to comment.