Skip to content

Commit

Permalink
Add stop-alua to scst_util.sh and call before stopping middlewared
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeagherix committed Sep 17, 2024
1 parent 961b26d commit 600a709
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
16 changes: 16 additions & 0 deletions debian/debian/ix-reboot.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Exec TrueNAS reboot tasks

After=network.target middlewared.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=true
ExecStop=/usr/local/bin/scst_util.sh stop-alua
StandardOutput=null
StandardError=null
TimeoutStopSec=0

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions debian/debian/ix-shutdown.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ After=network.target middlewared.service
Type=oneshot
RemainAfterExit=yes
ExecStart=true
ExecStop=/usr/local/bin/scst_util.sh stop-alua
ExecStop=midclt call core.event_send system.shutdown ADDED
ExecStop=midclt call --job initshutdownscript.execute_init_tasks SHUTDOWN
StandardOutput=null
Expand Down
1 change: 1 addition & 0 deletions debian/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ override_dh_installsystemd:
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-netif
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-postinit
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-preinit
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-reboot
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-reporting
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-shutdown
dh_installsystemd --no-start -r --no-restart-after-upgrade --name=ix-ssh-keys
Expand Down
21 changes: 20 additions & 1 deletion src/freenas/usr/local/bin/scst_util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,32 @@ force_close() {
wait
}

stop_alua() {
shopt -s nullglob

# Disable iSCSI
if [ -f /sys/kernel/scst_tgt/targets/iscsi/enabled ]; then
echo 0 > /sys/kernel/scst_tgt/targets/iscsi/enabled
fi

# Turn off any cluster_mode in parallel
for cm in /sys/kernel/scst_tgt/devices/*/cluster_mode ; do
echo 0 > "$cm" &
done
wait
}

case "$1" in
force-close)
force_close
rc=$?
;;
stop-alua)
stop_alua
rc=$?
;;
*)
echo "Usage: $0 {force-close}"
echo "Usage: $0 {force-close|stop-alua}"
exit 2
;;
esac
Expand Down

0 comments on commit 600a709

Please sign in to comment.