Ajust the order of operations

Check parameters first.
rename library and then declare Env path
Check the path before calling /system/bin/<commands>.

Signed-off-by: Wei Jiangang <wei_jiangang@hoperun.com>
This commit is contained in:
Wei Jiangang 2024-03-25 18:24:26 +08:00
parent c1ba66a885
commit 6501cd5e86

View File

@ -92,17 +92,10 @@ start_process() {
fi
}
# 如果有进程还在,暂停服务防止双进程存在
if pgrep -x "samgr" > /dev/null; then
log info "service is running, stop it"
/system/bin/stop_services.sh all
sleep 2
fi
# 软链接动态库
if [ ! -e "/usr/lib64/libsec_shared.z.so" ]; then
log info "libsec_shared.z.so not exist, create it"
ln -s /usr/lib64/libboundscheck.so /usr/lib64/libsec_shared.z.so
# 判断参数是否为空
if [ -z "$1" ]; then
log error "Usage: $0 [all|samgr|huks|deviceauth|softbus|device_manager|dfs|datamgr]"
exit 1
fi
# 新建日志目录
@ -118,10 +111,10 @@ if [ ! -e "/etc/SN" ]; then
echo "$ipv4_address" | sudo tee /etc/SN > /dev/null
fi
# 判断参数是否为空
if [ -z "$1" ]; then
log error "Usage: $0 [all|samgr|huks|deviceauth|softbus|device_manager|dfs|datamgr]"
exit 1
# 软链接动态库
if [ ! -e "/usr/lib64/libsec_shared.z.so" ]; then
log info "libsec_shared.z.so not exist, create it"
ln -s /usr/lib64/libboundscheck.so /usr/lib64/libsec_shared.z.so
fi
# 检查 $LD_LIBRARY_PATH 是否包含 "/system/lib64",如果不包含则加入
@ -155,6 +148,13 @@ if [ ! -e "/dev/binder" ]; then
fi
cd ${BIN_PATH} || exit
# 如果有进程还在,暂停服务防止双进程存在
if pgrep -x "samgr" > /dev/null; then
log info "service is running, stop it"
/system/bin/stop_services.sh all
sleep 2
fi
# 验证参数并执行相应命令
if [ "$1" == "all" ]; then
log info "Starting all services..."