busybox/base-files forged packages

This commit is contained in:
Conor Horan-Kates
2016-11-18 15:49:40 -08:00
parent 72a27eb586
commit 38465f7280
494 changed files with 12080 additions and 2 deletions

View File

@ -0,0 +1,3 @@
#!/bin/sh
/sbin/jffs2reset $@

View File

@ -0,0 +1,18 @@
#!/bin/sh
# Copyright (C) 2006-2010 OpenWrt.org
export HOTPLUG_TYPE="$1"
. /lib/functions.sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
LOGNAME=root
USER=root
export PATH LOGNAME USER
export DEVICENAME="${DEVPATH##*/}"
[ \! -z "$1" -a -d /etc/hotplug.d/$1 ] && {
for script in $(ls /etc/hotplug.d/$1/* 2>&-); do (
[ -f $script ] && . $script
); done
}

View File

@ -0,0 +1,25 @@
#!/bin/sh
# (C) 2008 openwrt.org
. /lib/functions.sh
ACTION=$1
NAME=$2
do_led() {
local name
local sysfs
config_get name $1 name
config_get sysfs $1 sysfs
[ "$name" = "$NAME" -o "$sysfs" = "$NAME" -a -e "/sys/class/leds/${sysfs}" ] && {
[ "$ACTION" = "set" ] &&
echo 1 >/sys/class/leds/${sysfs}/brightness \
|| echo 0 >/sys/class/leds/${sysfs}/brightness
exit 0
}
}
[ "$1" = "clear" -o "$1" = "set" ] &&
[ -n "$2" ] &&{
config_load system
config_foreach do_led
exit 1
}

View File

@ -0,0 +1,240 @@
#!/bin/sh
. /lib/functions.sh
. /lib/functions/system.sh
# initialize defaults
RAMFS_COPY_BIN="" # extra programs for temporary ramfs root
RAMFS_COPY_DATA="" # extra data files
export MTD_CONFIG_ARGS=""
export INTERACTIVE=0
export VERBOSE=1
export SAVE_CONFIG=1
export SAVE_OVERLAY=0
export DELAY=
export CONF_IMAGE=
export CONF_BACKUP_LIST=0
export CONF_BACKUP=
export CONF_RESTORE=
export NEED_IMAGE=
export HELP=0
export FORCE=0
export TEST=0
# parse options
while [ -n "$1" ]; do
case "$1" in
-i) export INTERACTIVE=1;;
-d) export DELAY="$2"; shift;;
-v) export VERBOSE="$(($VERBOSE + 1))";;
-q) export VERBOSE="$(($VERBOSE - 1))";;
-n) export SAVE_CONFIG=0;;
-c) export SAVE_OVERLAY=1;;
-b|--create-backup) export CONF_BACKUP="$2" NEED_IMAGE=1; shift;;
-r|--restore-backup) export CONF_RESTORE="$2" NEED_IMAGE=1; shift;;
-l|--list-backup) export CONF_BACKUP_LIST=1; break;;
-f) export CONF_IMAGE="$2"; shift;;
-F|--force) export FORCE=1;;
-T|--test) export TEST=1;;
-h|--help) export HELP=1; break;;
-*)
echo "Invalid option: $1"
exit 1
;;
*) break;;
esac
shift;
done
export CONFFILES=/tmp/sysupgrade.conffiles
export CONF_TAR=/tmp/sysupgrade.tgz
export ARGV="$*"
export ARGC="$#"
[ -z "$ARGV" -a -z "$NEED_IMAGE" -o $HELP -gt 0 ] && {
cat <<EOF
Usage: $0 [<upgrade-option>...] <image file or URL>
$0 [-q] [-i] <backup-command> <file>
upgrade-option:
-d <delay> add a delay before rebooting
-f <config> restore configuration from .tar.gz (file or url)
-i interactive mode
-c attempt to preserve all changed files in /etc/
-n do not save configuration over reflash
-T | --test
Verify image and config .tar.gz but do not actually flash.
-F | --force
Flash image even if image checks fail, this is dangerous!
-q less verbose
-v more verbose
-h | --help display this help
backup-command:
-b | --create-backup <file>
create .tar.gz of files specified in sysupgrade.conf
then exit. Does not flash an image. If file is '-',
i.e. stdout, verbosity is set to 0 (i.e. quiet).
-r | --restore-backup <file>
restore a .tar.gz created with sysupgrade -b
then exit. Does not flash an image. If file is '-',
the archive is read from stdin.
-l | --list-backup
list the files that would be backed up when calling
sysupgrade -b. Does not create a backup file.
EOF
exit 1
}
[ -n "$ARGV" -a -n "$NEED_IMAGE" ] && {
cat <<-EOF
-b|--create-backup and -r|--restore-backup do not perform a firmware upgrade.
Do not specify both -b|-r and a firmware image.
EOF
exit 1
}
# prevent messages from clobbering the tarball when using stdout
[ "$CONF_BACKUP" = "-" ] && export VERBOSE=0
add_uci_conffiles() {
local file="$1"
( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
/etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null) \
-type f -o -type l 2>/dev/null;
opkg list-changed-conffiles ) | sort -u > "$file"
return 0
}
add_overlayfiles() {
local file="$1"
if [ -d /overlay/upper ]; then
local overlaydir="/overlay/upper"
else
local overlaydir="/overlay"
fi
find $overlaydir/etc/ -type f -o -type l | sed \
-e 's,^/overlay/,/,' \
-e '\,/META_[a-zA-Z0-9]*$,d' \
-e '\,/functions.sh$,d' \
-e '\,/[^/]*-opkg$,d' \
> "$file"
return 0
}
# hooks
sysupgrade_image_check="platform_check_image"
[ $SAVE_OVERLAY = 0 -o ! -d /overlay/etc ] && \
sysupgrade_init_conffiles="add_uci_conffiles" || \
sysupgrade_init_conffiles="add_overlayfiles"
include /lib/upgrade
[ "$1" = "nand" ] && nand_upgrade_stage2 $@
do_save_conffiles() {
local conf_tar="${1:-$CONF_TAR}"
[ -z "$(rootfs_type)" ] && {
echo "Cannot save config while running from ramdisk."
ask_bool 0 "Abort" && exit
return 0
}
run_hooks "$CONFFILES" $sysupgrade_init_conffiles
ask_bool 0 "Edit config file list" && vi "$CONFFILES"
v "Saving config files..."
[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
tar c${TAR_V}zf "$conf_tar" -T "$CONFFILES" 2>/dev/null
rm -f "$CONFFILES"
}
if [ $CONF_BACKUP_LIST -eq 1 ]; then
add_uci_conffiles "$CONFFILES"
cat "$CONFFILES"
rm -f "$CONFFILES"
exit 0
fi
if [ -n "$CONF_BACKUP" ]; then
do_save_conffiles "$CONF_BACKUP"
exit $?
fi
if [ -n "$CONF_RESTORE" ]; then
if [ "$CONF_RESTORE" != "-" ] && [ ! -f "$CONF_RESTORE" ]; then
echo "Backup archive '$CONF_RESTORE' not found."
exit 1
fi
[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
tar -C / -x${TAR_V}zf "$CONF_RESTORE"
exit $?
fi
type platform_check_image >/dev/null 2>/dev/null || {
echo "Firmware upgrade is not implemented for this platform."
exit 1
}
for check in $sysupgrade_image_check; do
( eval "$check \"\$ARGV\"" ) || {
if [ $FORCE -eq 1 ]; then
echo "Image check '$check' failed but --force given - will update anyway!"
break
else
echo "Image check '$check' failed."
exit 1
fi
}
done
if [ -n "$CONF_IMAGE" ]; then
case "$(get_magic_word $CONF_IMAGE cat)" in
# .gz files
1f8b) ;;
*)
echo "Invalid config file. Please use only .tar.gz files"
exit 1
;;
esac
get_image "$CONF_IMAGE" "cat" > "$CONF_TAR"
export SAVE_CONFIG=1
elif ask_bool $SAVE_CONFIG "Keep config files over reflash"; then
[ $TEST -eq 1 ] || do_save_conffiles
export SAVE_CONFIG=1
else
export SAVE_CONFIG=0
fi
if [ $TEST -eq 1 ]; then
exit 0
fi
run_hooks "" $sysupgrade_pre_upgrade
# Some platforms/devices may want different sysupgrade process, e.g. without
# killing processes yet or calling ubus system upgrade method.
# This is needed e.g. on NAND devices where we just want to trigger stage1 at
# this point.
if type 'platform_pre_upgrade' >/dev/null 2>/dev/null; then
platform_pre_upgrade "$ARGV"
fi
ubus call system upgrade
touch /tmp/sysupgrade
if [ ! -f /tmp/failsafe ] ; then
kill_remaining TERM
sleep 3
kill_remaining KILL
fi
if [ -n "$(rootfs_type)" ]; then
v "Switching to ramdisk..."
run_ramfs '. /lib/functions.sh; include /lib/upgrade; do_upgrade'
else
do_upgrade
fi

236
lg_webOS/base-files/ipk/sbin/wifi Executable file
View File

@ -0,0 +1,236 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
usage() {
cat <<EOF
Usage: $0 [down|detect|reload|status]
enables (default), disables or detects a wifi configuration.
EOF
exit 1
}
ubus_wifi_cmd() {
local cmd="$1"
local dev="$2"
json_init
[ -n "$2" ] && json_add_string device "$2"
ubus call network.wireless "$1" "$(json_dump)"
}
find_net_config() {(
local vif="$1"
local cfg
local ifname
config_get cfg "$vif" network
[ -z "$cfg" ] && {
include /lib/network
scan_interfaces
config_get ifname "$vif" ifname
cfg="$(find_config "$ifname")"
}
[ -z "$cfg" ] && return 0
echo "$cfg"
)}
bridge_interface() {(
local cfg="$1"
[ -z "$cfg" ] && return 0
include /lib/network
scan_interfaces
for cfg in $cfg; do
config_get iftype "$cfg" type
[ "$iftype" = bridge ] && config_get "$cfg" ifname
prepare_interface_bridge "$cfg"
return $?
done
)}
prepare_key_wep() {
local key="$1"
local hex=1
echo -n "$key" | grep -qE "[^a-fA-F0-9]" && hex=0
[ "${#key}" -eq 10 -a $hex -eq 1 ] || \
[ "${#key}" -eq 26 -a $hex -eq 1 ] || {
[ "${key:0:2}" = "s:" ] && key="${key#s:}"
key="$(echo -n "$key" | hexdump -ve '1/1 "%02x" ""')"
}
echo "$key"
}
wifi_fixup_hwmode() {
local device="$1"
local default="$2"
local hwmode hwmode_11n
config_get channel "$device" channel
config_get hwmode "$device" hwmode
case "$hwmode" in
11bg) hwmode=bg;;
11a) hwmode=a;;
11b) hwmode=b;;
11g) hwmode=g;;
11n*)
hwmode_11n="${hwmode##11n}"
case "$hwmode_11n" in
a|g) ;;
default) hwmode_11n="$default"
esac
config_set "$device" hwmode_11n "$hwmode_11n"
;;
*)
hwmode=
if [ "${channel:-0}" -gt 0 ]; then
if [ "${channel:-0}" -gt 14 ]; then
hwmode=a
else
hwmode=g
fi
else
hwmode="$default"
fi
;;
esac
config_set "$device" hwmode "$hwmode"
}
_wifi_updown() {
for device in ${2:-$DEVICES}; do (
config_get disabled "$device" disabled
[ "$disabled" = "1" ] && {
echo "'$device' is disabled"
set disable
}
config_get iftype "$device" type
if eval "type ${1}_$iftype" 2>/dev/null >/dev/null; then
eval "scan_$iftype '$device'"
eval "${1}_$iftype '$device'" || echo "$device($iftype): ${1} failed"
elif [ ! -f /lib/netifd/wireless/$iftype.sh ]; then
echo "$device($iftype): Interface type not supported"
fi
); done
}
wifi_updown() {
cmd=down
[ enable = "$1" ] && {
_wifi_updown disable "$2"
ubus_wifi_cmd "$cmd" "$2"
scan_wifi
cmd=up
}
ubus_wifi_cmd "$cmd" "$2"
_wifi_updown "$@"
}
wifi_reload_legacy() {
_wifi_updown "disable" "$1"
scan_wifi
_wifi_updown "enable" "$1"
}
wifi_reload() {
ubus call network reload
wifi_reload_legacy
}
wifi_detect() {
for driver in ${2:-$DRIVERS}; do (
if eval "type detect_$driver" 2>/dev/null >/dev/null; then
eval "detect_$driver" || echo "$driver: Detect failed" >&2
else
echo "$driver: Hardware detection not supported" >&2
fi
); done
}
start_net() {(
local iface="$1"
local config="$2"
local vifmac="$3"
[ -f "/var/run/$iface.pid" ] && kill "$(cat /var/run/${iface}.pid)" 2>/dev/null
[ -z "$config" ] || {
include /lib/network
scan_interfaces
for config in $config; do
setup_interface "$iface" "$config" "" "$vifmac"
done
}
)}
set_wifi_up() {
local cfg="$1"
local ifname="$2"
uci_set_state wireless "$cfg" up 1
uci_set_state wireless "$cfg" ifname "$ifname"
}
set_wifi_down() {
local cfg="$1"
local vifs vif vifstr
[ -f "/var/run/wifi-${cfg}.pid" ] &&
kill "$(cat "/var/run/wifi-${cfg}.pid")" 2>/dev/null
uci_revert_state wireless "$cfg"
config_get vifs "$cfg" vifs
for vif in $vifs; do
uci_revert_state wireless "$vif"
done
}
scan_wifi() {
local cfgfile="$1"
DEVICES=
config_cb() {
local type="$1"
local section="$2"
# section start
case "$type" in
wifi-device)
append DEVICES "$section"
config_set "$section" vifs ""
config_set "$section" ht_capab ""
;;
esac
# section end
config_get TYPE "$CONFIG_SECTION" TYPE
case "$TYPE" in
wifi-iface)
config_get device "$CONFIG_SECTION" device
config_get vifs "$device" vifs
append vifs "$CONFIG_SECTION"
config_set "$device" vifs "$vifs"
;;
esac
}
config_load "${cfgfile:-wireless}"
}
DEVICES=
DRIVERS=
include /lib/wifi
scan_wifi
case "$1" in
down) wifi_updown "disable" "$2";;
detect) wifi_detect "$2";;
status) ubus_wifi_cmd "status" "$2";;
reload) wifi_reload "$2";;
reload_legacy) wifi_reload_legacy "$2";;
--help|help) usage;;
*) ubus call network reload; wifi_updown "enable" "$2";;
esac