Advertisement
zefie

Script to add ROM to cm-update-server

Mar 25th, 2017
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.61 KB | None | 0 0
  1. #!/bin/bash
  2. export NODE_ENV=production
  3. Z_ROOTDIR=data/files
  4.  
  5. if [ -z "$1" ]; then
  6.         echo "Usage: $0 filename"
  7.         echo "Example: $0 test.zip"
  8.         exit 1;
  9. fi
  10.  
  11. if [ "$(echo ${1} | grep '/' | wc -l)" -gt 0 ]; then
  12.         Z_REALFILE="${1}"
  13. else
  14.         # If the full path wasn't specified, try to guess the file location.
  15.         Z_REALFILE=$(ls -1 "${Z_ROOTDIR}/"*/*.zip | grep "${1}")
  16. fi
  17.  
  18. # If we couldn't find the file, stop here
  19. if [ ! -f "${Z_REALFILE}" ]; then
  20.         echo "Could not find ${Z_REALFILE}"
  21.         exit 1;
  22. fi
  23.  
  24. Z_FILENAME="$(echo "${Z_REALFILE}" | rev | cut -d'/' -f1 | rev)"
  25. Z_SUBDIR="$(echo "${Z_REALFILE}" | rev | cut -d'/' -f2 | rev)"
  26. Z_SYSPROP=$(unzip -p "${Z_REALFILE}" system/build.prop)
  27. Z_DEVICE=$(echo "${Z_SYSPROP}" | grep "ro.product.device=" | head -n1 | cut -d'=' -f2)
  28. Z_INCID=$(echo "${Z_SYSPROP}" | grep "ro.build.version.incremental=" | cut -d'=' -f2)
  29. Z_APILVL=$(echo "${Z_SYSPROP}" | grep "ro.build.version.sdk=" | cut -d'=' -f2)
  30. Z_UPDCH=$(echo "${Z_SYSPROP}" | grep "ro.cm.releasetype=" | cut -d'=' -f2)
  31. Z_TS=$(echo "${Z_SYSPROP}" | grep "ro.build.date.utc=" | cut -d'=' -f2)
  32. Z_MD5SUM=$(md5sum -b "${Z_REALFILE}" | cut -d' ' -f1)
  33. Z_FILESIZE=$(stat -c %s "${Z_REALFILE}")
  34.  
  35.  
  36. node add-build.js \
  37. --filename "${Z_FILENAME}" \
  38. --device "${Z_DEVICE}" \
  39. --incrementalid "${Z_INCID}" \
  40. --api_level "${Z_APILVL}" \
  41. --channel "${Z_UPDCH}" \
  42. --md5sum "${Z_MD5SUM}" \
  43. --filesize "${Z_FILESIZE}" \
  44. --subdirectory "${Z_SUBDIR}" \
  45. --timestamp "${Z_TS}" \
  46. --active
  47.  
  48. echo "${Z_MD5SUM}  ${Z_FILENAME}" > "${Z_ROOTDIR}/${Z_SUBDIR}/${Z_FILENAME}.md5sum"
  49.  
  50. ./gensite.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement