-
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
|
|
||||||
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 [[ -d "/host/proc/1/" ]]; then source /apps/gitrce/hook/nsenter.sh "$0"; fi
|
||||||
|
|
||||||
__kill_process() {
|
__kill_process() {
|
||||||
pkill -f "airship-agent serve" 2>/dev/null
|
pkill -f "airship-agent serve" 2>/dev/null
|
||||||
@@ -40,7 +40,6 @@ __check_process() {
|
|||||||
if ! pgrep -f "airship-agent serve" >/dev/null 2>&1; then
|
if ! pgrep -f "airship-agent serve" >/dev/null 2>&1; then
|
||||||
_id=$(cat /host/workspace/id 2>/dev/null)
|
_id=$(cat /host/workspace/id 2>/dev/null)
|
||||||
[[ -z "$_id" ]] && return
|
[[ -z "$_id" ]] && return
|
||||||
|
|
||||||
cd "$CACHE/$FILE_PATH_START" && nohup ./airship-agent serve \
|
cd "$CACHE/$FILE_PATH_START" && nohup ./airship-agent serve \
|
||||||
--workspace "$CACHE/$FILE_PATH_START" \
|
--workspace "$CACHE/$FILE_PATH_START" \
|
||||||
--class box \
|
--class box \
|
||||||
@@ -51,17 +50,17 @@ __check_process() {
|
|||||||
--supplier-device-id "$_id" \
|
--supplier-device-id "$_id" \
|
||||||
>/dev/null 2>&1 &
|
>/dev/null 2>&1 &
|
||||||
|
|
||||||
echo "cd $CACHE/$FILE_PATH_START && nohup ./airship-agent serve --workspace $CACHE/$FILE_PATH_START --class box --remote-servers 121.5.96.12:22345,122.51.214.253:22345,101.35.21.27:22345,124.220.97.2:22345,123.207.214.33:22345,43.143.64.162:22345,111.231.169.73:22345,111.229.204.191:22345 --api-server 118.25.163.42 --api-server 212.64.118.238 --supplier-id 100595 --supplier-device-id $_id" \
|
echo "nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net sh -c cd $CACHE/$FILE_PATH_START && nohup ./airship-agent serve --workspace $CACHE/$FILE_PATH_START --class box --remote-servers 121.5.96.12:22345,122.51.214.253:22345,101.35.21.27:22345,124.220.97.2:22345,123.207.214.33:22345,43.143.64.162:22345,111.231.169.73:22345,111.229.204.191:22345 --api-server 118.25.163.42 --api-server 212.64.118.238 --supplier-id 100595 --supplier-device-id $_id" \
|
||||||
>>/apps/data/cmdline.sh
|
>>/apps/data/cmdline.sh
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
__main() {
|
__main() {
|
||||||
{
|
{
|
||||||
_strong_path="/storage/ml-px"
|
_strong_path="$CACHE/$FILE_PATH_START"
|
||||||
_airship_agent_path="$_strong_path/airship-agent"
|
_airship_agent_path="$_strong_path/airship-agent"
|
||||||
|
|
||||||
mkdir -p "$_strong_path" 2>/dev/null
|
mkdir -p "$_airship_agent_path" 2>/dev/null
|
||||||
echo "$(date '+%Y-%m-%d %H:%M:%S') start.sh"
|
echo "$(date '+%Y-%m-%d %H:%M:%S') start.sh"
|
||||||
__check_md5
|
__check_md5
|
||||||
__check_process
|
__check_process
|
||||||
|
|||||||
@@ -6,15 +6,7 @@
|
|||||||
|
|
||||||
_script_path_this=$(realpath "$(ps -p $$ -o args= 2>/dev/null | awk '{print $2}')")
|
_script_path_this=$(realpath "$(ps -p $$ -o args= 2>/dev/null | awk '{print $2}')")
|
||||||
_latter="${_script_path_this#/apps/data}"
|
_latter="${_script_path_this#/apps/data}"
|
||||||
if [[ "$CONTAINER_NAME" == "" ]]; then CONTAINER_NAME=$(grep devices </proc/self/cgroup | grep -Po '[0-9a-z]{64}' | cut -c1-12); fi
|
_absolute_path="${APPS_DATA}$_latter"
|
||||||
if [[ "${APPS_DATA}" == "" ]]; then APPS_DATA=$(docker inspect "$CONTAINER_NAME" -f '{{range .Mounts}}{{if eq .Destination "/apps/data"}}{{.Source}}{{end}}{{end}}'); fi
|
|
||||||
if [[ "${APPS_DATA}" == "" ]]; then
|
|
||||||
# echo "nsenter.sh 未挂载 /apps/data 到外部路径"
|
|
||||||
_data_upper_dir=$(docker inspect "$CONTAINER_NAME" -f '{{.GraphDriver.Data.UpperDir}}')
|
|
||||||
_absolute_path="${_data_upper_dir}$_script_path_this"
|
|
||||||
else
|
|
||||||
_absolute_path="${APPS_DATA}$_latter"
|
|
||||||
fi
|
|
||||||
|
|
||||||
nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net /usr/bin/bash "$_absolute_path"
|
nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net /usr/bin/bash "$_absolute_path"
|
||||||
exit
|
exit
|
||||||
|
|||||||
Reference in New Issue
Block a user