Initial commit
This commit is contained in:
24
target/linux/x86/base-files/etc/board.d/01_leds
Executable file
24
target/linux/x86/base-files/etc/board.d/01_leds
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright © 2017 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions/uci-defaults.sh
|
||||
|
||||
board_config_update
|
||||
|
||||
case "$(board_name)" in
|
||||
pc-engines-apu|pc-engines-apu2|pc-engines-apu3)
|
||||
ucidef_set_led_netdev "wan" "WAN" "apu2:green:led3" "eth0"
|
||||
ucidef_set_led_netdev "lan" "LAN" "apu2:green:led2" "br-lan"
|
||||
ucidef_set_led_default "diag" "DIAG" "apu2:green:power" "1"
|
||||
;;
|
||||
traverse-technologies-geos)
|
||||
ucidef_set_led_netdev "lan" "LAN" "geos:1" "br-lan" "tx rx"
|
||||
ucidef_set_led_netdev "wlan" "WiFi" "geos:2" "phy0tpt"
|
||||
ucidef_set_led_default "diag" "DIAG" "geos:3" "1"
|
||||
;;
|
||||
esac
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
25
target/linux/x86/base-files/etc/board.d/02_network
Executable file
25
target/linux/x86/base-files/etc/board.d/02_network
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright © 2017 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions/system.sh
|
||||
. /lib/functions/uci-defaults.sh
|
||||
|
||||
board_config_update
|
||||
|
||||
case "$(board_name)" in
|
||||
pc-engines-apu|pc-engines-apu2|pc-engines-apu3)
|
||||
ucidef_set_interfaces_lan_wan "eth1 eth2" "eth0"
|
||||
;;
|
||||
traverse-technologies-geos)
|
||||
ucidef_set_interface_lan "eth0 eth1"
|
||||
ucidef_add_atm_bridge "0" "35" "llc" "bridged"
|
||||
ucidef_set_interface_wan "nas0" "dhcp"
|
||||
macaddr="$(cat /sys/class/net/eth0/address)" 2>/dev/null
|
||||
[ -n "$macaddr" ] && ucidef_set_interface_macaddr "wan" "$macaddr"
|
||||
;;
|
||||
esac
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
80
target/linux/x86/base-files/etc/diag.sh
Normal file
80
target/linux/x86/base-files/etc/diag.sh
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright © 2017 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/leds.sh
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
preinit_match_diag_led() {
|
||||
local CFG keys key cfg name sysfs default
|
||||
|
||||
CFG=/etc/board.json
|
||||
if [ ! -s $CFG ]; then
|
||||
CFG=/tmp/board.json
|
||||
[ -s /tmp/sysinfo/model ] || return
|
||||
/bin/board_detect $CFG || return
|
||||
fi
|
||||
|
||||
json_init
|
||||
json_load "$(cat $CFG)"
|
||||
json_get_keys keys led
|
||||
json_is_a led object || return
|
||||
|
||||
json_select led
|
||||
for key in $keys; do
|
||||
json_select "$key"
|
||||
json_get_vars name sysfs default
|
||||
|
||||
if [ "$name" = "DIAG" -a "$default" = "1" ]; then
|
||||
status_led="$sysfs"
|
||||
return
|
||||
fi
|
||||
json_select ..
|
||||
done
|
||||
}
|
||||
|
||||
match_diag_led() {
|
||||
local name
|
||||
local default
|
||||
local sysfs
|
||||
config_get name "$1" name
|
||||
config_get default "$1" default
|
||||
config_get sysfs "$1" sysfs
|
||||
|
||||
if [ "$name" = "DIAG" -a "$default" = "1" ]; then
|
||||
status_led="$sysfs"
|
||||
fi
|
||||
}
|
||||
|
||||
get_status_led() {
|
||||
if [ -s /etc/config/system ]; then
|
||||
config_load system
|
||||
config_foreach match_diag_led led
|
||||
else
|
||||
preinit_match_diag_led
|
||||
fi
|
||||
}
|
||||
|
||||
set_state() {
|
||||
get_status_led
|
||||
|
||||
case "$1" in
|
||||
preinit)
|
||||
status_led_blink_preinit
|
||||
;;
|
||||
|
||||
failsafe)
|
||||
status_led_blink_failsafe
|
||||
;;
|
||||
|
||||
preinit_regular)
|
||||
status_led_blink_preinit_regular
|
||||
;;
|
||||
|
||||
done)
|
||||
status_led_on
|
||||
;;
|
||||
esac
|
||||
}
|
||||
5
target/linux/x86/base-files/etc/inittab
Normal file
5
target/linux/x86/base-files/etc/inittab
Normal file
@@ -0,0 +1,5 @@
|
||||
::sysinit:/etc/init.d/rcS S boot
|
||||
::shutdown:/etc/init.d/rcS K shutdown
|
||||
ttyS0::askfirst:/usr/libexec/login.sh
|
||||
hvc0::askfirst:/usr/libexec/login.sh
|
||||
tty1::askfirst:/usr/libexec/login.sh
|
||||
39
target/linux/x86/base-files/lib/preinit/01_sysinfo
Normal file
39
target/linux/x86/base-files/lib/preinit/01_sysinfo
Normal file
@@ -0,0 +1,39 @@
|
||||
sanitize_name_x86() {
|
||||
sed -e '
|
||||
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;
|
||||
s/[^a-z0-9_-]\+/-/g;
|
||||
s/^-//;
|
||||
s/-$//;
|
||||
' "$@"
|
||||
}
|
||||
|
||||
do_sysinfo_x86() {
|
||||
local vendor product file
|
||||
|
||||
for file in sys_vendor board_vendor; do
|
||||
vendor="$(cat /sys/devices/virtual/dmi/id/$file 2>/dev/null)"
|
||||
[ -n "$vendor" ] && break
|
||||
done
|
||||
|
||||
for file in product_name board_name; do
|
||||
product="$(cat /sys/devices/virtual/dmi/id/$file 2>/dev/null)"
|
||||
case "$vendor:$product" in
|
||||
"Supermicro:Super Server")
|
||||
continue
|
||||
;;
|
||||
?*:?*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$vendor" -a -n "$product" ] || return
|
||||
|
||||
mkdir -p /tmp/sysinfo
|
||||
|
||||
echo "$vendor $product" > /tmp/sysinfo/model
|
||||
|
||||
sanitize_name_x86 /tmp/sysinfo/model > /tmp/sysinfo/board_name
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main do_sysinfo_x86
|
||||
10
target/linux/x86/base-files/lib/preinit/02_load_x86_ucode
Normal file
10
target/linux/x86/base-files/lib/preinit/02_load_x86_ucode
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2018 OpenWrt.org
|
||||
|
||||
do_load_x86_ucode() {
|
||||
if [ -e "/sys/devices/system/cpu/microcode/reload" ]; then
|
||||
echo 1 > /sys/devices/system/cpu/microcode/reload
|
||||
fi
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main do_load_x86_ucode
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
do_mount_procfs() {
|
||||
mount -o noatime -t proc none /proc
|
||||
}
|
||||
|
||||
5
target/linux/x86/base-files/lib/preinit/20_check_iso
Normal file
5
target/linux/x86/base-files/lib/preinit/20_check_iso
Normal file
@@ -0,0 +1,5 @@
|
||||
check_for_iso() {
|
||||
grep -qE '/dev/root.*iso9660' /proc/mounts && ramoverlay
|
||||
}
|
||||
|
||||
boot_hook_add preinit_mount_root check_for_iso
|
||||
19
target/linux/x86/base-files/lib/preinit/79_move_config
Normal file
19
target/linux/x86/base-files/lib/preinit/79_move_config
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2012-2015 OpenWrt.org
|
||||
|
||||
move_config() {
|
||||
local partdev
|
||||
|
||||
. /lib/upgrade/common.sh
|
||||
|
||||
if export_bootdevice && export_partdevice partdev 1; then
|
||||
mkdir -p /boot
|
||||
mount -t ext4 -o rw,noatime "/dev/$partdev" /boot
|
||||
if [ -f "/boot/$BACKUP_FILE" ]; then
|
||||
mv -f "/boot/$BACKUP_FILE" /
|
||||
fi
|
||||
mount --bind /boot/boot /boot
|
||||
fi
|
||||
}
|
||||
|
||||
boot_hook_add preinit_mount_root move_config
|
||||
95
target/linux/x86/base-files/lib/upgrade/platform.sh
Normal file
95
target/linux/x86/base-files/lib/upgrade/platform.sh
Normal file
@@ -0,0 +1,95 @@
|
||||
platform_check_image() {
|
||||
local diskdev partdev diff
|
||||
[ "$#" -gt 1 ] && return 1
|
||||
|
||||
case "$(get_magic_word "$1")" in
|
||||
eb48|eb63) ;;
|
||||
*)
|
||||
echo "Invalid image type"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
export_bootdevice && export_partdevice diskdev 0 || {
|
||||
echo "Unable to determine upgrade device"
|
||||
return 1
|
||||
}
|
||||
|
||||
get_partitions "/dev/$diskdev" bootdisk
|
||||
|
||||
#extract the boot sector from the image
|
||||
get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b 2>/dev/null
|
||||
|
||||
get_partitions /tmp/image.bs image
|
||||
|
||||
#compare tables
|
||||
diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
|
||||
|
||||
rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image
|
||||
|
||||
if [ -n "$diff" ]; then
|
||||
echo "Partition layout has changed. Full image will be written."
|
||||
ask_bool 0 "Abort" && exit 1
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
platform_copy_config() {
|
||||
local partdev
|
||||
|
||||
if export_partdevice partdev 1; then
|
||||
mount -t ext4 -o rw,noatime "/dev/$partdev" /mnt
|
||||
cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
|
||||
umount /mnt
|
||||
fi
|
||||
}
|
||||
|
||||
platform_do_upgrade() {
|
||||
local diskdev partdev diff
|
||||
|
||||
export_bootdevice && export_partdevice diskdev 0 || {
|
||||
echo "Unable to determine upgrade device"
|
||||
return 1
|
||||
}
|
||||
|
||||
sync
|
||||
|
||||
if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
|
||||
get_partitions "/dev/$diskdev" bootdisk
|
||||
|
||||
#extract the boot sector from the image
|
||||
get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b
|
||||
|
||||
get_partitions /tmp/image.bs image
|
||||
|
||||
#compare tables
|
||||
diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
|
||||
else
|
||||
diff=1
|
||||
fi
|
||||
|
||||
if [ -n "$diff" ]; then
|
||||
get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync
|
||||
|
||||
# Separate removal and addtion is necessary; otherwise, partition 1
|
||||
# will be missing if it overlaps with the old partition 2
|
||||
partx -d - "/dev/$diskdev"
|
||||
partx -a - "/dev/$diskdev"
|
||||
|
||||
return 0
|
||||
fi
|
||||
|
||||
#iterate over each partition from the image and write it to the boot disk
|
||||
while read part start size; do
|
||||
if export_partdevice partdev $part; then
|
||||
echo "Writing image to /dev/$partdev..."
|
||||
get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
|
||||
else
|
||||
echo "Unable to find partition $part device, skipped."
|
||||
fi
|
||||
done < /tmp/partmap.image
|
||||
|
||||
#copy partition uuid
|
||||
echo "Writing new UUID to /dev/$diskdev..."
|
||||
get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
|
||||
}
|
||||
Reference in New Issue
Block a user