BusyBox tar does not support gz; use plain tar archives
This commit is contained in:
parent
919a275fe3
commit
cbdf3860b0
12
build-tgr.sh
12
build-tgr.sh
@ -51,12 +51,12 @@ cp target/keys/signingpub.pem target/overlay/pub.pem
|
||||
echo "[+] Generating sample update package"
|
||||
mkdir -p home/update
|
||||
echo "sample update" > home/update/sample.txt
|
||||
tar -cvzf update.tgz home
|
||||
openssl dgst -sha256 -sign target/keys/signingkey.pem -out update.tgz.sig update.tgz
|
||||
cat update.tgz > update.tgz.cc
|
||||
cat update.tgz.sig >> update.tgz.cc
|
||||
mv update.tgz.cc target/overlay
|
||||
rm -rf home update.tgz update.tgz.sig
|
||||
tar -cvf update.tar home
|
||||
openssl dgst -sha256 -sign target/keys/signingkey.pem -out update.tar.sig update.tar
|
||||
cat update.tar > update.tar.cc
|
||||
cat update.tar.sig >> update.tar.cc
|
||||
mv update.tar.cc target/overlay
|
||||
rm -rf home update.tar update.tar.sig
|
||||
|
||||
echo "[+] Generating Monitoring SSH Key"
|
||||
ssh-keygen -t ecdsa -f target/keys/sshkey -q -N ""
|
||||
|
@ -15,7 +15,8 @@ fi
|
||||
|
||||
|
||||
pubkey="/pub.pem"
|
||||
file="/tmp/update.tgz.cc"
|
||||
file="/tmp/update.tar.cc"
|
||||
/bin/chmod 777 $file
|
||||
/bin/echo "### ccOS Update Script ###"
|
||||
/bin/echo "[+] Starting"
|
||||
/bin/sleep 1
|
||||
@ -25,19 +26,17 @@ if [[ -L $file ]]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
/bin/dd if=/tmp/update.tgz.cc of=sig bs=1 count=256 skip=$skip
|
||||
/usr/bin/truncate -s $skip update.tgz.cc
|
||||
check=`/usr/bin/openssl dgst -sha256 -verify $pubkey -signature /tmp/sig /tmp/update.tgz.cc`
|
||||
/bin/dd if=/tmp/update.tar.cc of=sig bs=1 count=256 skip=$skip
|
||||
/usr/bin/truncate -s $skip $file
|
||||
check=`/usr/bin/openssl dgst -sha256 -verify $pubkey -signature /tmp/sig $file`
|
||||
if [ "$check" == "Verified OK" ]
|
||||
then
|
||||
/bin/echo "[+] Signature is valid!"
|
||||
/bin/echo "[+] Upgrading..."
|
||||
/bin/tar -xvzf /tmp/update.tgz.cc -C /
|
||||
/bin/rm /tmp/update.tgz.cc /tmp/sig
|
||||
/bin/tar -xvf $file -C /
|
||||
/bin/rm $file /tmp/sig
|
||||
/bin/echo "[+] Done"
|
||||
exit 0
|
||||
else
|
||||
/bin/echo "[-] Signature error, exiting..."
|
||||
/bin/rm /tmp/update.tgz.cc /tmp/sig
|
||||
exit 1
|
||||
/bin/rm $file /tmp/sig
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user