mirror of
https://github.com/AuxXxilium/arc-dsm.git
synced 2024-11-23 23:50:52 +07:00
dsm: update script
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
parent
4ef8004bc4
commit
29a8ac8a39
144
update.sh
144
update.sh
@ -37,80 +37,84 @@ while IFS= read -r line; do
|
||||
rm -rf "${CACHE_PATH}/dl"
|
||||
mkdir -p "${CACHE_PATH}/dl"
|
||||
|
||||
echo "Downloading ${PAT_FILE}"
|
||||
# Discover remote file size
|
||||
STATUS=`curl -k -w "%{http_code}" -L "${PAT_URL}" -o "${PAT_PATH}" --progress-bar`
|
||||
if [ $? -ne 0 -o ${STATUS} -ne 200 ]; then
|
||||
rm "${PAT_PATH}"
|
||||
echo "Error downloading"
|
||||
fi
|
||||
if [ -f "${PAT_PATH}" ]; then
|
||||
rm -rf "${UNTAR_PAT_PATH}"
|
||||
mkdir -p "${UNTAR_PAT_PATH}"
|
||||
echo -n "Disassembling ${PAT_FILE}: "
|
||||
|
||||
header=`od -bcN2 ${PAT_PATH} | head -1 | awk '{print $3}'`
|
||||
case ${header} in
|
||||
105)
|
||||
echo "Uncompressed tar"
|
||||
isencrypted="no"
|
||||
;;
|
||||
213)
|
||||
echo "Compressed tar"
|
||||
isencrypted="no"
|
||||
;;
|
||||
255)
|
||||
echo "Encrypted"
|
||||
isencrypted="yes"
|
||||
;;
|
||||
*)
|
||||
echo -e "Could not determine if pat file is encrypted or not, maybe corrupted, try again!"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "${isencrypted}" = "yes" ]; then
|
||||
# Check existance of extractor
|
||||
if [ -f "${EXTRACTOR_PATH}/${EXTRACTOR_BIN}" ]; then
|
||||
echo "Extractor cached."
|
||||
fi
|
||||
# Uses the extractor to untar pat file
|
||||
echo "Extracting..."
|
||||
LD_LIBRARY_PATH="${EXTRACTOR_PATH}" "${EXTRACTOR_PATH}/${EXTRACTOR_BIN}" "${PAT_PATH}" "${UNTAR_PAT_PATH}"
|
||||
else
|
||||
echo "Extracting..."
|
||||
tar -xf "${PAT_PATH}" -C "${UNTAR_PAT_PATH}"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error extracting"
|
||||
fi
|
||||
if [ ! -f "${PAT_PATH}" ]; then
|
||||
echo "Downloading ${PAT_FILE}"
|
||||
# Discover remote file size
|
||||
STATUS=`curl -k -w "%{http_code}" -L "${PAT_URL}" -o "${PAT_PATH}" --progress-bar`
|
||||
if [ $? -ne 0 -o ${STATUS} -ne 200 ]; then
|
||||
rm "${PAT_PATH}"
|
||||
echo "Error downloading"
|
||||
fi
|
||||
if [ -f "${PAT_PATH}" ]; then
|
||||
rm -rf "${UNTAR_PAT_PATH}"
|
||||
mkdir -p "${UNTAR_PAT_PATH}"
|
||||
echo -n "Disassembling ${PAT_FILE}: "
|
||||
|
||||
mkdir -p "${DESTINATION}"
|
||||
mkdir -p "${DESTINATIONFILES}"
|
||||
header=`od -bcN2 ${PAT_PATH} | head -1 | awk '{print $3}'`
|
||||
case ${header} in
|
||||
105)
|
||||
echo "Uncompressed tar"
|
||||
isencrypted="no"
|
||||
;;
|
||||
213)
|
||||
echo "Compressed tar"
|
||||
isencrypted="no"
|
||||
;;
|
||||
255)
|
||||
echo "Encrypted"
|
||||
isencrypted="yes"
|
||||
;;
|
||||
*)
|
||||
echo -e "Could not determine if pat file is encrypted or not, maybe corrupted, try again!"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -n "Checking hash of zImage: "
|
||||
HASH="`sha256sum ${UNTAR_PAT_PATH}/zImage | awk '{print$1}'`"
|
||||
echo "OK"
|
||||
echo "${HASH}" > "${DESTINATION}/zImage_hash"
|
||||
if [ "${isencrypted}" = "yes" ]; then
|
||||
# Check existance of extractor
|
||||
if [ -f "${EXTRACTOR_PATH}/${EXTRACTOR_BIN}" ]; then
|
||||
echo "Extractor cached."
|
||||
fi
|
||||
# Uses the extractor to untar pat file
|
||||
echo "Extracting..."
|
||||
LD_LIBRARY_PATH="${EXTRACTOR_PATH}" "${EXTRACTOR_PATH}/${EXTRACTOR_BIN}" "${PAT_PATH}" "${UNTAR_PAT_PATH}"
|
||||
else
|
||||
echo "Extracting..."
|
||||
tar -xf "${PAT_PATH}" -C "${UNTAR_PAT_PATH}"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error extracting"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -n "Checking hash of ramdisk: "
|
||||
HASH="`sha256sum ${UNTAR_PAT_PATH}/rd.gz | awk '{print$1}'`"
|
||||
echo "OK"
|
||||
echo "${HASH}" > "${DESTINATION}/ramdisk_hash"
|
||||
mkdir -p "${DESTINATION}"
|
||||
mkdir -p "${DESTINATIONFILES}"
|
||||
|
||||
echo -n "Copying files: "
|
||||
cp "${UNTAR_PAT_PATH}/grub_cksum.syno" "${DESTINATION}"
|
||||
cp "${UNTAR_PAT_PATH}/GRUB_VER" "${DESTINATION}"
|
||||
cp "${UNTAR_PAT_PATH}/grub_cksum.syno" "${DESTINATION}"
|
||||
cp "${UNTAR_PAT_PATH}/GRUB_VER" "${DESTINATION}"
|
||||
cp "${UNTAR_PAT_PATH}/zImage" "${DESTINATION}"
|
||||
cp "${UNTAR_PAT_PATH}/rd.gz" "${DESTINATION}"
|
||||
cd "${DESTINATION}"
|
||||
tar -cf "${DESTINATIONFILES}/dsm.tar" .
|
||||
cd
|
||||
rm -rf "${UNTAR_PAT_PATH}"
|
||||
echo "DSM extract complete: ${MODEL}_${BUILD}"
|
||||
else
|
||||
echo "DSM extract Error: ${MODEL}_${BUILD}"
|
||||
echo -n "Checking hash of zImage: "
|
||||
HASH="`sha256sum ${UNTAR_PAT_PATH}/zImage | awk '{print$1}'`"
|
||||
echo "OK"
|
||||
echo "${HASH}" > "${DESTINATION}/zImage_hash"
|
||||
|
||||
echo -n "Checking hash of ramdisk: "
|
||||
HASH="`sha256sum ${UNTAR_PAT_PATH}/rd.gz | awk '{print$1}'`"
|
||||
echo "OK"
|
||||
echo "${HASH}" > "${DESTINATION}/ramdisk_hash"
|
||||
|
||||
echo -n "Copying files: "
|
||||
cp "${UNTAR_PAT_PATH}/grub_cksum.syno" "${DESTINATION}"
|
||||
cp "${UNTAR_PAT_PATH}/GRUB_VER" "${DESTINATION}"
|
||||
cp "${UNTAR_PAT_PATH}/grub_cksum.syno" "${DESTINATION}"
|
||||
cp "${UNTAR_PAT_PATH}/GRUB_VER" "${DESTINATION}"
|
||||
cp "${UNTAR_PAT_PATH}/zImage" "${DESTINATION}"
|
||||
cp "${UNTAR_PAT_PATH}/rd.gz" "${DESTINATION}"
|
||||
cd "${DESTINATION}"
|
||||
tar -cf "${DESTINATIONFILES}/dsm.tar" .
|
||||
rm -f "${PAT_PATH}"
|
||||
rm -rf "${UNTAR_PAT_PATH}"
|
||||
echo "DSM extract complete: ${MODEL}_${BUILD}"
|
||||
else
|
||||
echo "DSM extract Error: ${MODEL}_${BUILD}"
|
||||
fi
|
||||
fi
|
||||
cd ${HOME}
|
||||
done < ${MODELSFILE}
|
||||
done < ${MODELSFILE}
|
||||
|
||||
rm -rf "${CACHE_PATH}/dl"
|
Loading…
Reference in New Issue
Block a user