tree: cleanup

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-07-26 16:53:04 +02:00
parent da350e738a
commit dc99ea4de0
10 changed files with 66 additions and 133 deletions

View File

@ -14,22 +14,26 @@ if [ "${1}" = "late" ]; then
mkdir -p "/tmpRoot/usr/lib/systemd/system"
DEST="/tmpRoot/usr/lib/systemd/system/amepatch.service"
cat > ${DEST} <<EOF
cat << EOF > ${DEST}
[Unit]
Description=addon amepatch
DefaultDependencies=no
IgnoreOnIsolate=true
After=multi-user.target
[Service]
Type=simple
Restart=on-failure
RestartSec=5s
RestartSec=10s
RemainAfterExit=yes
ExecStartPre=/usr/bin/amepatch.sh
ExecStart=/usr/syno/bin/synopkg restart CodecPack
ExecStartPost=/usr/syno/bin/systemctl stop amepatch
[Install]
WantedBy=multi-user.target
[X-Synology]
Author=Virtualization Team
EOF
mkdir -vp /tmpRoot/usr/lib/systemd/system/multi-user.target.wants
ln -vsf /usr/lib/systemd/system/amepatch.service /tmpRoot/usr/lib/systemd/system/multi-user.target.wants/amepatch.service

View File

@ -15,20 +15,26 @@ if [ "${1}" = "late" ]; then
mkdir -p "/tmpRoot/usr/lib/systemd/system"
DEST="/tmpRoot/usr/lib/systemd/system/codecpatch.service"
echo "[Unit]" >${DEST}
echo "Description=addon codecpatch" >>${DEST}
echo "After=multi-user.target" >>${DEST}
echo >>${DEST}
echo "[Service]" >>${DEST}
echo "Type=oneshot" >>${DEST}
echo "RemainAfterExit=yes" >>${DEST}
echo "ExecStart=/usr/bin/codecpatch.sh" >>${DEST}
echo >>${DEST}
echo "[Install]" >>${DEST}
echo "WantedBy=multi-user.target" >>${DEST}
cat << EOF > ${DEST}
[Unit]
Description=addon codecpatch
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/codecpatch.sh
[Install]
WantedBy=multi-user.target
[X-Synology]
Author=Virtualization Team
EOF
mkdir -vp /tmpRoot/usr/lib/systemd/system/multi-user.target.wants
ln -vsf /usr/lib/systemd/system/codecpatch.service /tmpRoot/usr/lib/systemd/system/multi-user.target.wants/codecpatch.service
fi
elif [ "${1}" = "uninstall" ]; then
echo "Installing addon codecpatch - ${1}"

View File

@ -19,7 +19,7 @@ if [ "${1}" = "late" ]; then
if [ "${2}" = "userspace" ]; then
mkdir -p "/tmpRoot/usr/lib/systemd/system"
DEST="/tmpRoot/usr/lib/systemd/system/cpufreqscaling.service"
cat > ${DEST} <<EOF
cat << EOF > ${DEST}
[Unit]
Description=Enable CPU Freq scaling
DefaultDependencies=no
@ -30,7 +30,7 @@ After=multi-user.target
User=root
Type=simple
Restart=on-failure
RestartSec=30s
RestartSec=10s
ExecStart=/usr/sbin/scaler.sh
[Install]
@ -44,7 +44,7 @@ EOF
else
mkdir -p "/tmpRoot/usr/lib/systemd/system"
DEST="/tmpRoot/usr/lib/systemd/system/cpufreqscaling.service"
cat > ${DEST} <<EOF
cat << EOF > ${DEST}
[Unit]
Description=Enable CPU Freq scaling
DefaultDependencies=no

View File

@ -16,17 +16,22 @@ if [ "${1}" = "late" ]; then
shift
mkdir -p "/tmpRoot/usr/lib/systemd/system"
DEST="/tmpRoot/usr/lib/systemd/system/cpuinfo.service"
echo "[Unit]" >${DEST}
echo "Description=Adds correct CPU Info" >>${DEST}
echo "After=multi-user.target" >>${DEST}
echo >>${DEST}
echo "[Service]" >>${DEST}
echo "Type=oneshot" >>${DEST}
echo "RemainAfterExit=yes" >>${DEST}
echo "ExecStart=/usr/bin/cpuinfo.sh $@" >>${DEST}
echo >>${DEST}
echo "[Install]" >>${DEST}
echo "WantedBy=multi-user.target" >>${DEST}
cat << EOF > ${DEST}
[Unit]
Description=Adds correct CPU Info
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/cpuinfo.sh $@
[Install]
WantedBy=multi-user.target
[X-Synology]
Author=Virtualization Team
EOF
mkdir -vp /tmpRoot/usr/lib/systemd/system/multi-user.target.wants
ln -vsf /usr/lib/systemd/system/cpuinfo.service /tmpRoot/usr/lib/systemd/system/multi-user.target.wants/cpuinfo.service

View File

@ -1,5 +0,0 @@
[brightness]
night_start=22:00
night_end=07:00
day_brightness=255
night_brightness=64

View File

@ -9,28 +9,6 @@
UGREEN_LEDS_CLI="/usr/bin/ugreen_leds_cli"
SMARTCTL="/usr/bin/smartctl"
HDPARM="/usr/bin/hdparm"
CONFIG_FILE="/usr/bin/led.conf"
# Funktion, um den SMART-Status einer Festplatte zu überprüfen
function check_smart_status() {
local device=$1
smartctl -H -n standby $device | grep -q "PASSED"
return $?
}
# Funktion, um den Power-Status einer Festplatte zu überprüfen, ohne sie aufzuwecken
function check_power_status() {
local device=$1
local status=$(hdparm -C $device | grep -oP '(?<=drive state is: ).*')
echo $status
}
# Funktion, um den Load Average-Wert zu ermitteln
function get_load_average() {
load_average=$(uptime | awk -F'[a-z]:' '{print $2}' | awk -F',' '{print $1}' | tr -d '[:space:]' | awk -F'.' '{print $1}')
echo $load_average
}
# Funktion, um zu überprüfen, ob ein Netzwerkinterface verbunden ist
function check_network_interface() {
@ -39,30 +17,15 @@ function check_network_interface() {
return $?
}
# Funktion, um die aktuelle Helligkeit basierend auf der Konfigurationsdatei zu ermitteln
function get_brightness() {
local current_time=$(date +%H:%M)
local night_start=$(grep -Po '(?<=night_start=).*' $CONFIG_FILE)
local night_end=$(grep -Po '(?<=night_end=).*' $CONFIG_FILE)
local day_brightness=$(grep -Po '(?<=day_brightness=).*' $CONFIG_FILE)
local night_brightness=$(grep -Po '(?<=night_brightness=).*' $CONFIG_FILE)
if [[ "$current_time" > "$night_start" || "$current_time" < "$night_end" ]]; then
echo $night_brightness
else
echo $day_brightness
fi
}
if [ "${1}" = "on" ]; then
echo "Enable Ugreen LED"
$UGREEN_LEDS_CLI all -on -color 255 255 255 -brightness 65
elif [ "${1}" = "off" ]; then
echo "Disable Ugreen LED"
$UGREEN_LEDS_CLI all -off
elif [ "${1}" = "nic" ]; then
# Get Brightness
brightness=$(get_brightness)
else
brightness=255
color="0 255 0" # Grün
# NIC Status
interface_up=0
interfaces=($(ls /sys/class/net 2>/dev/null | grep eth))
@ -75,62 +38,19 @@ elif [ "${1}" = "nic" ]; then
done
if [[ $interface_up -eq 1 ]]; then
$UGREEN_LEDS_CLI netdev -on -color 0 255 0 -brightness $brightness > /dev/null 2>&1
$UGREEN_LEDS_CLI netdev -on -color $color -brightness $brightness > /dev/null 2>&1
fi
elif [ "${1}" = "disk" ]; then
# Get Brightness
brightness=$(get_brightness)
# Get Disks
# Disks
devices=($(ls -d /dev/sata*[1-9] 2>/dev/null))
# bootdisk=$(cat /usr/addons/bootdisk)
# Disks Smart Check
for i in "${!devices[@]}"; do
# [ "${devices[$i]}" = "/dev/${bootdisk}" ] && continue
device=${devices[$i]}
disk_number=$((i + 1)) # Disknummer für die LED-Steuerung (disk1, disk2, etc.)
color="0 255 0" # Standardfarbe grün
if check_smart_status $device; then
color="0 255 0" # Grün
else
color="255 0 0" # Rot
fi
power_status=$(check_power_status $device)
case $power_status in
"unknown")
$UGREEN_LEDS_CLI disk$disk_number -on -color $color -brightness $brightness > /dev/null 2>&1
;;
"active/idle")
$UGREEN_LEDS_CLI disk$disk_number -blink 500 500 -color $color -brightness $brightness > /dev/null 2>&1
;;
"standby")
$UGREEN_LEDS_CLI disk$disk_number -breath 1000 1000 -color $color -brightness $brightness > /dev/null 2>&1
;;
*)
$UGREEN_LEDS_CLI disk$disk_number -on -color $color -brightness $brightness > /dev/null 2>&1
;;
esac
$UGREEN_LEDS_CLI disk$disk_number -on -color $color -brightness $brightness > /dev/null 2>&1
done
elif [ "${1}" = "cpu" ]; then
# Get Brightness
brightness=$(get_brightness)
# CPU Load Average
load_average=$(get_load_average)
if [ $load_average -lt 1 ]; then
color="0 255 0" # Grün
elif [ $load_average -lt 2 ]; then
color="127 255 0" # Gelbgrün
elif [ $load_average -lt 3 ]; then
color="255 255 0" # Gelb
elif [ $load_average -lt 4 ]; then
color="255 127 0" # Orange
elif [ $load_average -lt 5 ]; then
color="255 0 0" # Rot
else
color="255 0 0" # Rot (schnelleres Blinken)
fi
# CPU
$UGREEN_LEDS_CLI power -color $color -brightness $brightness > /dev/null 2>&1
fi
exit 0

View File

@ -31,7 +31,7 @@ if [ "${1}" = "late" ]; then
mkdir -p "/tmpRoot/usr/lib/systemd/system"
# All on
DEST="/tmpRoot/usr/lib/systemd/system/ledcontrol.service"
cat > ${DEST} <<'EOF'
cat << EOF > ${DEST}
[Unit]
Description=Ledcontrol for Ugreen
DefaultDependencies=no
@ -40,9 +40,10 @@ After=multi-user.target
[Service]
User=root
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/ledcontrol.sh on
Type=simple
Restart=on-failure
RestartSec=10s
ExecStart=/usr/bin/ledcontrol.sh
[Install]
WantedBy=multi-user.target

View File

@ -17,7 +17,7 @@ if [ "${1}" = "late" ]; then
shift
mkdir -p "/tmpRoot/usr/lib/systemd/system"
DEST="/tmpRoot/usr/lib/systemd/system/storagepanel.service"
cat > ${DEST} <<EOF
cat << EOF > ${DEST}
[Unit]
Description=Modify storage panel
DefaultDependencies=no

View File

@ -12,7 +12,7 @@ if [ "${1}" = "late" ]; then
mkdir -p "/tmpRoot/usr/lib/systemd/system"
DEST="/tmpRoot/usr/lib/systemd/system/surveillancepatch.service"
cat > ${DEST} <<EOF
cat << EOF > ${DEST}
[Unit]
Description=addon surveillancepatch
DefaultDependencies=no
@ -21,8 +21,9 @@ After=multi-user.target
[Service]
User=root
Type=oneshot
RemainAfterExit=yes
Type=simple
Restart=on-failure
RestartSec=10s
ExecStart=/usr/bin/surveillancepatch.sh
[Install]

View File

@ -12,7 +12,7 @@ if [ "${1}" = "late" ]; then
mkdir -p "/tmpRoot/usr/lib/systemd/system"
DEST="/tmpRoot/usr/lib/systemd/system/surveillancepatch.service"
cat > ${DEST} <<EOF
cat << EOF > ${DEST}
[Unit]
Description=addon surveillancepatchn
DefaultDependencies=no
@ -21,8 +21,9 @@ After=multi-user.target
[Service]
User=root
Type=oneshot
RemainAfterExit=yes
Type=simple
Restart=on-failure
RestartSec=10s
ExecStart=/usr/bin/surveillancepatch.sh
[Install]