Skip to content

Commit

Permalink
initscripts: update data partition on boot
Browse files Browse the repository at this point in the history
If venus-data.{tar.gz,tgz,zip} is found on removable storage when booting,
unpack it into /data.
  • Loading branch information
mansr authored and Jeroen Hofstee committed May 13, 2019
1 parent ab148f1 commit 469760f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
28 changes: 28 additions & 0 deletions meta-venus/recipes-core/initscripts/files/update-data.sh
@@ -0,0 +1,28 @@
#! /bin/sh

ARCHIVE_NAME=venus-data
ARCHIVE_SUF="tar.gz tgz zip"

unpack() {
archive=$1
dest=$2

case $archive in
*.tar.gz|*.tgz)
tar xzf "$archive" -C "$dest"
;;
*.zip)
unzip -d "$dest" "$archive"
;;
esac
}

for dir in /media/*; do
for suf in $ARCHIVE_SUF; do
archive=$dir/$ARCHIVE_NAME.$suf
if [ -f "$archive" ]; then
echo "Updating /data with $archive"
unpack "$archive" /data
fi
done
done
4 changes: 4 additions & 0 deletions meta-venus/recipes-core/initscripts/initscripts_%.bbappend
Expand Up @@ -7,6 +7,7 @@ SRC_URI += "\
file://static-nodes.sh \
file://test-data-partition.sh \
file://report-data-failure.sh \
file://update-data.sh \
"

SRC_URI_append_ccgx = "\
Expand All @@ -29,6 +30,9 @@ do_install_append() {
update-rc.d -r ${D} test-data-partition.sh start 03 S .

install -m 0755 ${WORKDIR}/report-data-failure.sh ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/update-data.sh ${D}${sysconfdir}/init.d

update-rc.d -r ${D} update-data.sh start 30 5 .
update-rc.d -r ${D} report-data-failure.sh start 82 5 .

rm ${D}${sysconfdir}/init.d/banner.sh
Expand Down

2 comments on commit 469760f

@photon-delight
Copy link

@photon-delight photon-delight commented on 469760f Jul 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unpacking of venus-data.zip file fails on my system, while unpacking venus-data.tar.gz is successful

@mpvader
Copy link
Contributor

@mpvader mpvader commented on 469760f Jul 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thank you; good to know.

Most likely this just is what it is; and some zip formats might work while others don’t. And, tar.gz working is good enough.

Please sign in to comment.