Files
unraid-corefreq/corefreq.plg
2024-01-28 22:49:47 +01:00

299 lines
9.8 KiB
XML

<?xml version='1.0' standalone='yes'?>
<!DOCTYPE PLUGIN [
<!ENTITY name "CoreFreq">
<!ENTITY author "ich777">
<!ENTITY version "2024.01.28">
<!ENTITY md5 "2172c65c5dff54fa94f0c452e15c226d">
<!ENTITY launch "Settings/corefreq">
<!ENTITY gitURL "https://raw.githubusercontent.com/&author;/unraid-corefreq/master">
<!ENTITY pluginURL "&gitURL;/corefreq.plg">
<!ENTITY plugin "/boot/config/plugins/corefreq">
<!ENTITY emhttp "/usr/local/emhttp/plugins/CoreFreq">
<!ENTITY packages "&plugin;/packages">
]>
<PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;" min="6.9.2" support="https://forums.unraid.net/topic/109314-plugin-corefreq/">
<CHANGES>
###2024.01.28
- Update icon and logo
###2023.08.10
- Corrected typo in examples
###2023.08.09
- Added Module option page and description how to make settings persistent
###2023.01.26
- Fixed not downloading newer packages on boot
- Fixed plugin installation error when there is no active internet connection on boot
###2022.07.21
- Save md5 in packages directory
- Cleanup
###2022.04.11
- Added Plugin Update Helper when up-/downgrading unRAID version
###2022.04.01
- Bugfix, remove package on plugin removal
###2022.02.18
- Created plugin page
- Autostart from CoreFreq must be now enabled on plugin page
###2021.07.13
- Error showing up on boot in terminal fixed
###2021.06.16
- Search for latest CoreFreq version on boot and update it if a newer version is found
###2021.05.26
- Initial release
</CHANGES>
<FILE Run="/bin/bash">
<INLINE>
rm -f $(ls &plugin;/&name;*.txz 2>/dev/null|grep -v '&version;')
</INLINE>
</FILE>
<FILE Name="&plugin;/&name;-&version;.txz" Run="upgradepkg --install-new">
<URL>&gitURL;/packages/&name;-&version;.txz</URL>
<MD5>&md5;</MD5>
</FILE>
<FILE Name="&emhttp;/README.md">
<INLINE>
**CoreFreq**
CoreFreq is a CPU low level monitoring software designed for x86_64-Processors. You can show Package and Core temps, Hot sensor, Vcore, RAM,...
You can also toggle SpeedStep, Clock modulation, Turbo boost, C-States demotion, C1E,...
It has also a built in stress test and much, much more.
Visit the plugin page after installing and follow the instructions.
Open up a unRAID Terminal and type in 'corefreq-cli' (without quotes), hit "F2" or "SPACE" to open up the menu inside CoreFreq.
Please note that not every combination of CPU and motherboard is supported!
Intel Systems: It is recommended that you append 'nmi_watchdog=0' (without qutoes) for better accuracy to your syslinux configuration.
You can get more details here: https://github.com/cyring/CoreFreq
</INLINE>
</FILE>
<FILE Run="/bin/bash">
<INLINE>
download() {
# Download CoreFreq
if wget -q -nc --show-progress --progress=bar:force:noscroll -O "&packages;/${KERNEL_V%%-*}/${LAT_PACKAGE}" "${DL_URL}/${LAT_PACKAGE}" ; then
wget -q -nc --show-progress --progress=bar:force:noscroll -O "&packages;/${KERNEL_V%%-*}/${LAT_PACKAGE}.md5" "${DL_URL}/${LAT_PACKAGE}.md5"
if [ "$(md5sum &packages;/${KERNEL_V%%-*}/${LAT_PACKAGE} | awk '{print $1}')" != "$(cat &packages;/${KERNEL_V%%-*}/${LAT_PACKAGE}.md5 | awk '{print $1}')" ]; then
echo
echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------"
echo "--------------------------------CHECKSUM ERROR!---------------------------------"
rm -rf &plugin; &emhttp;
exit 1
fi
echo
echo "--------------Successfully downloaded CoreFreq, please wait...!----------------"
else
echo
echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR-----"
echo "--------------------------Can't download CoreFreq------------------------------"
rm -rf &plugin; &emhttp;
exit 1
fi
}
check() {
if ! ls -1 &packages;/${KERNEL_V%%-*}/ | grep -q "${LAT_PACKAGE}" ; then
echo
echo "----------------Downloading CoreFreq v$(echo $LAT_PACKAGE | cut -d '-' -f2), please wait...!---------------"
echo "----------This could take some time, please don't close this window!----------"
download
else
echo
echo "----------------------CoreFreq v$(echo $LAT_PACKAGE | cut -d '-' -f2) found locally!-----------------------"
fi
}
get_version() {
LAT_PACKAGE="$(wget -qO- https://api.github.com/repos/ich777/unraid-corefreq/releases/tags/${KERNEL_V} | jq -r '.assets[].name' | grep "${PACKAGE}" | grep -E -v '\.md5$' | sort -V | tail -1)"
}
install() {
# Install CoreFreq and depmod
/sbin/installpkg "&packages;/${KERNEL_V%%-*}/${PACKAGE}*.txz"
/sbin/depmod -a
}
load_module() {
# Load CoreFreq module
/sbin/modprobe corefreqk
}
patch() {
# Patching files and creating necessary direcotries/symlinks
if [ ! -d /root/.config/CoreFreq ]; then
mkdir -p /root/.config/CoreFreq
fi
ln -s &plugin;/corefreq.cfg /root/.config/CoreFreq/corefreq.cfg
}
start_daemon() {
# Start CoreFreq Daemon
echo "/usr/bin/corefreqd" | at now &gt; /dev/null 2&gt;&amp;1
}
# Determine CPU manufacturer
VENDOR="$(lscpu | awk '/Vendor ID/{print $3}' | head -1)"
if [ "${VENDOR}" == "GenuineIntel" ]; then
VENDOR="INTEL"
elif [ "${VENDOR}" == "AuthenticAMD" ]; then
VENDOR="AMD"
else
echo "---Unknown CPU vendor: ${VENDOR}, only Intel and AMD are supported!---"
rm -rf &plugin; &emhttp;
exit 1
fi
# Define Variables
KERNEL_V="$(uname -r)"
PACKAGE="corefreq_${VENDOR}"
DL_URL="https://github.com/ich777/unraid-corefreq/releases/download/$KERNEL_V"
if [ ! -d "&packages;/${KERNEL_V%%-*}" ]; then
mkdir -p "&packages;/${KERNEL_V%%-*}"
CUR_V=""
else
CUR_V="$(ls -p &packages;/${KERNEL_V%%-*} 2&gt;/dev/null | grep -E -v '\.md5' | sort -V | tail -1)"
fi
# Create settings file if not found
if [ ! -f "&plugin;/settings.cfg" ]; then
echo 'autostart_corefreq=false
module_tested=false' > "&plugin;/settings.cfg"
fi
# Check if Autostart is enabled
PLG_AUTOSTART="$(cat &plugin;/settings.cfg | grep "autostart_corefreq=" | cut -d '=' -f2)"
#Check if version where fetched correctly
if [ -z "$CUR_V" ]; then
get_version
if [ -z "$LAT_PACKAGE" ]; then
echo
echo "------ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR--------"
echo "---Can't get latest CoreFreq version and found no local package!---"
echo
rm -rf &plugin; &emhttp;
exit 1
fi
else
LAT_PACKAGE="${CUR_V}"
fi
#Check for old packages
rm -rf $(ls -d &packages;/* | grep -v "${KERNEL_V%%-*}")
rm -rf $(find &packages;/${KERNEL_V%%-*}/ -type f -maxdepth 1 | grep -v "${LAT_PACKAGE}")
#Check if CoreFreq is on the latest version and already downloaded
check
if ! modinfo corefreqk -0 >/dev/null 2>&amp;1 ; then
echo
echo "------------------Installing CoreFreq v$(echo $LAT_PACKAGE | cut -d '-' -f2), please wait...!----------------"
install >/dev/null
echo
fi
if [ "${PLG_AUTOSTART}" == "true" ]; then
load_module >/dev/null
else
echo
echo "-----------Autostart from CoreFreq disabled! Please see Plugin page!------------"
echo
fi
if [ "${PLG_AUTOSTART}" == "true" ]; then
if [ ! -z "$(pidof corefreqd)" ]; then
echo
echo "--------------Nothing to do, CoreFreq Daemon is already started!--------------"
echo
else
echo
patch >/dev/null
echo "-------------------Starting CoreFreq Daemon, please wait...!------------------"
start_daemon >/dev/null
echo
fi
fi
echo
echo "----------------Installation of CoreFreq v$(echo $LAT_PACKAGE | cut -d '-' -f2) successful!------------------"
echo
#Check if Plugin Update Helper is downloaded and up-to-date
if [ ! -f &plugin;/plugin_update_helper ]; then
wget -q -T 5 -O &plugin;/plugin_update_helper "https://raw.githubusercontent.com/ich777/unraid-plugin_update_helper/master/plugin_update_helper"
else
CUR_V="$(grep -E "Plugin-Update-Helper version:" &plugin;/plugin_update_helper | awk '{print $4}')"
if [ ! -s /tmp/update-helper ]; then
echo "$(wget -T5 -qO- https://raw.githubusercontent.com/ich777/unraid-plugin_update_helper/master/plugin_update_helper | grep -E "Plugin-Update-Helper version:" | awk '{print $4}')" > /tmp/update-helper
AVAIL_V="$(cat /tmp/update-helper)"
else
AVAIL_V="$(cat /tmp/update-helper)"
fi
if [ ! -z "$AVAIL_V" ]; then
COMPARE="$(sort -V &lt;(echo -e "${AVAIL_V}\n$CUR_V") | tail -1)"
if [ "$CUR_V" != "$COMPARE" ]; then
wget -q -T 5 -O &plugin;/plugin_update_helper "https://raw.githubusercontent.com/ich777/unraid-plugin_update_helper/master/plugin_update_helper"
fi
fi
fi
#Check if Plugin Update Helper is installed and up to date
if [ ! -f /usr/bin/plugin_update_helper ]; then
cp &plugin;/plugin_update_helper /usr/bin/plugin_update_helper
chmod +x /usr/bin/plugin_update_helper
else
PLUGIN_V="$(grep -E "Plugin-Update-Helper version:" &plugin;/plugin_update_helper | awk '{print $4}')"
INST_V="$(grep -E "Plugin-Update-Helper version:" /usr/bin/plugin_update_helper | awk '{print $4}')"
COMPARE="$(sort -V &lt;(echo -e "${PLUGIN_V}\n$INST_V") | tail -1)"
if [ "$INST_V" != "$COMPARE" ]; then
kill $(ps aux | grep -E "inotifywait -q /boot/changes.txt -e move_self,delete_self" | grep -v "grep -E inotifywait" | awk '{print $2}') 2>/dev/null
sleep 1
cp &plugin;/plugin_update_helper /usr/bin/plugin_update_helper
chmod +x /usr/bin/plugin_update_helper
fi
fi
#Start Plugin Update Helper
if [ -z "$(ps aux | grep -E "inotifywait -q /boot/changes.txt -e move_self,delete_self" | grep -v "grep -E inotifywait" | awk '{print $2}')" ]; then
echo "/usr/bin/plugin_update_helper" | at now &gt; /dev/null 2&gt;&amp;1
fi
</INLINE>
</FILE>
<FILE Run="/bin/bash" Method="remove">
<INLINE>
echo "------------------------------------"
echo "-------Uninstalling CoreFreq--------"
echo "------------------------------------"
# Remove plugin related files
kill $(pidof corefreqd)
removepkg &name;-&version;
rm -rf &emhttp;
rm -rf &plugin;
echo
echo "------------------------------------------------------------------------"
echo "-----------CoreFreq uninstalled, please reboot your server!-------------"
echo "------------------------------------------------------------------------"
echo
</INLINE>
</FILE>
</PLUGIN>