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