Skip to content

Commit

Permalink
Add pv util and fix autoupdate.
Browse files Browse the repository at this point in the history
  • Loading branch information
anmaped committed Nov 21, 2018
1 parent 71f6336 commit 0d1384c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion buildopenfang.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

TAG=rc04_01
TAG=rc05_01

set -e

Expand Down
4 changes: 2 additions & 2 deletions config/buildroot.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Automatically generated file; DO NOT EDIT.
# Buildroot 2016.02-00007-g2ccb557 Configuration
# Buildroot 2016.02-00011-g71f6336 Configuration
#
BR2_HAVE_DOT_CONFIG=y

Expand Down Expand Up @@ -457,7 +457,7 @@ BR2_PACKAGE_MEMSTAT=y
# BR2_PACKAGE_NETPERF is not set
# BR2_PACKAGE_OPROFILE is not set
# BR2_PACKAGE_PAX_UTILS is not set
# BR2_PACKAGE_PV is not set
BR2_PACKAGE_PV=y
# BR2_PACKAGE_RAMSMP is not set
# BR2_PACKAGE_RAMSPEED is not set
# BR2_PACKAGE_RT_TESTS is not set
Expand Down
10 changes: 5 additions & 5 deletions fs/etc/init.d/S40dafang
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ start | "")
mount -t jffs2 /dev/mtdblock9 /params

# Detect other partitions available in the microSD
[[ -f "/dev/mmcblk0p2" ]] || {
[ -b "/dev/mmcblk0p2" ] && {
mkdir -p /mnt/mmcblk0p2
mount /dev/mmcblk0p2 /mnt/mmcblk0p2
}
[[ -f "/dev/mmcblk0p3" ]] || {
[ -b "/dev/mmcblk0p3" ] && {
mkdir -p /mnt/mmcblk0p3
mount /dev/mmcblk0p3 /mnt/mmcblk0p3
}
[[ -f "/dev/mmcblk0p4" ]] || {
[ -b "/dev/mmcblk0p4" ] && {
mkdir -p /mnt/mmcblk0p4
mount /dev/mmcblk0p4 /mnt/mmcblk0p4
}
[[ -f "/dev/mmcblk0p5" ]] || {
[ -b "/dev/mmcblk0p5" ] && {
mkdir -p /mnt/mmcblk0p5
mount /dev/mmcblk0p5 /mnt/mmcblk0p5
}

# Try to find wpa_supplicant.conf in one of the available partitions
PATH_TO_WPACONF=$(find /mnt -name "wpa_supplicant.conf")
[[ -z "$PATH_TO_WPACONF" ]] || {
[ -z "$PATH_TO_WPACONF" ] || {
echo "Copying wpa_supplicant.conf ..."
cp $PATH_TO_WPACONF /etc
}
Expand Down
25 changes: 20 additions & 5 deletions fs/opt/autoupdate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ ID=
WORKING_DIR=/mnt/mmcblk0p2

update() {
xz -cd images-$ID.tar.xz | tar xvf -

[[ -d "/mnt/update" ]] || { mkdir /mnt/update; }
echo "Update is starting..."

# check if there is enough memory available
[ $(free | head -3 | tail -1 | awk '{printf $4}') -gt 64000 ] || { echo "No free ram available! Try to disable HD mode first..."; exit 1; }

xz -cd images-$ID.tar.xz | pv -s $(printf "%.0f\n" $(xz -l images-$ID.tar.xz | tail -n 1 | awk '{print $5}'))m | tar xvf -

[ -d "/mnt/update" ] || { mkdir /mnt/update; }

mount -t ext3 -o loop openfang-images/rootfs.ext2 /mnt/update

Expand All @@ -30,7 +36,7 @@ version)
--id=*)
ID_NEW=$(echo "$1" | cut -d "=" -f 2)
echo "$ID_NEW"
[[ ! -f "$WORKING_DIR/images-$ID_NEW.tar.xz" ]] || {
[ -f "$WORKING_DIR/images-$ID_NEW.tar.xz" ] && {
cd $WORKING_DIR
update
exit 0
Expand All @@ -53,7 +59,7 @@ version)
VERSION_=$(date -d "$VERSION" +%s)
NEW_VER_=$(date -d "$NEW_VER" +%s)

if [[ "$VERSION_" -lt "$NEW_VER_" ]]; then
if [ "$VERSION_" -lt "$NEW_VER_" ]; then
echo "***"
echo "$VERSION ($VERSION_) will be updated to $NEW_VER ($NEW_VER_)"
echo "***"
Expand All @@ -67,15 +73,24 @@ version)
echo "Current version is $date_b ($date_b_) and will be updated to $VERSION ($VERSION_)"
echo "***"

[[ "$VERSION_" -le "$date_b_" ]] && {
[ "$VERSION_" -le "$date_b_" ] && {
echo "nothing to do."
exit 0
}

# check if there is a second partition
[ -d "$WORKING_DIR" ] || { echo "A second partition is not available to extract files!"; exit 1; }

# check if there is 500mb free space available
[ $(df -k "$WORKING_DIR" | tail -n 1 | awk '{printf $4}') -gt 500000 ] || { echo "No space available!"; exit 1; }

cd $WORKING_DIR

curl -L --insecure https://github.com/anmaped/openfang/releases/download/$TAG/images-$ID.tar.xz -o images-$ID.tar.xz

# check if file exists
[ -f "images-$ID.tar.xz" ] || { echo "Something wrong happen with the downloaded file."; exit 1; }

update
;;

Expand Down

0 comments on commit 0d1384c

Please sign in to comment.