Skip to content

Commit

Permalink
Merge remote-tracking branch 'thingos/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrisan committed Jun 6, 2020
2 parents 6c31350 + e95375e commit 12afca5
Show file tree
Hide file tree
Showing 23 changed files with 106 additions and 55 deletions.
1 change: 0 additions & 1 deletion board/bananapim1/overlay-initramfs/remove_initramfs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ if [ -f /boot/boot-normal.scr ]; then
mv /boot/boot.scr /boot/boot-fwupdater.scr
mv /boot/boot-normal.scr /boot/boot.scr
fi

2 changes: 1 addition & 1 deletion board/common/overlay/etc/crontabs/root
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
14 3 * * * /usr/sbin/logrotate /etc/logrotate.conf
13 * * * * /usr/sbin/logrotate /etc/logrotate.conf
0 2 * * 0 /usr/sbin/https-update
*/15 * * * * /usr/sbin/dyndns-update
33 changes: 29 additions & 4 deletions board/common/overlay/etc/init.d/S33hostapd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ test -x ${PROG} || exit 0
test -n "${OS_VERSION}" || source /etc/init.d/base

prepare_conf ${CONF} ${SYS_CONF} ${BOOT_CONF}
test -s ${CONF} || exit 0

test -s ${WATCH_CONF} && source ${WATCH_CONF}

Expand All @@ -38,7 +37,20 @@ watch() {
done
}

start() {
prepare_ap_ifaces() {
wifi_ifaces=$(ip link | grep -oE 'wlan[[:digit:]]')
msg_begin "Preparing AP interfaces"
ap_ifaces=""
for iface in ${wifi_ifaces}; do
ap_iface=ap${iface: -1}
if iw dev ${iface} interface add ${ap_iface} type __ap &>/dev/null; then
ap_ifaces+="${ap_iface} "
fi
done
msg_done "${ap_ifaces:-none}"
}

start_hostapd() {
msg_begin "Starting hostapd"

# wait up to 5 seconds for interface
Expand All @@ -65,13 +77,27 @@ start() {
test -n "${module}" && msg_done "done (${module})"|| msg_done
}

stop() {
stop_hostapd() {
msg_begin "Stopping hostpad"
killall hostapd &>/dev/null
ps | grep hostapd | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
msg_done
}

start() {
prepare_ap_ifaces

if [[ -s ${CONF} ]]; then
start_hostapd
fi
}

stop() {
if [[ -s ${CONF} ]]; then
stop_hostapd
fi
}

case "$1" in
start)
start
Expand All @@ -90,4 +116,3 @@ case "$1" in
echo "Usage: $0 {start|stop|restart}"
exit 1
esac

8 changes: 5 additions & 3 deletions board/common/overlay/sbin/fwupdate
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function show_versions() {
show_json=$1

# the /usr/libexec/list-versions-* helpers return a table with the following format:
# <version>|<prerelease>|<board>|<url>|<date>
# <version>|<prerelease>|<board>|<url>|<date|published>
versions=$(FW_USERNAME=${OS_FIRMWARE_USERNAME} FW_PASSWORD=${OS_FIRMWARE_PASSWORD} \
/usr/libexec/list-versions-${OS_FIRMWARE_METHOD} ${OS_FIRMWARE_REPO})

Expand All @@ -223,15 +223,17 @@ function show_versions() {
if [[ "${OS_PRERELEASES}" == "false" && "${varr[1]}" == "true" ]]; then
continue # skip prereleases
fi
if [[ "${varr[5]}" == "false" ]]; then
continue # skip unpublished
fi
if [[ "${board}" != "${varr[2]}" ]]; then
continue # skip other boards
fi

if [[ "${show_json}" == "true" ]]; then
echo "{\"version\": \"${varr[0]}\"," \
"\"url\": \"${varr[3]}\"," \
"\"board\": \"${varr[2]}\"," \
"\"prerelease\": ${varr[1]}," \
"\"prerelease\": ${varr[1]:-false}," \
"\"date\": \"${varr[4]}\"}"
else
echo ${varr[0]}
Expand Down
8 changes: 6 additions & 2 deletions board/common/overlay/usr/libexec/list-versions-bitbucket
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ function check_prerelease() {
fi
}

function add_published_flag() {
read line
echo "${line}|true"
}

extensions=".img.gz .img.xz .img"
opts="-s -S -f"
test -n "${FW_USERNAME}" && opts+=" --user ${FW_USERNAME}:${FW_PASSWORD}"
Expand All @@ -23,6 +28,5 @@ rtrimstr=$(for e in ${extensions}; do echo -n " | rtrimstr(\"${e}\")"; done)
jq_expr=".values[] | [{a: .name | split(\"-\"), url: .links.self.href, date: .created_on | split(\"T\")[0]}] |
map((.a[2] ${rtrimstr}), \"false\", .a[1], .url, .date) | join(\"|\")"

curl ${opts} ${url} | jq --raw-output "${jq_expr}" | while read line; do echo "${line}" | check_prerelease; done
curl ${opts} ${url} | jq --raw-output "${jq_expr}" | while read line; do echo "${line}" | check_prerelease | add_published_flag; done
exit ${PIPESTATUS[0]}

16 changes: 11 additions & 5 deletions board/common/overlay/usr/libexec/list-versions-github
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ fi

opts="-s -S -f"
test -n "${FW_USERNAME}" && opts+=" --user ${FW_USERNAME}:${FW_PASSWORD}"
url=https://api.github.com/repos/$1/releases
releases_url=https://api.github.com/repos/$1/releases

# Get release info via GitHub API
releases=$(curl ${opts} ${releases_url})
test $? == 0 || exit 1

# Format release lines
jq_expr='.[] | {version: .name, prerelease: .prerelease | tostring} +
(.assets[] | {name: .name | split("-")[1], url: .browser_download_url}) +
({date: .created_at | split("T")[0]}) | flatten | join("|")'

curl ${opts} ${url} | jq --raw-output "${jq_expr}"
exit ${PIPESTATUS[0]}
({date: .created_at | split("T")[0]}) +
({published: true})
| flatten | join("|")'

jq --raw-output "${jq_expr}" <<< ${releases}
exit $?
16 changes: 13 additions & 3 deletions board/common/overlay/usr/libexec/list-versions-s3
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,43 @@ bucket=$(echo ${bucket_path} | cut -d '/' -f 1)
path=${bucket_path:${#bucket} + 1}

opts="-s -S -f"
max_keys="1000"
test -n "${FW_USERNAME}" && opts+=" --user ${FW_USERNAME}:${FW_PASSWORD}"
url="https://${bucket}.s3.amazonaws.com"

xml_result=$(curl ${opts} "${url}?list-type=2&prefix=${path}")
xml_result=$(curl ${opts} "${url}?list-type=2&max_keys=${max_keys}&prefix=${path}&fetch-owner=true")
keys=$(echo "${xml_result}" | grep -oE '<Key>[^<]+<\/Key>' | sed 's/<Key>\(.*\)<\/Key>/\1/')
dates=$(echo "${xml_result}" | grep -oE '<LastModified>[^<]+<\/LastModified>' | sed 's/<LastModified>\(.*\)<\/LastModified>/\1/')
storage_classes=$(echo "${xml_result}" | grep -oE '<StorageClass>[^<]+<\/StorageClass>' | sed 's/<StorageClass>\(.*\)<\/StorageClass>/\1/')
dates=(${dates})
files=(${keys})
storage_classes=(${storage_classes})

i=0
for file in ${files[*]}; do
[[ "${file}" =~ ^${path}/(.+)/(.+)$ ]] || continue
version="${BASH_REMATCH[1]}"
fname="${BASH_REMATCH[2]}"

prerelease=false

if [[ "${version}" =~ ^.*[abc]\.?[0-9]+$ ]] || # e.g. 0.4.1b2, 0.4.1b.2, 0.4.1-b.2
[[ "${version}" =~ ^.*(alpha|beta|rc)\.?[0-9]+$ ]] || # e.g. 0.4.1beta2, 0.4.1beta.2, 0.4.1-beta.2
[[ "${version}" =~ ^(dev|nightly).*$ ]]; then # e.g. dev20180314, nightly20180314
prerelease=true
fi

# Items with REDUCED_REDUNDANCY storage class are considered, by convention, unpublished
published="true"
storage_class=${storage_classes[${i}]}
if [[ "${storage_class}" == "REDUCED_REDUNDANCY" ]]; then
published="false"
fi

[[ "${fname}" =~ ^([^-]+)-([^-]+)-(.+)$ ]] || continue
board="${BASH_REMATCH[2]}"
final_url="${url}/${path}/${version}/${fname}"
date="${dates[${i}]:0:10}"

echo "${version}|${prerelease}|${board}|${final_url}|${date}"
echo "${version}|${prerelease}|${board}|${final_url}|${date}|${published}"
i=$((i + 1))
done | semver-sort -r -t '|' -k 1
1 change: 0 additions & 1 deletion board/odroidc1/overlay-initramfs/prepare_initramfs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
mkdir /system
mount /dev/mmcblk0p2 /system
/system/bin/busybox insmod /system/lib/modules/*/kernel/fs/nls/nls_cp437.ko

1 change: 0 additions & 1 deletion board/odroidc1/overlay-initramfs/remove_initramfs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/sh

sed -i 's/00 0x22000000 0x/00 - 0x/' /boot/boot.ini

1 change: 0 additions & 1 deletion board/odroidc2/overlay-initramfs/remove_initramfs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/sh

sed -i 's/00 0x13000000 0x/00 - 0x/' /boot/boot.ini

1 change: 0 additions & 1 deletion board/odroidxu4/overlay-initramfs/remove_initramfs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/sh

sed -i 's/00 0x42000000 0x/00 - 0x/' /boot/boot.ini

1 change: 0 additions & 1 deletion board/pine64/overlay-initramfs/remove_initramfs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/sh

sed -i 's/initrd_filename=/#initrd_filename=/' /boot/uEnv.txt

Binary file modified board/raspberrypi/initrd.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion board/raspberrypi/overlay-initramfs/remove_initramfs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh

sed -i 's/^initramfs.*//g' /boot/config.txt

sed -i '/^ *$/d' /boot/config.txt # Remove blank lines
17 changes: 10 additions & 7 deletions board/raspberrypi/overlay/etc/init.d/S11throttlewatch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

CHECK_INTERVAL=30
CHECK_INTERVAL=60


test -n "${OS_VERSION}" || source /etc/init.d/base
Expand All @@ -19,12 +19,16 @@ get_throttled_since_boot() {
test $((t & 262144)) -ne 0 && echo -n "throttled "
}

get_temp() {
t=$(</sys/class/thermal/thermal_zone0/temp)
echo "$((t / 1000))"
}

watch_now() {
while true; do
t=$(get_throttled_now)
if [[ -n "${t}" ]]; then
logger -t throttlewatch -s "currently: ${t}"
fi
th=$(get_throttled_now)
te=$(get_temp)
logger -t throttlewatch "currently: ${th:-ok}, temperature: ${te} C"

sleep ${CHECK_INTERVAL}
done
Expand All @@ -34,7 +38,7 @@ watch_since_boot() {
while true; do
t=$(get_throttled_since_boot)
if [[ -n "${t}" ]]; then
logger -t throttlewatch -s "since boot: ${t}"
logger -t throttlewatch "since boot: ${t}"
break
fi

Expand Down Expand Up @@ -62,4 +66,3 @@ case "$1" in
esac

exit $?

1 change: 0 additions & 1 deletion board/raspberrypi/overlay/usr/libexec/fw-prepare-boot
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

echo >> /boot/config.txt
echo "initramfs initrd.gz" >> /boot/config.txt

1 change: 0 additions & 1 deletion board/raspberrypi/overlay/usr/libexec/fw-restore-boot-cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ fi

old_boot=$1
cp ${old_boot}/config.txt /boot

Binary file modified board/raspberrypi2/initrd.gz
Binary file not shown.
17 changes: 10 additions & 7 deletions board/raspberrypi2/overlay/etc/init.d/S11throttlewatch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

CHECK_INTERVAL=30
CHECK_INTERVAL=60


test -n "${OS_VERSION}" || source /etc/init.d/base
Expand All @@ -19,12 +19,16 @@ get_throttled_since_boot() {
test $((t & 262144)) -ne 0 && echo -n "throttled "
}

get_temp() {
t=$(</sys/class/thermal/thermal_zone0/temp)
echo "$((t / 1000))"
}

watch_now() {
while true; do
t=$(get_throttled_now)
if [[ -n "${t}" ]]; then
logger -t throttlewatch -s "currently: ${t}"
fi
th=$(get_throttled_now)
te=$(get_temp)
logger -t throttlewatch "currently: ${th:-ok}, temperature: ${te} C"

sleep ${CHECK_INTERVAL}
done
Expand All @@ -34,7 +38,7 @@ watch_since_boot() {
while true; do
t=$(get_throttled_since_boot)
if [[ -n "${t}" ]]; then
logger -t throttlewatch -s "since boot: ${t}"
logger -t throttlewatch "since boot: ${t}"
break
fi

Expand Down Expand Up @@ -62,4 +66,3 @@ case "$1" in
esac

exit $?

Binary file modified board/raspberrypi3/initrd.gz
Binary file not shown.
17 changes: 10 additions & 7 deletions board/raspberrypi3/overlay/etc/init.d/S11throttlewatch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

CHECK_INTERVAL=30
CHECK_INTERVAL=60


test -n "${OS_VERSION}" || source /etc/init.d/base
Expand All @@ -19,12 +19,16 @@ get_throttled_since_boot() {
test $((t & 262144)) -ne 0 && echo -n "throttled "
}

get_temp() {
t=$(</sys/class/thermal/thermal_zone0/temp)
echo "$((t / 1000))"
}

watch_now() {
while true; do
t=$(get_throttled_now)
if [[ -n "${t}" ]]; then
logger -t throttlewatch -s "currently: ${t}"
fi
th=$(get_throttled_now)
te=$(get_temp)
logger -t throttlewatch "currently: ${th:-ok}, temperature: ${te} C"

sleep ${CHECK_INTERVAL}
done
Expand All @@ -34,7 +38,7 @@ watch_since_boot() {
while true; do
t=$(get_throttled_since_boot)
if [[ -n "${t}" ]]; then
logger -t throttlewatch -s "since boot: ${t}"
logger -t throttlewatch "since boot: ${t}"
break
fi

Expand Down Expand Up @@ -62,4 +66,3 @@ case "$1" in
esac

exit $?

Binary file modified board/raspberrypi4/initrd.gz
Binary file not shown.
Loading

0 comments on commit 12afca5

Please sign in to comment.