#!/system/bin/sh export PATH="$PATH:/sbin:/system/sbin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin" CACHE_DIR="$1" [ -z "$CACHE_DIR" ] && CACHE_DIR="/data/" SMALLP_PATH="$CACHE_DIR/smallp/" mkdir -p "$CACHE_DIR/local/tmp/bin" export PATH="$PATH:$CACHE_DIR/local/tmp/bin" init() { BUSYBOXY="/system/bin/busybox-arm" if [ ! -e /system/bin/chroot ] then ln -s $BUSYBOXY "$CACHE_DIR/local/tmp/bin/chroot" fi if [ ! -e /system/bin/pgrep ] then ln -s $BUSYBOXY "$CACHE_DIR/local/tmp/bin/pgrep" fi if [ ! -e /system/bin/dirname ] then ln -s $BUSYBOXY "$CACHE_DIR/local/tmp/bin/dirname" fi } is_running() { for pid in $(pgrep "starthugep.sh") do if [ "$pid" != "$$" ] then exit 0 fi done } install() { if [ -f /system/bin/hugep-all.zip ] then rm -rf "$SMALLP_PATH" mkdir "$SMALLP_PATH" if [ -f /system/bin/unzip ] then unzip /system/bin/hugep-all.zip -d "$SMALLP_PATH" else unzip_go -file /system/bin/hugep-all.zip -dst "$SMALLP_PATH" fi else return 1 fi } need_intall() { if [ -e /system/.androidrom ] then if [ ! -d "$SMALLP_PATH" ] then return 0 fi version=$(/system/bin/jqgo 'dianxinfs' < "$SMALLP_PATH"/config.json) if [ -z "$version" ] then return 0 fi if [ ! -f "${SMALLP_PATH}/dianxinfs_arm32_${version}/writable/.deviceID" ] then return 0 fi if ! grep -q "^32_" "${SMALLP_PATH}/dianxinfs_arm32_${version}/writable/.deviceID" 2>/dev/null then return 0 fi fi return 3 } forever() { chmod 777 "${SMALLP_PATH}/hugep-start.sh" while true do pid=$(pgrep "hugep-start.sh") if [ -z "$pid" ]; then "${SMALLP_PATH}"/hugep-start.sh > /dev/null 2>&1 & fi sleep 30 done } init if need_intall then if ! install then exit 3 fi fi is_running forever