Overlay: minor script refactoring ()

pull/1305/head
viktorxda 2024-02-07 16:18:43 +01:00 committed by GitHub
parent 5511be0a29
commit e37099d6ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 80 additions and 171 deletions

View File

@ -10,7 +10,8 @@ case "$1" in
[ -r /etc/modules ] || exit 0
while read module args; do
case "$module" in
""|"#"*) continue
""|"#"*)
continue
;;
esac

View File

@ -9,15 +9,13 @@ PID_FILE="/var/run/${NAME}.pid"
# Read configuration variable file if it is present
[ -r "${CFG_FILE}" ] && . "${CFG_FILE}"
start()
{
start() {
printf "Starting ${NAME}: "
start-stop-daemon -S -q -x "${DAEMON}" -- ${DAEMON_ARGS}
[ $? = 0 ] && echo "OK" || echo "FAIL"
}
stop()
{
stop() {
printf "Stopping ${NAME}: "
# This daemon does not exit properly with the default TERM signal unless
# it's forced to work by something reading /dev/random. Killing it and

View File

@ -4,4 +4,9 @@ case "$1" in
start)
system_fb
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@ -1,7 +1,4 @@
#!/bin/sh
#
# Start mdev....
#
case "$1" in
start)
@ -10,14 +7,8 @@ case "$1" in
/sbin/mdev -s
;;
stop)
;;
restart|reload)
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@ -1,40 +1,20 @@
#!/bin/sh
#
# Start rc.local
#
start() {
echo "Starting rc.local"
/etc/rc.local
}
restart() {
echo "Restarting rc.local"
/etc/rc.local
}
stop() {
echo "Stopping rc.local"
# Check if rc.local.stop exists and if so, execute it
if [ -x /etc/rc.local.stop ]; then
/etc/rc.local.stop
else
echo "/etc/rc.local.stop not found or not executable."
fi
[ -x /etc/rc.local.stop ] && /etc/rc.local.stop
}
case "$1" in
start)
start
;;
restart|reload)
restart
;;
stop)
stop
start|stop)
"$1"
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
echo "Usage: $0 {start|stop}"
exit 1
;;
esac

View File

@ -1,65 +0,0 @@
#!/bin/sh
DAEMON="watchdog"
WATCHDOG_ENABLED=false
WATCHDOG_TIMEOUT=60
SUPPORTED_VENDORS="ingenic"
WATCHDOG_ARGS="-T $WATCHDOG_TIMEOUT /dev/watchdog"
WATCHDOG_VENDOR=$(ipcinfo -v)
vendor_supported() {
for vendor in $SUPPORTED_VENDORS; do
[ "$WATCHDOG_VENDOR" = "$vendor" ] && return 0
done
return 1
}
start()
{
if [ "$(cli -g .watchdog.enabled)" = "true" ]; then
printf "Starting ${DAEMON}: "
echo "majestic watchdog enabled"
exit 0
fi
if vendor_supported && [ "$WATCHDOG_ENABLED" = "true" ]; then
printf "Starting ${DAEMON}: "
start-stop-daemon -b -S -q -x "/sbin/${DAEMON}" -- ${WATCHDOG_ARGS}
if [ $? = 0 ]; then
echo "OK"
else
echo "FAIL"
fi
else
echo "Watchdog: System watchdog disabled"
exit 0
fi
}
stop()
{
printf "Stopping ${DAEMON}: "
if start-stop-daemon -K -q -s KILL -n "${DAEMON}"; then
echo "OK"
else
echo "FAIL"
fi
}
case "$1" in
start|stop)
"$1"
;;
restart|reload)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|reload}" >&2
exit 1
;;
esac

View File

@ -4,14 +4,15 @@ export HOME=${HOME:-/root}
export TZ=$(cat /etc/TZ)
export SENSOR=$(fw_printenv -n sensor)
echo_c() { echo -ne "\e[1;$1m$2\e[0m"; }
echo_c() {
echo -ne "\e[1;$1m$2\e[0m"
}
if [ "$PS1" ]; then
[ -f /etc/os-release ] && . /etc/os-release
[ -f /etc/openipc_banner ] && echo_c 34 "$(cat /etc/openipc_banner)"
echo_c 32 "$(printf "%56s" "${GITHUB_VERSION}")"
[ -f /etc/openipc_donors ] && echo_c 37 "\n\n$(cat /etc/openipc_donors)\n\n"
#
if [ "$(id -u)" -eq 0 ]; then
export PS1='\u@\h:\w\# '
else
@ -21,7 +22,9 @@ fi
export EDITOR='/bin/vi'
[ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; }
[ -x /usr/bin/arp ] || arp() {
cat /proc/net/arp
}
differ() {
diff -rN "/rom$1" "$1"
@ -31,22 +34,22 @@ majestic_changes() {
diff -L "Majestic changes" -U 3 /rom/etc/majestic.yaml /etc/majestic.yaml
}
show_modules() {
echo; cat /proc/modules | cut -f 1 -d " " | while read module; do echo "Module: $module"; \
if [ -d "/sys/module/$module/parameters" ]; then ls /sys/module/$module/parameters/ | while read parameter; \
do echo -n "Parameter: $parameter --> "; cat /sys/module/$module/parameters/$parameter; done; fi; echo; done
set_fullname() {
show_fullname >/etc/hostname
}
show_fullname() {
echo "openipc-$(ipcinfo --chip-name)-$(ipcinfo --short-sensor)"
}
set_fullname() {
show_fullname >/etc/hostname
show_modules() {
echo; cat /proc/modules | cut -f1 -d " " | while read module; do echo "Module: $module"; \
if [ -d "/sys/module/$module/parameters" ]; then ls /sys/module/$module/parameters/ | while read parameter; \
do echo -n "Parameter: $parameter --> "; cat /sys/module/$module/parameters/$parameter; done; fi; echo; done
}
show_gain() {
while sleep 1; do wget -q -O - http://127.0.0.1/metrics/isp | grep ^isp_again; done
while sleep 1; do wget -T1 -q -O - http://127.0.0.1/metrics/isp | grep ^isp_again; done
}
show_wlan() {
@ -57,17 +60,6 @@ network() {
/etc/init.d/S40network "$1"
}
switch_debug() {
[ "$1" = "on" ] && action='+' report='enabled' || action='-' report='disabled'
mount | grep -q 'debugfs' || mount -t debugfs none /sys/kernel/debug
echo "${action}p" > /sys/kernel/debug/dynamic_debug/control
for entry in mmc_core avpu squashfs mtdblock; do
echo "module $entry -p" > /sys/kernel/debug/dynamic_debug/control
done
echo "file fs/sysfs/file.c -p" > /sys/kernel/debug/dynamic_debug/control
echo "Dynamic debug for all files has been $report."
}
# Source configuration files from /etc/profile.d
for i in /etc/profile.d/*.sh; do
[ -r "$i" ] && . $i

View File

@ -2,17 +2,15 @@
destdir=/mnt
my_umount()
{
my_umount() {
if grep -qs "^/dev/$1 " /proc/mounts; then
umount "${destdir}/$1";
umount "${destdir}/$1"
fi
[ -d "${destdir}/$1" ] && rmdir "${destdir}/$1"
}
my_mount()
{
my_mount() {
mkdir -p "${destdir}/$1" || exit 1
if ! mount -t auto -o sync "/dev/$1" "${destdir}/$1"; then
@ -36,6 +34,7 @@ add|"")
my_umount ${MDEV}
my_mount ${MDEV}
;;
remove)
my_umount ${MDEV}
;;

View File

@ -4,10 +4,18 @@
#
. /etc/datalink.conf
chip=$(ipcinfo -c)
skip=$(fw_printenv -n fpv)
fw=$(grep "BUILD_OPTION" "/etc/os-release" | cut -d= -f2)
case "$1" in
start)
if [ ${skip} = "true" ]; then
sed -i "s/console/#console/g" /etc/inittab
elif [ ${skip} = "false" ]; then
sed -i "s/#console/console/g" /etc/inittab
exit 0
fi
if ! [ -f /etc/system.ok ]; then
tweaksys ${chip}
fi