-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: api: srest: Agent Install API updated
Automatically install the agent on a remote server
- Loading branch information
Showing
4 changed files
with
171 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
|
||
AGENT_REPO="https://raw.githubusercontent.com/cloud-barista/cm-honeybee/main/agent" | ||
|
||
get_latest_release() { | ||
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api | ||
grep '"tag_name":' | # Get tag line | ||
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value | ||
} | ||
|
||
Initializer() { | ||
if [ -f /tmp/agentFirst ]; then | ||
# 첫 실행이 아닐 경우 | ||
# echo "[Install] --PASS" | ||
echo "" | ||
|
||
sleep 1 | ||
else | ||
# 첫 실행인 경우 | ||
touch /tmp/agentFirst | ||
|
||
if [ -f /etc/debian_version ]; then | ||
apt-get install -y curl wget > /tmp/honeybee-agent-install.log 2>&1 | ||
elif [ -f /etc/redhat-release ]; then | ||
yum install -y curl wget > /tmp/honeybee-agent-install-install.log 2>&1 | ||
fi | ||
fi | ||
} | ||
|
||
Copy() { | ||
if [ -f /usr/bin/cm-honeybee-agent ]; then | ||
# echo "[Binary Copy] --PASS" | ||
echo "" | ||
|
||
sleep 1 | ||
else | ||
LATEST_RELEASE=$(get_latest_release "cloud-barista/cm-honeybee") | ||
DOWNLOAD_URL=https://github.com/cloud-barista/cm-honeybee/releases/download/${LATEST_RELEASE}/cm-honeybee-agent | ||
|
||
wget --no-check-certificate --continue --quiet $DOWNLOAD_URL -P /usr/bin | ||
chmod a+x /usr/bin/cm-honeybee-agent | ||
|
||
mkdir -p /etc/cloud-migrator/cm-honeybee-agent/conf | ||
wget --no-check-certificate --continue --quiet ${AGENT_REPO}/conf/cm-honeybee-agent.yaml -P /etc/cloud-migrator/cm-honeybee-agent/conf | ||
wget --no-check-certificate --continue --quiet ${AGENT_REPO}/scripts/systemd/cm-honeybee-agent.service -P /etc/systemd/system | ||
fi | ||
} | ||
|
||
Start() { | ||
status=$(service cm-honeybee-agent status | grep Active | awk '{print $3}') | ||
if [[ "$status" == "(running)" ]]; then | ||
# echo "[service start] --PASS" | ||
echo "" | ||
|
||
sleep 1 | ||
else | ||
systemctl daemon-reload | ||
systemctl enable --now cm-honeybee-agent | ||
fi | ||
|
||
sleep 1 | ||
} | ||
|
||
Initializer | ||
Copy | ||
Start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
package route | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/cloud-barista/cm-honeybee/server/common" | ||
"github.com/cloud-barista/cm-honeybee/server/pkg/api/rest/controller" | ||
"github.com/labstack/echo/v4" | ||
"strings" | ||
) | ||
|
||
func RegisterBenchmark(e *echo.Echo) { | ||
e.GET("/"+strings.ToLower(common.ShortModuleName)+"/bench/:connId", controller.GetBenchmarkInfo) | ||
e.GET("/"+strings.ToLower(common.ShortModuleName)+"/run/bench/:connId", controller.RunBenchmarkInfo) | ||
e.GET("/"+strings.ToLower(common.ShortModuleName)+"/init/agent/:connId", controller.AgentInitInfo) | ||
} |