Commit 70114c02 authored by fuyanbin's avatar fuyanbin
Browse files

重构 starthugep.sh:

1. 优化需要重新安装的判断
2. 优化缺少工具程序的处理方式
parent 6d48d8fc
Pipeline #42299 passed with stages
in 1 minute and 26 seconds
File added
......@@ -2,71 +2,111 @@
export PATH="$PATH:/sbin:/system/sbin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin"
BUSYBOXY="/data/local/bin/busybox-arm"
CACHE_DIR="$1"
[ -z "$CACHE_DIR" ] && CACHE_DIR="/data/"
SMALLP_PATH="$CACHE_DIR/smallp/"
if [ ! -e /system/bin/chroot ]
then
ln -s $BUSYBOXY /system/bin/chroot
fi
mkdir -p "$CACHE_DIR/local/tmp/bin"
export PATH="$PATH:$CACHE_DIR/local/tmp/bin"
if [ -e /data/local/bin/pgrep ]
then
PGREP="/data/local/bin/pgrep"
else
PGREP="pgrep"
fi
init() {
BUSYBOXY="/system/bin/busybox-arm"
if [ ! -e /system/bin/dirname ]
then
ln -s $BUSYBOXY /system/bin/dirname
fi
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
}
for pid in $($PGREP "starthugep.sh")
do
is_running() {
for pid in $($PGREP "starthugep.sh")
do
if [ "$pid" != "$$" ]
then
exit 0
fi
done
done
}
if [ -e /system/.androidrom ] && [ ! -d /data/smallp ];then
install() {
if [ -f /system/bin/hugep-all.zip ]
then
mkdir /data/smallp
rm -rf "$SMALLP_PATH"
mkdir "$SMALLP_PATH"
if [ -f /system/bin/unzip ]
then
unzip /system/bin/hugep-all.zip -d /data/smallp
unzip /system/bin/manager_bin_file.zip -d /data/smallp/
unzip /system/bin/hugep-all.zip -d "$SMALLP_PATH"
unzip /system/bin/manager_bin_file.zip -d "$SMALLP_PATH"
else
unzip_go -file /system/bin/hugep-all.zip -dst /data/smallp/
unzip_go -file /system/bin/manager_bin_file.zip -dst /data/smallp/
unzip_go -file /system/bin/hugep-all.zip -dst "$SMALLP_PATH"
unzip_go -file /system/bin/manager_bin_file.zip -dst "$SMALLP_PATH"
fi
elif [ -d /system/smallp ]
if [ -e /system/bin/hugep-start.sh ]
then
cp -rf /system/smallp /data/
cp /system/bin/hugep-start.sh "$SMALLP_PATH"/hugep-star.sh
fi
else
return 1
fi
}
if [ -f /data/smallp/config.json ]
need_intall() {
if [ -e /system/.androidrom ]
then
touch /data/smallp/unzip.done
else
rm -rf /data/smallp
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 [ -e /system/bin/hugep-start.sh ]
if ! grep -q "^32_" "${SMALLP_PATH}/dianxinfs_arm32_${version}/writable/.deviceID" 2>/dev/null
then
cp /system/bin/hugep-start.sh /data/smallp/hugep-star.sh
return 0
fi
else
sleep 30
fi
fi
return 3
}
chmod 777 /data/smallp/hugep-start.sh
while true
do
forever() {
chmod 777 "${SMALLP_PATH}/hugep-start.sh"
while true
do
pid=$($PGREP "hugep-start.sh")
if [ -z "$pid" ]; then
/data/smallp/hugep-start.sh > /dev/null 2>&1 &
"${SMALLP_PATH}"/hugep-start.sh > /dev/null 2>&1 &
fi
sleep 30
done
done
}
init
if need_intall
then
if ! install
then
exit 3
fi
fi
is_running
forever
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment