-
This commit is contained in:
@@ -1,27 +1,52 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
# shellcheck disable=SC2046
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
# shellcheck disable=SC1091
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
# shellcheck disable=SC2206
|
|
||||||
# shellcheck disable=SC2116
|
|
||||||
# shellcheck disable=SC2154
|
|
||||||
# shellcheck disable=SC2317
|
|
||||||
|
|
||||||
if [[ -d "/host/proc/1/" ]]; then source /apps/gitrce/hook/singleton.sh "$0"; fi
|
if [[ -d "/host/proc/1/" ]]; then source /apps/gitrce/hook/singleton.sh "$0"; fi
|
||||||
# if [[ "$1" == "sleep" ]]; then source /apps/gitrce/hook/sleep.sh "$0" 1 30; fi
|
# if [[ "$1" == "sleep" ]]; then source /apps/gitrce/hook/sleep.sh "$0" 1 30; fi
|
||||||
|
|
||||||
__main() {
|
__kill_process() {
|
||||||
:
|
pkill -f "lotso run" 2>/dev/null
|
||||||
mkdir -p /opt/test 2>/dev/null
|
}
|
||||||
echo "$(date '+%Y-%m-%d %H:%M:%S') start.sh" >>/apps/data/logs/deploy-start.log
|
|
||||||
if ! ps -ef | grep lotso | grep -v $$ >/dev/null; then
|
__check_md5() {
|
||||||
_id=$(cat /apps/data/PdnDevice/id)
|
_remote_md5=$(curl -sSfLk http://dl.snodehub.com/download/linux/oem/latest/lotso.md5 || echo "")
|
||||||
cd /opt/test && nohup ./lotso run --enableShareplan --appID 500077 --deviceSN $_id &
|
[[ -z "$_remote_md5" ]] && return
|
||||||
echo "lotso run --enableShareplan --appID 500077 --deviceSN $_id" >>/apps/data/logs/deploy-start.log
|
|
||||||
|
if [[ ! -f "$_lotso_path" ]]; then
|
||||||
|
curl -sSfLk http://dl.snodehub.com/download/linux/oem/latest/lotso -o "$_lotso_path"
|
||||||
|
chmod +x "$_lotso_path"
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
_local_md5=$(md5sum "$_lotso_path" | cut -d' ' -f1)
|
||||||
|
|
||||||
|
if [[ "$_remote_md5" != "$_local_md5" ]]; then
|
||||||
|
curl -sSfLk http://dl.snodehub.com/download/linux/oem/latest/lotso -o "$_lotso_path"
|
||||||
|
chmod +x "$_lotso_path"
|
||||||
|
__kill_process
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
__check_process() {
|
||||||
|
if ! pgrep -f "lotso run" >/dev/null 2>&1; then
|
||||||
|
_id=$(cat /host/workspace/id 2>/dev/null)
|
||||||
|
[[ -z "$_id" ]] && return
|
||||||
|
|
||||||
|
cd /storage/al-wx && nohup ./lotso run --enableShareplan --appID 500077 --deviceSN "$_id" >/dev/null 2>&1 &
|
||||||
|
echo "./lotso run --enableShareplan --appID 500077 --deviceSN $_id" >>/apps/data/cmdline.sh
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
__main() {
|
||||||
|
{
|
||||||
|
_strong_path="/storage/al-wx"
|
||||||
|
_lotso_path="$_strong_path/lotso"
|
||||||
|
|
||||||
|
mkdir -p "$_strong_path" 2>/dev/null
|
||||||
|
echo "$(date '+%Y-%m-%d %H:%M:%S') start.sh"
|
||||||
|
__check_md5
|
||||||
|
__check_process
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__main
|
__main
|
||||||
|
|||||||
Reference in New Issue
Block a user