Files
unraid-iscsi/iscsi.plg
2021-09-17 10:57:17 +02:00

223 lines
7.2 KiB
XML

<?xml version='1.0' standalone='yes'?>
<!DOCTYPE PLUGIN [
<!ENTITY name "iscsi">
<!ENTITY author "ich777">
<!ENTITY version "2021.09.17">
<!ENTITY launch "Settings/iscsi_main">
<!ENTITY gitURL "https://github.com/&author;/unraid-&name;/raw/master">
<!ENTITY pluginURL "&gitURL;/&name;.plg">
<!ENTITY md5 "54bef526d2c29528288c632eb3457789">
<!ENTITY plugin "/boot/config/plugins/&name;">
<!ENTITY emhttp "/usr/local/emhttp/plugins/&name;">
]>
<PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;" min="6.9.0-beta31">
<CHANGES>
###2021.09.17
- Added deprecation message, please use this plugin: https://github.com/SimonFair/unraid.iSCSI/ instead! You find it also in the CA App.
###2021.03.25
- Added wait for network and timout
###2021.01.04
- Fixed permission issues
- Corrected a typos
###2021.01.04
- Fixed a bug where the buttons on the iSCSI Volumes and ACL page are not displayed on Chrome, Edge,...
###2020.12.14
- Fixed bug of disappearing fileIO targets on start/restart of Unraid
- Corrected/added messages/description
###2020.12.10
- Fixed removal of empty downloads
###2020.11.30
- Added save button
- Corrected bug on main page
###2020.11.09
- Corrected bug where plugin configuration page doesn't show up on Unraid version 6.9.0beta33
###2020.10.28
- Added basic GUI for creation/deletion of IQNs,FileIO/Block Volumes, LUNs, ACL's
###2020.10.27
- Initial release
</CHANGES>
<FILE Run="/bin/bash">
<INLINE>
rm -f $(ls /boot/config/plugins/&name;/&name;*.txz 2>/dev/null|grep -v '&version;')
</INLINE>
</FILE>
<FILE Name="/boot/config/plugins/&name;/&name;-&version;.txz" Run="upgradepkg --install-new">
<URL>&gitURL;/packages/&name;-&version;.txz</URL>
<MD5>&md5;</MD5>
</FILE>
<FILE Name="&emhttp;/README.md">
<INLINE>
**iSCSI Target**
This Plugin adds iSCSI Target to Unraid, the GUI is currently in beta.
</INLINE>
</FILE>
<FILE Run="/bin/bash">
<INLINE>
KERNEL_V="$(uname -r)"
PACKAGE="iscsi"
DL_URL="https://github.com/ich777/unraid-plugins-repo/releases/download/$KERNEL_V"
#Wait for Network and timeout after 30 seconds
HOST="8.8.8.8"
for i in {1..10}; do
ping -c1 $HOST &amp;> /dev/null &amp;&amp; break;
done
if [ ! -d "&plugin;/packages/${KERNEL_V%%-*}" ]; then
mkdir -p "&plugin;/packages/${KERNEL_V%%-*}"
fi
#Check for old packages
rm -rf $(ls -d &plugin;/packages/* | grep -v "${KERNEL_V%%-*}")
download() {
#Download iSCSI Target
if wget -q -nc --show-progress --progress=bar:force:noscroll -O "&plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz" "${DL_URL}/${PACKAGE}-1.txz" ; then
if [ "$(md5sum "&plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz" | cut -d ' ' -f1)" != "$(wget -qO- "${DL_URL}/${PACKAGE}-1.txz.md5" | cut -d ' ' -f1)" ]; then
if [ -d &plugin; ]; then
rm -rf &plugin;
fi
echo
echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------"
echo "--------------------------------CHECKSUM ERROR!---------------------------------"
exit 1
fi
echo
echo "-------------Successfully downloaded iSCSI Target, please wait...!-------------"
else
echo
echo "----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------"
echo "------------------------Can't download iSCSI Target----------------------------"
exit 1
fi
}
check() {
if [ ! -f "&plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz" ]; then
echo
echo "+=============================================================================="
echo "| WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING"
echo "|"
echo "| Don't close this window with the red 'X' in the top right corner until the 'DONE' button is displayed!"
echo "|"
echo "| WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING"
echo "+=============================================================================="
echo
echo "------------------Downloading iSCSI Target, please wait...!--------------------"
echo "-----------This could take some time, please don't close this window!----------"
download
elif [ ! -s "&plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz" ]; then
rm -rf &plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz
echo
echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR-----"
echo "-----Download is empty please contact the developer of this plugin if the------"
echo "-------plugin has been already built against the current Kernel version--------"
exit 1
else
echo
echo "--------------------------iSCSI Target found locally!--------------------------"
fi
}
install() {
#Install iSCSI Target
/sbin/installpkg "&plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz"
}
patch() {
#Patching files and creating necessary direcotries/symlinks
if [ ! -d /etc/target ]; then
mkdir -p /etc/target
fi
if [ ! -d /root/.targetcli ]; then
mkdir -p /root/.targetcli
fi
if [ ! -d /boot/config/iscsi/.targetcli ]; then
mkdir -p /boot/config/iscsi/.targetcli
fi
ln -s /boot/config/iscsi/saveconfig.json /etc/target/saveconfig.json
ln -s /boot/config/iscsi/.targetcli/prefs.bin /root/.targetcli/prefs.bin
#Load/unload iSCSI Target on Array start/stop
echo "
# Load iSCSI configuration
echo 'Loading iSCSI configuration'
targetcli restoreconfig &amp;" >> /usr/local/emhttp/plugins/dynamix/event/disks_mounted/local_syslog_start
echo "
# Unload iSCSI configuration
echo 'Unloading iSCSI configuration'
targetcli clearconfig confirm=True &amp;" >> /usr/local/emhttp/plugins/dynamix/event/unmounting_disks/local_syslog_stop
}
start() {
#Starting Targetcli-FB
echo
echo "---------------------Starting iSCSI Target, please wait...!--------------------"
targetcli restoreconfig
}
#Check if iSCSI Target is allready downloaded
check
install > /dev/null
patch
if [ ! -z "$(pidof emhttpd)" ]; then
start
fi
echo "+-----------------------------------------------------------------------------------"
echo "| ATTENTION - ATTENTION - ATTENTION - ATTENTION - ATTENTION - ATTENTION - ATTENTION"
echo "|"
echo "| This plugin is deprecated in favour to: https://github.com/SimonFair/unraid.iSCSI/"
echo "|"
echo "| ATTENTION - ATTENTION - ATTENTION - ATTENTION - ATTENTION - ATTENTION - ATTENTION"
echo "+-----------------------------------------------------------------------------------"
echo
echo "-------------------Installation of iSCSI Target successful---------------------"
echo
</INLINE>
</FILE>
<FILE Run="/bin/bash" Method="remove">
<INLINE>
echo "---------------------------------------"
echo "-------Uninstalling iSCSI Target-------"
echo "---------------------------------------"
# Remove plugin related files
removepkg &name;-&version;
rm -rf /usr/local/emhttp/plugins/&name;
rm -rf &plugin;
#Remove load/unload iSCSI Target on Array start/stop
sed -i '/\n/!N;/\n.*# Load iSCSI configuration/{$d;N;N;d};P;D' /usr/local/emhttp/plugins/dynamix/event/disks_mounted/local_syslog_start
sed -i '/\n/!N;/\n.*# Unload iSCSI configuration/{$d;N;N;d};P;D' /usr/local/emhttp/plugins/dynamix/event/unmounting_disks/local_syslog_stop
echo
echo "----------------------------------------------------------------------------"
echo "-----------iSCSI Target uninstalled, please reboot your server!-------------"
echo "----------------------------------------------------------------------------"
echo
</INLINE>
</FILE>
</PLUGIN>