cleanup scripts: projects/

This commit is contained in:
CvH 2024-07-06 11:09:42 +02:00
parent 67dcda694b
commit 52d0bad764
20 changed files with 183 additions and 183 deletions

View File

@ -5,4 +5,4 @@
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
TEMP="$(cat /sys/class/thermal/thermal_zone0/temp)"
echo "$(( $TEMP / 1000 )) C"
echo "$(($TEMP / 1000)) C"

View File

@ -5,8 +5,8 @@
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
if [ -f /sys/class/thermal/thermal_zone1/temp ]; then
TEMP="$(cat /sys/class/thermal/thermal_zone1/temp)"
TEMP="$(cat /sys/class/thermal/thermal_zone1/temp)"
else
TEMP="$(cat /sys/class/thermal/thermal_zone0/temp)"
TEMP="$(cat /sys/class/thermal/thermal_zone0/temp)"
fi
echo "$(( $TEMP / 1000 )) C"
echo "$(($TEMP / 1000)) C"

View File

@ -5,7 +5,7 @@
# detect legacy kernel installs and abort to prevent upgrades
case $(uname -r) in
3.14*|4.9*)
3.14* | 4.9*)
echo "Updates from Amlogic vendor kernels are not supported!"
sleep 10
exit 1

View File

@ -8,56 +8,56 @@
[ -z "$BOOT_PART" ] && BOOT_PART=$(df "$BOOT_ROOT" | tail -1 | awk {' print $1 '})
# identify the boot device
if [ -z "$BOOT_DISK" ]; then
case $BOOT_PART in
/dev/sd[a-z][0-9]*)
BOOT_DISK=$(echo $BOOT_PART | sed -e "s,[0-9]*,,g")
;;
/dev/mmcblk*)
BOOT_DISK=$(echo $BOOT_PART | sed -e "s,p[0-9]*,,g")
;;
esac
fi
if [ -z "$BOOT_DISK" ]; then
case $BOOT_PART in
/dev/sd[a-z][0-9]*)
BOOT_DISK=$(echo $BOOT_PART | sed -e "s,[0-9]*,,g")
;;
/dev/mmcblk*)
BOOT_DISK=$(echo $BOOT_PART | sed -e "s,p[0-9]*,,g")
;;
esac
fi
# mount $BOOT_ROOT rw
mount -o remount,rw $BOOT_ROOT
mount -o remount,rw $BOOT_ROOT
# update /amlogic device trees
if [ -d $BOOT_ROOT/amlogic ]; then
for dtbfile in $BOOT_ROOT/amlogic/*.dtb ; do
dtb=$(basename $dtbfile)
echo "Updating $dtb"
cp -p $SYSTEM_ROOT/usr/share/bootloader/$dtb $BOOT_ROOT/amlogic/ 2>/dev/null || true
done
fi
if [ -d $BOOT_ROOT/amlogic ]; then
for dtbfile in $BOOT_ROOT/amlogic/*.dtb; do
dtb=$(basename $dtbfile)
echo "Updating $dtb"
cp -p $SYSTEM_ROOT/usr/share/bootloader/$dtb $BOOT_ROOT/amlogic/ 2>/dev/null || true
done
fi
# update /extlinux device trees
if [ -f $BOOT_ROOT/extlinux/extlinux.conf ]; then
for dtbfile in $BOOT_ROOT/*.dtb ; do
dtb=$(basename $dtbfile)
echo "Updating $dtb"
cp -p $SYSTEM_ROOT/usr/share/bootloader/$dtb $BOOT_ROOT/ 2>/dev/null || true
done
fi
if [ -f $BOOT_ROOT/extlinux/extlinux.conf ]; then
for dtbfile in $BOOT_ROOT/*.dtb; do
dtb=$(basename $dtbfile)
echo "Updating $dtb"
cp -p $SYSTEM_ROOT/usr/share/bootloader/$dtb $BOOT_ROOT/ 2>/dev/null || true
done
fi
# update /dtb device trees
if [ -d $BOOT_ROOT/dtb ]; then
for dtbfile in $BOOT_ROOT/dtb/*.dtb ; do
dtb=$(basename $dtbfile)
echo "Updating $dtb"
cp -p $SYSTEM_ROOT/usr/share/bootloader/$dtb $BOOT_ROOT/dtb/ 2>/dev/null || true
done
fi
if [ -d $BOOT_ROOT/dtb ]; then
for dtbfile in $BOOT_ROOT/dtb/*.dtb; do
dtb=$(basename $dtbfile)
echo "Updating $dtb"
cp -p $SYSTEM_ROOT/usr/share/bootloader/$dtb $BOOT_ROOT/dtb/ 2>/dev/null || true
done
fi
# update u-boot scripts
if [ -f $BOOT_ROOT/uEnv.ini ]; then
for scriptfile in $SYSTEM_ROOT/usr/share/bootloader/*_autoscript* $SYSTEM_ROOT/usr/share/bootloader/*.scr ; do
script=$(basename $scriptfile)
echo "Updating $script"
cp -p $SYSTEM_ROOT/usr/share/bootloader/$script $BOOT_ROOT/ 2>/dev/null || true
done
fi
if [ -f $BOOT_ROOT/uEnv.ini ]; then
for scriptfile in $SYSTEM_ROOT/usr/share/bootloader/*_autoscript* $SYSTEM_ROOT/usr/share/bootloader/*.scr; do
script=$(basename $scriptfile)
echo "Updating $script"
cp -p $SYSTEM_ROOT/usr/share/bootloader/$script $BOOT_ROOT/ 2>/dev/null || true
done
fi
# mount $BOOT_ROOT ro
sync
mount -o remount,ro $BOOT_ROOT
sync
mount -o remount,ro $BOOT_ROOT

View File

@ -4,7 +4,7 @@
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
case $(dtsoc) in
amlogic,g12*|amlogic,sm1)
amlogic,g12* | amlogic,sm1)
TEMP=$(cat /sys/devices/virtual/thermal/thermal_zone1/temp)
;;
*)
@ -12,5 +12,5 @@ case $(dtsoc) in
;;
esac
TEMP="$(( $TEMP / 1000 ))"
TEMP="$(($TEMP / 1000))"
echo "${TEMP} C"

View File

@ -8,16 +8,16 @@ SYS_CPUFREQ_GOV=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
if [ "${SYS_CPUFREQ_GOV}" = "ondemand" ]; then
for io_is_busy in $(find /sys/devices/system/cpu -name io_is_busy); do
echo 1 > "${io_is_busy}"
echo 1 >"${io_is_busy}"
done
for up_threshold in $(find /sys/devices/system/cpu -name up_threshold); do
echo 50 > "${up_threshold}"
echo 50 >"${up_threshold}"
done
for sampling_rate in $(find /sys/devices/system/cpu -name sampling_rate); do
echo 100000 > "${sampling_rate}"
echo 100000 >"${sampling_rate}"
done
for sampling_down_factor in $(find /sys/devices/system/cpu -name sampling_down_factor); do
echo 50 > "${sampling_down_factor}"
echo 50 >"${sampling_down_factor}"
done
else
echo "cpufreq: settings not found for current cpu governor." | systemd-cat -p info

View File

@ -2,14 +2,15 @@
FB_TYPE="$(grep '^0 ' /proc/fb | sed 's/[^[:space:]] //')"
if [ "$FB_TYPE" == "inteldrmfb" ] || echo "$FB_TYPE" | grep -q "^i9[0-9]*drmfb$"; then
OUTPUT=`/usr/bin/xrandr -display :0 -q | sed '/ connected/!d;s/ .*//;q'`
for out in $OUTPUT ; do
OUTPUT=$(/usr/bin/xrandr -display :0 -q | sed '/ connected/!d;s/ .*//;q')
for out in $OUTPUT; do
# Hack - something is not yet fully right
/usr/bin/xrandr -display :0 --output $out --set "Broadcast RGB" "Full"
# Seems there is a little race somewhere on some outputs
# Turn the display shortly off and on again
if [ -e "/storage/.config/forcedisplay" ]; then
/usr/bin/xrandr -display :0 --output $out --off ; /usr/bin/xrandr -display :0 --output $out --auto
/usr/bin/xrandr -display :0 --output $out --off
/usr/bin/xrandr -display :0 --output $out --auto
fi
done
fi

View File

@ -16,16 +16,16 @@ if [ $(basename "$0") = "gputemp" -o "$1" = "gpu" ]; then
for hwmon in /sys/class/hwmon/*; do
if [ -f "${hwmon}/name" ]; then
case $(cat ${hwmon}/name) in
nouveau|radeon|amdgpu)
nouveau | radeon | amdgpu)
[[ -f "${hwmon}/temp1_input" ]] && TEMP="$(cat ${hwmon}/temp1_input)" && break
[[ -f "${hwmon}/temp2_input" ]] && TEMP="$(cat ${hwmon}/temp2_input)" && break
;;
# intel gpu is supported by cpu coretemp below
# intel gpu is supported by cpu coretemp below
esac
fi
done
TEMP="$(( $TEMP / 1000 ))"
TEMP="$(($TEMP / 1000))"
fi
fi
@ -34,7 +34,7 @@ if [ "$1" = "cpu" -o "$TEMP" = "0" ]; then
for hwmon in /sys/class/hwmon/*; do
if [ -f "${hwmon}/name" ]; then
case $(cat ${hwmon}/name) in
coretemp|k10temp|scpi_sensors)
coretemp | k10temp | scpi_sensors)
[[ -f "${hwmon}/temp1_input" ]] && TEMP="$(cat ${hwmon}/temp1_input)" && break
[[ -f "${hwmon}/temp2_input" ]] && TEMP="$(cat ${hwmon}/temp2_input)" && break
;;
@ -46,7 +46,7 @@ if [ "$1" = "cpu" -o "$TEMP" = "0" ]; then
TEMP="$(cat /sys/class/hwmon/hwmon0/device/temp1_input)"
fi
TEMP="$(( $TEMP / 1000 ))"
TEMP="$(($TEMP / 1000))"
fi
echo "${TEMP} C"

View File

@ -13,105 +13,104 @@ USED_IFACES=""
function log
{
logger -t "${LOGGER_TAG}" "$@"
logger -t "${LOGGER_TAG}" "$@"
}
function logerr
{
logger -t "${LOGGER_TAG}" -p "err" "$@"
logger -t "${LOGGER_TAG}" -p "err" "$@"
}
# Select setup based on model
case "${MODEL}" in
"ZII RDU2+ Board" | "ZII RDU2 Board")
log "Loading RDU2 networking setup..."
IP_IFACE="eth1"
BR_NAME="br0"
BR_IFACES="netaux netleft netright gigabit_proc"
ALL_IFACES="eth0 ${IP_IFACE} ${BR_IFACES} ${BR_NAME}"
;;
"ZII RDU1 Board")
log "Loading RDU1 networking setup..."
IP_IFACE="br0"
BR_NAME="br0"
BR_IFACES="netaux netleft netright"
ALL_IFACES="eth0 ${BR_NAME} ${BR_IFACES}"
;;
*)
logerr "invalid hardware model detected: ${MODEL}"
exit 1
;;
"ZII RDU2+ Board" | "ZII RDU2 Board")
log "Loading RDU2 networking setup..."
IP_IFACE="eth1"
BR_NAME="br0"
BR_IFACES="netaux netleft netright gigabit_proc"
ALL_IFACES="eth0 ${IP_IFACE} ${BR_IFACES} ${BR_NAME}"
;;
"ZII RDU1 Board")
log "Loading RDU1 networking setup..."
IP_IFACE="br0"
BR_NAME="br0"
BR_IFACES="netaux netleft netright"
ALL_IFACES="eth0 ${BR_NAME} ${BR_IFACES}"
;;
*)
logerr "invalid hardware model detected: ${MODEL}"
exit 1
;;
esac
case "${ACTION}" in
"start")
"start")
# Assume RDU network is already started if the bridge is available
if [ -d /sys/class/net/${BR_NAME} ]; then
log "Networking setup is already started"
exit 0
fi
# Assume RDU network is already started if the bridge is available
if [ -d /sys/class/net/${BR_NAME} ]; then
log "Networking setup is already started"
exit 0
fi
# Cleanup all addresses from all interfaces and bring them down
log "Resetting interfaces..."
for IFACE in ${ALL_IFACES}; do
log " Resetting ${IFACE}..."
ip addr flush dev ${IFACE} >/dev/null 2>&1
ip link set dev ${IFACE} down >/dev/null 2>&1
done
# Cleanup all addresses from all interfaces and bring them down
log "Resetting interfaces..."
for IFACE in ${ALL_IFACES}; do
log " Resetting ${IFACE}..."
ip addr flush dev ${IFACE} >/dev/null 2>&1
ip link set dev ${IFACE} down >/dev/null 2>&1
done
# Create bridge with all interfaces
log "Creating bridge interface..."
brctl addbr ${BR_NAME} >/dev/null 2>&1
for IFACE in ${BR_IFACES}; do
log " Adding ${IFACE} to bridge..."
brctl addif ${BR_NAME} ${IFACE} >/dev/null 2>&1
done
# Create bridge with all interfaces
log "Creating bridge interface..."
brctl addbr ${BR_NAME} >/dev/null 2>&1
for IFACE in ${BR_IFACES}; do
log " Adding ${IFACE} to bridge..."
brctl addif ${BR_NAME} ${IFACE} >/dev/null 2>&1
done
# Bring all bridge interfaces and the bridge itself up
log "Bringing up all interfaces..."
for IFACE in ${ALL_IFACES}; do
log " Bringing up ${IFACE}..."
ip link set dev ${IFACE} up >/dev/null 2>&1
done
# Bring all bridge interfaces and the bridge itself up
log "Bringing up all interfaces..."
for IFACE in ${ALL_IFACES}; do
log " Bringing up ${IFACE}..."
ip link set dev ${IFACE} up >/dev/null 2>&1
done
# All done
log "RDU networking started"
exit 0
;;
# All done
log "RDU networking started"
exit 0
;;
"stop")
"stop")
# Assume RDU network is already stopped if the bridge is available
if [ ! -d /sys/class/net/${BR_NAME} ]; then
log "Networking setup is already stopped"
exit 0
fi
# Assume RDU network is already stopped if the bridge is available
if [ ! -d /sys/class/net/${BR_NAME} ]; then
log "Networking setup is already stopped"
exit 0
fi
# Cleanup all addresses from all interfaces and bring them down
log "Resetting interfaces..."
for IFACE in ${ALL_IFACES}; do
ip addr flush dev ${IFACE} >/dev/null 2>&1
ip link set dev ${IFACE} down >/dev/null 2>&1
done
# Cleanup all addresses from all interfaces and bring them down
log "Resetting interfaces..."
for IFACE in ${ALL_IFACES}; do
ip addr flush dev ${IFACE} >/dev/null 2>&1
ip link set dev ${IFACE} down >/dev/null 2>&1
done
# Remove bridge interfaces and bridge itself
log "Removing bridge interface..."
for IFACE in ${BR_IFACES}; do
brctl delif ${BR_NAME} ${IFACE} >/dev/null 2>&1
done
brctl delbr ${BR_NAME} >/dev/null 2>&1
# Remove bridge interfaces and bridge itself
log "Removing bridge interface..."
for IFACE in ${BR_IFACES}; do
brctl delif ${BR_NAME} ${IFACE} >/dev/null 2>&1
done
brctl delbr ${BR_NAME} >/dev/null 2>&1
# All done
log "RDU networking stopped"
exit 0
;;
# All done
log "RDU networking stopped"
exit 0
;;
*)
logerr "invalid action requested: ${ACTION}"
exit 2
;;
*)
logerr "invalid action requested: ${ACTION}"
exit 2
;;
esac

View File

@ -4,4 +4,4 @@
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
TEMP="$(cat /sys/class/thermal/thermal_zone0/temp)"
echo "$(( $TEMP / 1000 )) C"
echo "$(($TEMP / 1000)) C"

View File

@ -4,4 +4,4 @@
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
TEMP="$(cat /sys/class/thermal/thermal_zone1/temp)"
echo "$(( $TEMP / 1000 )) C"
echo "$(($TEMP / 1000)) C"

View File

@ -16,17 +16,17 @@ if [ -z "$BOOT_DISK" ]; then
fi
# mount $BOOT_ROOT r/w
mount -o remount,rw $BOOT_ROOT
mount -o remount,rw $BOOT_ROOT
# update Device Tree Blobs
for all_dtb in /flash/*.dtb; do
dtb=$(basename $all_dtb)
if [ -f $SYSTEM_ROOT/usr/share/bootloader/$dtb ]; then
echo "*** updating Device Tree Blob: $dtb ..."
cp -p $SYSTEM_ROOT/usr/share/bootloader/$dtb $BOOT_ROOT
fi
done
for all_dtb in /flash/*.dtb; do
dtb=$(basename $all_dtb)
if [ -f $SYSTEM_ROOT/usr/share/bootloader/$dtb ]; then
echo "*** updating Device Tree Blob: $dtb ..."
cp -p $SYSTEM_ROOT/usr/share/bootloader/$dtb $BOOT_ROOT
fi
done
# mount $BOOT_ROOT r/o
sync
mount -o remount,ro $BOOT_ROOT
sync
mount -o remount,ro $BOOT_ROOT

View File

@ -5,4 +5,4 @@
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
TEMP="$(cat /sys/class/thermal/thermal_zone0/temp)"
echo "$(( $TEMP / 1000 )) C"
echo "$(($TEMP / 1000)) C"

View File

@ -4,15 +4,15 @@
# Copyright (C) 2009-2015 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv)
SYS_CPUFREQ_GOV=$( cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor )
SYS_CPUFREQ_GOV=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
SYS_ONDEMAND_DIR="/sys/devices/system/cpu/cpufreq/ondemand/"
# Configure frequency scaling properties
if [ "${SYS_CPUFREQ_GOV}" = "ondemand" ]; then
echo 1 > "${SYS_ONDEMAND_DIR}/io_is_busy"
echo 50 > "${SYS_ONDEMAND_DIR}/up_threshold"
echo 100000 > "${SYS_ONDEMAND_DIR}/sampling_rate"
echo 50 > "${SYS_ONDEMAND_DIR}/sampling_down_factor"
echo 1 >"${SYS_ONDEMAND_DIR}/io_is_busy"
echo 50 >"${SYS_ONDEMAND_DIR}/up_threshold"
echo 100000 >"${SYS_ONDEMAND_DIR}/sampling_rate"
echo 50 >"${SYS_ONDEMAND_DIR}/sampling_down_factor"
else
echo "cpufreq: settings not found for current cpu governor." | systemd-cat -p info
fi

View File

@ -5,4 +5,4 @@
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
TEMP="$(cat /sys/class/thermal/thermal_zone0/temp)"
echo "$(( $TEMP / 1000 )) C"
echo "$(($TEMP / 1000)) C"

View File

@ -5,4 +5,4 @@
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
TEMP="$(cat /sys/class/thermal/thermal_zone1/temp)"
echo "$(( $TEMP / 1000 )) C"
echo "$(($TEMP / 1000)) C"

View File

@ -5,4 +5,4 @@
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
TEMP="$(cat /sys/class/thermal/thermal_zone0/temp)"
echo "$(( $TEMP / 1000 )) C"
echo "$(($TEMP / 1000)) C"

View File

@ -8,16 +8,16 @@ SYS_CPUFREQ_GOV=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
if [ "${SYS_CPUFREQ_GOV}" = "ondemand" ]; then
for io_is_busy in $(find /sys/devices/system/cpu -name io_is_busy); do
echo 1 > "${io_is_busy}"
echo 1 >"${io_is_busy}"
done
for up_threshold in $(find /sys/devices/system/cpu -name up_threshold); do
echo 50 > "${up_threshold}"
echo 50 >"${up_threshold}"
done
for sampling_rate in $(find /sys/devices/system/cpu -name sampling_rate); do
echo 100000 > "${sampling_rate}"
echo 100000 >"${sampling_rate}"
done
for sampling_down_factor in $(find /sys/devices/system/cpu -name sampling_down_factor); do
echo 50 > "${sampling_down_factor}"
echo 50 >"${sampling_down_factor}"
done
else
echo "cpufreq: settings not found for current cpu governor." | systemd-cat -p info

View File

@ -8,29 +8,29 @@
[ -z "$BOOT_PART" ] && BOOT_PART=$(df "$BOOT_ROOT" | tail -1 | awk {' print $1 '})
# identify the boot device
if [ -z "$BOOT_DISK" ]; then
case $BOOT_PART in
/dev/sd[a-z][0-9]*)
BOOT_DISK=$(echo $BOOT_PART | sed -e "s,[0-9]*,,g")
;;
/dev/mmcblk*)
BOOT_DISK=$(echo $BOOT_PART | sed -e "s,p[0-9]*,,g")
;;
esac
fi
if [ -z "$BOOT_DISK" ]; then
case $BOOT_PART in
/dev/sd[a-z][0-9]*)
BOOT_DISK=$(echo $BOOT_PART | sed -e "s,[0-9]*,,g")
;;
/dev/mmcblk*)
BOOT_DISK=$(echo $BOOT_PART | sed -e "s,p[0-9]*,,g")
;;
esac
fi
# mount $BOOT_ROOT rw
mount -o remount,rw $BOOT_ROOT
mount -o remount,rw $BOOT_ROOT
# update extlinux device trees
if [ -f $BOOT_ROOT/extlinux/extlinux.conf ]; then
for dtbfile in $BOOT_ROOT/*.dtb ; do
dtb=$(basename $dtbfile)
echo "Updating $dtb"
cp -p $SYSTEM_ROOT/usr/share/bootloader/$dtb $BOOT_ROOT/ 2>/dev/null || true
done
fi
if [ -f $BOOT_ROOT/extlinux/extlinux.conf ]; then
for dtbfile in $BOOT_ROOT/*.dtb; do
dtb=$(basename $dtbfile)
echo "Updating $dtb"
cp -p $SYSTEM_ROOT/usr/share/bootloader/$dtb $BOOT_ROOT/ 2>/dev/null || true
done
fi
# mount $BOOT_ROOT ro
sync
mount -o remount,ro $BOOT_ROOT
sync
mount -o remount,ro $BOOT_ROOT

View File

@ -5,5 +5,5 @@
# XU4 has 5x sensors so read them all and report the highest value
TEMP=$(cat /sys/devices/virtual/thermal/thermal_zone*/temp | sort -n | tail -1)
TEMP="$(( $TEMP / 1000 ))"
TEMP="$(($TEMP / 1000))"
echo "${TEMP} C"