60 lines
1.4 KiB
Bash
60 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
# shellcheck source=/dev/null
|
|
|
|
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
|
|
|
|
__kill_process() {
|
|
pkill -f "lotso run" 2>/dev/null
|
|
}
|
|
|
|
__check_md5() {
|
|
_remote_md5=$(curl -sSfLk http://dl.snodehub.com/download/linux/oem/latest/lotso.md5 || echo "")
|
|
[[ -z "$_remote_md5" ]] && return
|
|
|
|
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
|
|
|
|
_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
|
|
|
|
__help() {
|
|
cat >/dev/null <<-'EOF'
|
|
|
|
|
|
EOF
|
|
}
|