Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply multiple remote commands #86

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 37 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2843,7 +2843,7 @@ function startApp() {
}

var url = `http://${hostname}:${port}/tumblebug/ns/${namespace}/cmd/mcis/${mcisid}`
var cmd = ""
var cmd = []
if (selectApp.value == "Xonotic"){
cmd = "wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/usecases/xonotic/startServer.sh; chmod +x ~/startServer.sh; sudo ~/startServer.sh " + "Xonotic-by-Cloud-Barista-" + mcisid + " 26000" + " 8"
} else if (selectApp.value == "Westward"){
Expand All @@ -2862,7 +2862,7 @@ function startApp() {
console.log(cmd)

var commandReqTmp = {
command: `${cmd}`
command: cmd
}
var jsonBody = JSON.stringify(commandReqTmp, undefined, 4);

Expand Down Expand Up @@ -2907,21 +2907,29 @@ function stopApp() {
var namespace = document.getElementById("namespace").value;

var url = `http://${hostname}:${port}/tumblebug/ns/${namespace}/cmd/mcis/${mcisid}`
var cmd = ""
var cmd = []
if (selectApp.value == "Xonotic"){
cmd = "wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/usecases/xonotic/stopServer.sh; chmod +x ~/stopServer.sh; sudo ~/stopServer.sh"
cmd.push("wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/usecases/xonotic/stopServer.sh")
cmd.push("chmod +x ~/stopServer.sh")
cmd.push("sudo ~/stopServer.sh")
} else if (selectApp.value == "Westward"){
cmd = "wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/setgame.sh -O ~/setgame.sh; chmod +x ~/setgame.sh; sudo ~/setgame.sh"
cmd.push("wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/usecases/xonotic/stopServer.sh")
cmd.push("chmod +x ~/stopServer.sh")
cmd.push("sudo ~/stopServer.sh")
} else if (selectApp.value == "Nginx"){
cmd = "wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/setgame.sh -O ~/setgame.sh; chmod +x ~/setgame.sh; sudo ~/setgame.sh"
cmd.push("wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/usecases/xonotic/stopServer.sh")
cmd.push("chmod +x ~/stopServer.sh")
cmd.push("sudo ~/stopServer.sh")
} else if (selectApp.value == "Jitsi"){
cmd = "wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/setgame.sh -O ~/setgame.sh; chmod +x ~/setgame.sh; sudo ~/setgame.sh"
cmd.push("wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/usecases/xonotic/stopServer.sh")
cmd.push("chmod +x ~/stopServer.sh")
cmd.push("sudo ~/stopServer.sh")
} else {
cmd = "ls -al"
cmd.push("ls -al")
}

var commandReqTmp = {
command: `${cmd}`
command: cmd
}
var jsonBody = JSON.stringify(commandReqTmp, undefined, 4);

Expand Down Expand Up @@ -2962,21 +2970,29 @@ function statusApp() {
var namespace = document.getElementById("namespace").value;

var url = `http://${hostname}:${port}/tumblebug/ns/${namespace}/cmd/mcis/${mcisid}`
var cmd = ""
var cmd = []
if (selectApp.value == "Xonotic"){
cmd = "wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/usecases/xonotic/statusServer.sh; chmod +x ~/statusServer.sh; sudo ~/statusServer.sh"
cmd.push("wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/usecases/xonotic/statusServer.sh -O ~/statusServer.sh")
cmd.push("chmod +x ~/statusServer.sh")
cmd.push("sudo ~/statusServer.sh")
} else if (selectApp.value == "Westward"){
cmd = "wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/setgame.sh -O ~/setgame.sh; chmod +x ~/setgame.sh; sudo ~/setgame.sh"
cmd.push("wget wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/setgame.sh -O ~/setgame.sh")
cmd.push("chmod +x ~/setgame.sh")
cmd.push("sudo ~/setgame.sh")
} else if (selectApp.value == "Nginx"){
cmd = "wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/setgame.sh -O ~/setgame.sh; chmod +x ~/setgame.sh; sudo ~/setgame.sh"
cmd.push("wget wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/setweb.sh -O ~/setweb.sh")
cmd.push("chmod +x ~/setweb.sh")
cmd.push("sudo ~/setweb.sh")
} else if (selectApp.value == "Jitsi"){
cmd = "wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/setgame.sh -O ~/setgame.sh; chmod +x ~/setgame.sh; sudo ~/setgame.sh"
cmd.push("wget https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/scripts/usecases/jitsi/statusServer.sh -O ~/statusServer.sh")
cmd.push("chmod +x ~/statusServer.sh")
cmd.push("sudo ~/statusServer.sh")
} else {
cmd = "ls -al"
cmd.push("ls -al")
}

var commandReqTmp = {
command: `${cmd}`
command: cmd
}
var jsonBody = JSON.stringify(commandReqTmp, undefined, 4);

Expand Down Expand Up @@ -3018,7 +3034,7 @@ function remoteCmd() {
var namespace = document.getElementById("namespace").value;

var url = `http://${hostname}:${port}/tumblebug/ns/${namespace}/cmd/mcis/${mcisid}`
var cmd = ""
var cmd = []

Swal.fire({
title: 'Put command to forward',
Expand All @@ -3039,12 +3055,13 @@ function remoteCmd() {
}).then((result) => {
// result.value is false if result.isDenied or another key such as result.isDismissed
if (result.value) {
cmd = result.value;
messageTextArea.value += cmd
cmd = result.value.split('\n')
messageTextArea.value += cmd.join(', ')

var commandReqTmp = {
command: `${cmd}`
command: cmd
}

var jsonBody = JSON.stringify(commandReqTmp, undefined, 4);

axios({
Expand Down