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
for pid in $($PGREP "starthugep.sh") if [ ! -e /system/bin/dirname ]
do
if [ "$pid" != "$$" ]
then then
exit 0 ln -s $BUSYBOXY "$CACHE_DIR/local/tmp/bin/dirname"
fi fi
done }
is_running() {
for pid in $($PGREP "starthugep.sh")
do
if [ "$pid" != "$$" ]
then
exit 0
fi
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 ]
then
cp -rf /system/smallp /data/
fi
if [ -f /data/smallp/config.json ] if [ -e /system/bin/hugep-start.sh ]
then then
touch /data/smallp/unzip.done cp /system/bin/hugep-start.sh "$SMALLP_PATH"/hugep-star.sh
fi
else else
rm -rf /data/smallp return 1
fi fi
}
if [ -e /system/bin/hugep-start.sh ] need_intall() {
if [ -e /system/.androidrom ]
then then
cp /system/bin/hugep-start.sh /data/smallp/hugep-star.sh 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 fi
else return 3
sleep 30 }
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