2024-06-08 21:22:27 +07:00
|
|
|
|
#!/usr/bin/env ash
|
2024-05-05 06:16:56 +07:00
|
|
|
|
#
|
|
|
|
|
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium> and Ing <https://github.com/wjz304>
|
|
|
|
|
#
|
2024-05-14 22:12:48 +07:00
|
|
|
|
# From:https://github.com/007revad/Synology_enable_M2_volume
|
2024-05-05 06:16:56 +07:00
|
|
|
|
# From: https://github.com/PeterSuh-Q3/tcrp-addons/blob/main/nvmevolume-onthefly/src/install.sh
|
|
|
|
|
#
|
|
|
|
|
|
2024-05-14 22:12:48 +07:00
|
|
|
|
if grep -qw "/addons/nvmesystem.sh" "/addons/addons.sh"; then
|
|
|
|
|
echo "nvmevolume is not required if nvmesystem exists!"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
2024-05-05 06:16:56 +07:00
|
|
|
|
if [ "${1}" = "late" ]; then
|
|
|
|
|
echo "Installing addon nvmevolume - ${1}"
|
|
|
|
|
mkdir -p "/tmpRoot/usr/arc/addons/"
|
2024-11-09 01:34:54 +07:00
|
|
|
|
cp -pf "${0}" "/tmpRoot/usr/arc/addons/"
|
2024-05-05 06:16:56 +07:00
|
|
|
|
|
|
|
|
|
SO_FILE="/tmpRoot/usr/lib/libhwcontrol.so.1"
|
2024-11-09 01:34:54 +07:00
|
|
|
|
[ ! -f "${SO_FILE}.bak" ] && cp -pf "${SO_FILE}" "${SO_FILE}.bak"
|
2024-05-05 06:16:56 +07:00
|
|
|
|
|
2024-11-20 16:51:12 +07:00
|
|
|
|
cp -pf "${SO_FILE}" "${SO_FILE}.tmp"
|
2024-11-08 01:15:46 +07:00
|
|
|
|
xxd -c $(xxd -p "${SO_FILE}.tmp" 2>/dev/null | wc -c) -p "${SO_FILE}.tmp" 2>/dev/null |
|
2024-11-20 16:51:12 +07:00
|
|
|
|
sed "s/803e00b801000000752.488b/803e00b8010000009090488b/" |
|
|
|
|
|
xxd -r -p >"${SO_FILE}" 2>/dev/null
|
2024-05-05 06:16:56 +07:00
|
|
|
|
rm -f "${SO_FILE}.tmp"
|
2024-11-20 16:51:12 +07:00
|
|
|
|
|
|
|
|
|
# Create storage pool page without RAID type.
|
|
|
|
|
cp -vpf /usr/bin/nvmevolume.sh /tmpRoot/usr/bin/nvmevolume.sh
|
|
|
|
|
|
|
|
|
|
[ ! -f "/tmpRoot/usr/bin/gzip" ] && cp -vpf /usr/bin/gzip /tmpRoot/usr/bin/gzip
|
|
|
|
|
|
|
|
|
|
mkdir -p "/tmpRoot/usr/lib/systemd/system"
|
|
|
|
|
DEST="/tmpRoot/usr/lib/systemd/system/nvmevolume.service"
|
|
|
|
|
{
|
|
|
|
|
echo "[Unit]"
|
|
|
|
|
echo "Description=Modify storage panel(nvmevolume)"
|
|
|
|
|
echo "Wants=smpkg-custom-install.service pkgctl-StorageManager.service"
|
|
|
|
|
echo "After=smpkg-custom-install.service"
|
|
|
|
|
echo "After=storagepanel.service" # storagepanel
|
|
|
|
|
echo "After=nvmesystem.service" # nvmesystem
|
|
|
|
|
echo
|
|
|
|
|
echo "[Service]"
|
|
|
|
|
echo "Type=oneshot"
|
|
|
|
|
echo "RemainAfterExit=yes"
|
|
|
|
|
echo "ExecStart=/usr/bin/nvmevolume.sh"
|
|
|
|
|
echo
|
|
|
|
|
echo "[Install]"
|
|
|
|
|
echo "WantedBy=multi-user.target"
|
|
|
|
|
} >"${DEST}"
|
2024-05-05 06:16:56 +07:00
|
|
|
|
elif [ "${1}" = "uninstall" ]; then
|
|
|
|
|
echo "Installing addon nvmevolume - ${1}"
|
|
|
|
|
|
|
|
|
|
SO_FILE="/tmpRoot/usr/lib/libhwcontrol.so.1"
|
|
|
|
|
[ -f "${SO_FILE}.bak" ] && mv -f "${SO_FILE}.bak" "${SO_FILE}"
|
2024-11-20 16:51:12 +07:00
|
|
|
|
|
|
|
|
|
rm -f "/tmpRoot/usr/lib/systemd/system/multi-user.target.wants/nvmevolume.service"
|
|
|
|
|
rm -f "/tmpRoot/usr/lib/systemd/system/nvmevolume.service"
|
|
|
|
|
|
|
|
|
|
# rm -f /tmpRoot/usr/bin/gzip
|
|
|
|
|
[ ! -f "/tmpRoot/usr/arc/revert.sh" ] && echo '#!/usr/bin/env bash' >/tmpRoot/usr/arc/revert.sh && chmod +x /tmpRoot/usr/arc/revert.sh
|
|
|
|
|
echo "/usr/bin/nvmevolume.sh -r" >>/tmpRoot/usr/arc/revert.sh
|
|
|
|
|
echo "rm -f /usr/bin/nvmevolume.sh" >>/tmpRoot/usr/arc/revert.sh
|
2024-05-19 21:38:25 +07:00
|
|
|
|
fi
|