Inital Commit
All checks were successful
UGREEN NAS / UGREEN NAS [amd64] (push) Successful in 26s

This commit is contained in:
Cantibra
2025-10-26 21:11:06 +01:00
commit c93c7b0784
31 changed files with 2629 additions and 0 deletions

51
root/usr/sbin/ugreen-led-init Executable file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env bash
###
#
# Options Section
#
###
set -u
set -o pipefail
###
#
# Function Section
#
###
function load_module () {
MODULE="${1}"
if ! /usr/sbin/lsmod | /usr/bin/grep --quiet "${MODULE}"; then
/usr/sbin/modprobe "${MODULE}"
fi
}
###
#
# Runtime Environment
#
###
load_module 'i2c_dev'
load_module 'led_ugreen'
I2C_DEV=$(/usr/sbin/i2cdetect -l | /usr/bin/grep 'SMBus I801 adapter' | grep --perl-regexp --only-matching 'i2c-\d+')
if [[ -n "${I2C_DEV}" ]]; then
DEV_PATH="/sys/bus/i2c/devices/$I2C_DEV/${I2C_DEV/i2c-/}-003a"
if [[ -d "${DEV_PATH}" ]]; then
DEV_NAME=$(/usr/bin/cat "${DEV_PATH}/name")
fi
if [[ ! -d "${DEV_PATH}" ]]; then
/usr/bin/echo 'led-ugreen 0x3a' > "/sys/bus/i2c/devices/${I2C_DEV}/new_device"
elif [[ "${DEV_NAME}" != 'led-ugreen' ]]; then
exit 1
fi
else
exit 1
fi