shell scripts clean up and formatting (#874)

pull/876/head
Paul Philippov 2023-06-11 15:44:27 -04:00 committed by GitHub
parent 52f4b1ec5c
commit 500d11cbc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 803 additions and 731 deletions

View File

@ -1,17 +1,17 @@
config BR2_OPENIPC_SOC_VENDOR
string "openipc soc vendor"
string "SoC vendor"
default "hisilicon"
config BR2_OPENIPC_SOC_MODEL
string "openipc soc model"
string "SoC model"
default "hi3516ev300"
config BR2_OPENIPC_SOC_FAMILY
string "openipc soc family"
string "SoC family"
default "hi3516ev200"
config BR2_OPENIPC_FLAVOR
string "openipc flavor"
string "OpenIPC flavor"
default "lite"
source "$BR2_EXTERNAL_GENERAL_PATH/package/Config.in"

View File

@ -36,19 +36,19 @@ stop() {
return "$status"
}
restart() {
case "$1" in
start|stop)
"$1"
;;
restart|reload)
stop
sleep 1
start
}
;;
case "$1" in
start|stop|restart)
"$1" ;;
reload)
# Restart, since there is no true "reload" feature.
restart ;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
;;
esac

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
# attempt to load modules

View File

@ -32,10 +32,16 @@ stop()
case "$1" in
start|stop)
"$1" ;;
"$1"
;;
restart|reload)
stop; start ;;
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|reload}" >&2
exit 1
;;
esac

View File

@ -9,13 +9,17 @@ case "$1" in
echo /sbin/mdev >/proc/sys/kernel/hotplug
/sbin/mdev -s
;;
stop)
;;
restart|reload)
;;
*)
echo "Usage: $0 {start|stop|restart}"
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
;;
esac
exit $?

View File

@ -36,18 +36,19 @@ stop() {
return "$status"
}
restart() {
case "$1" in
start|stop)
"$1"
;;
reload)
stop
sleep 1
start
}
;;
case "$1" in
start|stop|restart)
"$1" ;;
reload)
restart ;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
;;
esac

View File

@ -30,24 +30,27 @@ start() {
start-stop-daemon -S -q -p /var/run/dropbear.pid --exec /usr/sbin/dropbear -- $DROPBEAR_ARGS
[ $? = 0 ] && echo "OK" || echo "FAIL"
}
stop() {
printf "Stopping dropbear sshd: "
start-stop-daemon -K -q -p /var/run/dropbear.pid
[ $? = 0 ] && echo "OK" || echo "FAIL"
}
restart() {
stop
start
}
case "$1" in
start|stop|restart)
"$1" ;;
reload)
restart ;;
start|stop)
"$1"
;;
restart|reload)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
;;
esac
exit $?

View File

@ -38,18 +38,19 @@ stop() {
return "$status"
}
restart() {
case "$1" in
start|stop)
"$1"
;;
restart|reload)
stop
sleep 1
start
}
;;
case "$1" in
start|stop|restart)
"$1" ;;
reload)
restart ;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
;;
esac

View File

@ -22,12 +22,18 @@ stop() {
case "$1" in
start|stop)
"$1" ;;
"$1"
;;
restart|reload)
stop; start ;;
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
;;
esac
exit $?

View File

@ -38,18 +38,19 @@ stop() {
return "$status"
}
restart() {
case "$1" in
start|stop)
"$1"
;;
restart|reload)
stop
sleep 1
start
}
;;
case "$1" in
start|stop|restart)
"$1" ;;
reload)
restart ;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
;;
esac

View File

@ -1,7 +1,6 @@
#!/bin/sh
# load vendor specific drivers
#
vendor=$(ipcinfo -v)
status=$(check_mac)

View File

@ -1,21 +1,14 @@
#!/bin/sh
# Setting the TimeZone for all processes
#
export TZ=$(cat /etc/TZ)
# Set the firmware creation time as the base system time
#
/bin/date -s @$(stat -t /etc/os-release | cut -d" " -f12)
# Start all init scripts in /etc/init.d
# executing them in numerical order.
#
for i in /etc/init.d/S??* ; do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
@ -25,13 +18,13 @@ for i in /etc/init.d/S??* ;do
(
trap - INT QUIT TSTP
set start
. $i
$i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done

View File

@ -7,13 +7,20 @@
case "$IF_BRIDGE_PORTS" in
"")
exit 0 ;;
exit 0
;;
none)
INTERFACES="" ;;
INTERFACES=""
;;
all)
INTERFACES=$(grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/') ;;
INTERFACES=$(grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/')
;;
*)
INTERFACES="$IF_BRIDGE_PORTS" ;;
INTERFACES="$IF_BRIDGE_PORTS"
;;
esac
brctl delbr $IFACE

View File

@ -7,13 +7,20 @@
case "$IF_BRIDGE_PORTS" in
"")
exit 0 ;;
exit 0
;;
none)
INTERFACES="" ;;
INTERFACES=""
;;
all)
INTERFACES=$(grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/') ;;
INTERFACES=$(grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/')
;;
*)
INTERFACES="$IF_BRIDGE_PORTS" ;;
INTERFACES="$IF_BRIDGE_PORTS"
;;
esac
brctl addbr $IFACE &&

View File

@ -7,30 +7,37 @@ case "$IFACE" in
vconfig set_name_type VLAN_PLUS_VID
VLANID=$(echo $IFACE|sed "s/vlan0*//")
;;
vlan*)
vconfig set_name_type VLAN_PLUS_VID_NO_PAD
VLANID=$(echo $IFACE|sed "s/vlan*//")
;;
*.0*)
vconfig set_name_type DEV_PLUS_VID
VLANID=$(echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g")
IF_VLAN_RAW_DEVICE=$(echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/")
;;
*.*)
vconfig set_name_type DEV_PLUS_VID_NO_PAD
VLANID=$(echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g")
IF_VLAN_RAW_DEVICE=$(echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/")
;;
*)
exit 0
;;
esac
if [ -n "$IF_VLAN_RAW_DEVICE" ]; then
[ ! -x /sbin/vconfig ] && exit 0
if ! ip link show dev "$IF_VLAN_RAW_DEVICE" > /dev/null; then
echo "$IF_VLAN_RAW_DEVICE does not exist, unable to create $IFACE"
exit 1
fi
ip link set up dev $IF_VLAN_RAW_DEVICE
vconfig add $IF_VLAN_RAW_DEVICE $VLANID
fi

View File

@ -23,17 +23,29 @@ export EDITOR='/bin/vi'
[ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; }
differ() { diff -rN "/rom$1" "$1"; }
differ() {
diff -rN "/rom$1" "$1"
}
majestic_changes() { diff -L "Majestic changes" -U 3 /rom/etc/majestic.yaml /etc/majestic.yaml; }
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"; \
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; }
do echo -n "Parameter: $parameter --> "; cat /sys/module/$module/parameters/$parameter; done; fi; echo; done
}
show_fullname() { echo "openipc-$(ipcinfo --chip-name)-$(ipcinfo --short-sensor)"; }
show_fullname() {
echo "openipc-$(ipcinfo --chip-name)-$(ipcinfo --short-sensor)"
}
set_fullname() { show_fullname >/etc/hostname; }
set_fullname() {
show_fullname >/etc/hostname
}
# Source configuration files from /etc/profile.d
for i in /etc/profile.d/*.sh; do [ -r "$i" ] && . $i; done; unset i
for i in /etc/profile.d/*.sh; do
[ -r "$i" ] && . $i
done; unset i

View File

@ -13,9 +13,11 @@ case "${CMD}" in
cli)
yaml-cli -i /etc/majestic.yaml "$@"
;;
sensor_cli)
yaml-cli -i /etc/sensor/$(fw_printenv -n sensor).yaml $@
;;
ipctool)
IPCTOOL=/tmp/ipctool
if [ ! -x $IPCTOOL ]; then
@ -25,11 +27,13 @@ case "${CMD}" in
fi
$IPCTOOL $@
;;
check_mac)
if [ "$(fw_printenv -n ethaddr)" = "00:00:23:34:45:66" ]; then
XMMAC="$(ipcinfo --xm-mac)" && [ -n "${XMMAC}" ] && [ ! "Nothing found." = "${XMMAC}" ] && fw_setenv ethaddr ${XMMAC} && reboot -f || echo "Warning. Wired network interface has default MAC address, please change it."
fi
;;
*)
;;
esac

View File

@ -36,7 +36,6 @@ setBlue() {
if [ -n $1 ]; then
case $1 in
off)
setRed 0
setGreen 0

View File

@ -12,6 +12,7 @@ case ${manufacturer} in
;;
esac
;;
Camhi|Hichip|Xin)
case ${soc} in
hi3516ev200|gk7205v200)
@ -28,6 +29,7 @@ case ${manufacturer} in
;;
esac
;;
Herospeed|Longsee|Cantonk)
case ${soc} in
hi3516ev200|gk7205v200)
@ -41,6 +43,7 @@ case ${manufacturer} in
;;
esac
;;
Jabsco)
case ${soc} in
hi3516ev200|gk7205v200)
@ -48,6 +51,7 @@ case ${manufacturer} in
;;
esac
;;
Jvt)
case ${soc} in
hi3516cv200)
@ -58,6 +62,7 @@ case ${manufacturer} in
;;
esac
;;
Juan|Sannce)
case ${soc} in
hi3518ev200)
@ -65,6 +70,7 @@ case ${manufacturer} in
;;
esac
;;
Tiandy)
case ${soc} in
hi3518ev200)
@ -72,6 +78,7 @@ case ${manufacturer} in
;;
esac
;;
Uniview)
case ${soc} in
hi3516ev300|gk7205v300)
@ -79,6 +86,7 @@ case ${manufacturer} in
;;
esac
;;
Xiongmai)
case ${soc} in
hi3516ev200|gk7205v200)
@ -98,6 +106,7 @@ case ${manufacturer} in
;;
esac
;;
Zenotech|Videopark)
case ${soc} in
hi3516ev300|gk7205v300)

View File

@ -15,8 +15,7 @@ if [ ! -d /sys/class/gpio/gpio${GPIO} ]; then
fi
# continuously monitor current value of reset switch
while [ true ]
do
while [ true ]; do
if [ "$(cat /sys/class/gpio/gpio"${GPIO}"/value)" -eq 1 ]; then
count=0
else

View File

@ -263,69 +263,84 @@ for i in "$@"; do
skip_ver=1
shift
;;
--force_md5)
skip_md5=1
shift
;;
--force_soc)
skip_soc=1
shift
;;
--force_ver)
skip_ver=1
shift
;;
-d)
branch_dev=1
shift
;;
-h | --help)
print_sysinfo
print_usage
exit 0
;;
-k)
update_kernel=1
remote_update=1
shift
;;
--kernel=*)
update_kernel=1
kernel_file="${i#*=}"
[ "$kernel_file" != ${kernel_file#/mnt/mmc} ] && skip_unmount=1
shift
;;
-n | --wipe_overlay)
clear_overlay=1
shift
;;
-r)
update_rootfs=1
remote_update=1
shift
;;
--rootfs=*)
update_rootfs=1
rootfs_file="${i#*=}"
[ "$rootfs_file" != ${rootfs_file#/mnt/mmc} ] && skip_unmount=1
shift
;;
--url=*)
url="${i#*=}"
shift
;;
-x | --no_reboot)
skip_reboot=1
shift
;;
-w)
update_webui=1
shift
;;
-x | --no_reboot)
skip_reboot=1
shift
;;
-z | --no_update)
skip_selfupdate=1
shift
;;
*)
print_sysinfo
echo_c 37 "\nUnknown option: $1"

View File

@ -17,9 +17,7 @@ RESOLV_CONF="/tmp/resolv.conf"
# Handle stateful DHCPv6 like DHCPv4
[ -n "$ipv6" ] && ip="$ipv6/128"
if [ -z "${IF_WAIT_DELAY}" ]; then
IF_WAIT_DELAY=10
fi
[ -z "${IF_WAIT_DELAY}" ] && IF_WAIT_DELAY=10
wait_for_ipv6_default_route() {
printf "Waiting for IPv6 default route to appear"

View File

@ -265,8 +265,8 @@ sys_config() {
devmem 0x20030058 32 0x2 # TDE unreset
devmem 0x20030068 32 0x2 # MDU unreset
#devmem 0x2003006c 32 0x2; # IVE unreset
#devmem 0x2003008c 32 0x2; # SIO unreset and clock enable,m/f/bclk config in code.
#devmem 0x2003006c 32 0x2 # IVE unreset
#devmem 0x2003008c 32 0x2 # SIO unreset and clock enable,m/f/bclk config in code.
#devmem 0x20050068 32 0x58000000 # Audio Codec channel config for power down.
}
sysctl() {