Skip to content

Instantly share code, notes, and snippets.

@robvanoostenrijk
Created January 2, 2026 03:13
Show Gist options
  • Select an option

  • Save robvanoostenrijk/bd7dc9f596e548c0406d15811516884f to your computer and use it in GitHub Desktop.

Select an option

Save robvanoostenrijk/bd7dc9f596e548c0406d15811516884f to your computer and use it in GitHub Desktop.
XikeStor SKS3200-8E2X

Debian systemd script to bring up (re-enable) a port on a XikeStor SKS3200-8E2X switch.

In some cases with SFP+ links and Intel X520, connection does not come up successfully after rebooting the connected machine. This script checks if the connection has come up and resets it from the switch end if required.

#!/bin/bash
HOSTNAME="192.168.10.2"
USERNAME="admin"
PASSWORD="admin"
INTERFACE="enp1s0"
PORT=9
interface_down() {
if [[ $(cat "/sys/class/net/$INTERFACE/operstate") == "up" ]]; then
echo "[i] $INTERFACE is already up"
return 1
else
echo "[i] $INTERFACE down, bringing up"
return 0
fi
}
enable_switch_port() {
COOKIES=$(mktemp -t cookies-XXXXXX)
# Obtain login cookie through /authorize
STATUS=$(curl \
--cookie-jar "${COOKIES}" \
--output /dev/null \
--silent \
--write-out "%{http_code}" \
"http://${HOSTNAME}/authorize?loginusr=$(echo -n ${USERNAME} | md5sum | cut -c1-32)&loginpwd=$(echo -n ${PASSWORD} | md5sum | cut -c1-32)")
if [ "$STATUS" -eq 200 ]; then
echo "[i] Obtained authorization cookie."
else
echo "[!] Authorization failure."
fi
JSON=$(cat <<EOF
{"port_sts":"Enable","port_spd_duplex":"Auto","flow_ctrl":"On","port_num":1,"port_list":["${PORT}"]}
EOF
)
STATUS=$(curl \
--cookie "${COOKIES}" \
--json "${JSON}" \
--output /dev/null \
--silent \
--write-out "%{http_code}" \
"http://${HOSTNAME}/apply_user_port_setting.json")
if [ "$STATUS" -eq 200 ]; then
echo "[i] Port ${PORT} reset."
else
echo "[!] Port reset failed."
fi
rm "${COOKIES}"
}
while interface_down; do
enable_switch_port
sleep 30s
done
[Unit]
Description=XikeStor Enable SFP+ Port
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/xikestor-port.sh
RemainAfterExit=yes
StandardOutput=journal
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment