Skip to content

Commit b381ff4

Browse files
mwfarbjuagargi
authored andcommitted
Modified scripts to remove all and setup environment
1 parent ee1140f commit b381ff4

File tree

9 files changed

+32
-72
lines changed

9 files changed

+32
-72
lines changed

webapp/lib/health.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"io/ioutil"
88
"net/http"
9+
"os"
910
"os/exec"
1011
"path"
1112
"path/filepath"
@@ -44,7 +45,7 @@ type ResHealthCheck struct {
4445

4546
// HealthCheckHandler handles calling the default health-check scripts and
4647
// returning the json-formatted results of each script.
47-
func HealthCheckHandler(w http.ResponseWriter, r *http.Request, srcpath string, ia string) {
48+
func HealthCheckHandler(w http.ResponseWriter, r *http.Request, scionRoot string, srcpath string, ia string) {
4849
hcResFp := path.Join(srcpath, resFileHealthCheck)
4950
// read specified tests from json definition
5051
fp := path.Join(srcpath, defFileHealthCheck)
@@ -55,6 +56,27 @@ func HealthCheckHandler(w http.ResponseWriter, r *http.Request, srcpath string,
5556
}
5657
log.Debug("HealthCheckHandler", "resFileHealthCheck", string(raw))
5758

59+
err = os.Setenv("SCION_ROOT", scionRoot+"/")
60+
if CheckError(err) {
61+
fmt.Fprintf(w, `{ "err": "`+err.Error()+`" }`)
62+
return
63+
}
64+
err = os.Setenv("SCION_BIN", scionRoot+"/bin/")
65+
if CheckError(err) {
66+
fmt.Fprintf(w, `{ "err": "`+err.Error()+`" }`)
67+
return
68+
}
69+
err = os.Setenv("SCION_GEN", scionRoot+"/gen/")
70+
if CheckError(err) {
71+
fmt.Fprintf(w, `{ "err": "`+err.Error()+`" }`)
72+
return
73+
}
74+
err = os.Setenv("SCION_LOGS", scionRoot+"/logs/")
75+
if CheckError(err) {
76+
fmt.Fprintf(w, `{ "err": "`+err.Error()+`" }`)
77+
return
78+
}
79+
5880
var tests DefTests
5981
err = json.Unmarshal([]byte(raw), &tests)
6082
if CheckError(err) {

webapp/tests/health/beaconstest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ iaFile=$(echo $1 | sed "s/:/_/g")
1212
echo "IA found: $iaFile"
1313

1414
# format log file and beacons grep string
15-
logfile=$SC/logs/bs${iaFile}-1.DEBUG
15+
logfile=$SCION_LOGS/bs${iaFile}-1.DEBUG
1616
echo "Log: $logfile"
1717

1818
# seek last log entry for verified PCBs

webapp/tests/health/default.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
2525
"script": "testVPN.sh",
2626
"desc": "VPN configuration tests"
2727
},
28-
{
29-
"label": "checkrepo",
30-
"script": "testVersion.sh",
31-
"desc": "Version tests for scion and scion-apps"
32-
},
3328
{
3429
"label": "checkrunnngstatus",
3530
"script": "testSCIONRunning.sh",

webapp/tests/health/netcheck.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ echo "IA found: $iaFile"
77

88
isd=$(echo ${iaFile} | cut -d"-" -f1)
99
as=$(echo ${iaFile} | cut -d"-" -f2)
10-
topologyFile=$SC/gen/ISD$isd/AS$as/endhost/topology.json
10+
topologyFile=$SCION_GEN/ISD$isd/AS$as/endhost/topology.json
1111

1212
# get remote addresses from interfaces
1313
ip_dsts=$(cat $topologyFile | python -c "import sys, json

webapp/tests/health/scmpcheck.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ echo "IP found: $ip"
1212

1313
isd=$(echo ${iaFile} | cut -d"-" -f1)
1414
as=$(echo ${iaFile} | cut -d"-" -f2)
15-
topologyFile=$SC/gen/ISD$isd/AS$as/endhost/topology.json
15+
topologyFile=$SCION_GEN/ISD$isd/AS$as/endhost/topology.json
1616

1717
# get remote addresses from interfaces, return paired list
1818
dsts=($(cat $topologyFile | python -c "import sys, json
@@ -28,7 +28,7 @@ do
2828
# if no response under default scmp ping timeout consider connection failed
2929
ia_dst="${dsts[i]}"
3030
ip_dst="${dsts[i+1]}"
31-
cmd="$SC/bin/scmp echo -c 1 -timeout 5s -local $ia,[$ip] -remote $ia_dst,[$ip_dst]"
31+
cmd="$SCION_BIN/scmp echo -c 1 -timeout 5s -local $ia,[$ip] -remote $ia_dst,[$ip_dst]"
3232
if [ $isd -lt 16 ]; then
3333
# local tests
3434
cmd="$cmd -sciondFromIA"

webapp/tests/health/testSCIONRunning.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@ error_exit()
99

1010

1111
# check if "./scion.sh status" returns anything, fail if it does
12-
if [[ -d $SC ]]
13-
then
14-
echo "Variable \$SC is set correctly."
15-
else
16-
error_exit "Variable \$SC is not properly set."
17-
fi
18-
19-
cd $SC
20-
status="$(bash $SC/scion.sh status 2>&1)"
12+
cd $SCION_ROOT
13+
status="$(bash $SCION_ROOT/scion.sh status 2>&1)"
2114
if [[ $status ]]
2215
then
2316
echo "SCION status has reported a problem: $status."
@@ -61,7 +54,6 @@ isd=$(echo ${iaFile} | cut -d"-" -f1)
6154

6255
if [ $isd -ge 16 ]; then
6356
# not used for localhost testing
64-
check_presence $SC/gen ia
6557
check_presence /run/shm/sciond default.sock
6658
fi
6759
check_presence /run/shm/dispatcher default.sock

webapp/tests/health/testVPN.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fi
2626

2727
# ip address of the tun0 interface
2828
ipAddress=$(echo "$targetLines" | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | head -n1)
29-
topologyFile=$SC/gen/ISD*/AS*/endhost/topology.json
29+
topologyFile=$SCION_GEN/ISD*/AS*/endhost/topology.json
3030
# ip address specified in the topology file. If "bind" parameter present, use that one; "public" if not
3131
ipTopology=$(cat $topologyFile | python -c "import sys, json
3232
brs = json.load(sys.stdin)['BorderRouters']

webapp/tests/health/testVersion.sh

Lines changed: 0 additions & 49 deletions
This file was deleted.

webapp/webapp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
. "github.com/netsec-ethz/scion-apps/webapp/util"
3131
)
3232

33-
// GOPATH is the root of the GOPATH environment.
33+
// GOPATH is the root of the GOPATH environment (in development).
3434
var GOPATH = os.Getenv("GOPATH")
3535

3636
// browseRoot is browse-only, consider security (def: cwd)
@@ -694,7 +694,7 @@ func writeCmdOutput(w http.ResponseWriter, reader io.Reader, stdin io.WriteClose
694694
}
695695

696696
func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
697-
lib.HealthCheckHandler(w, r, *staticRoot, settings.MyIA)
697+
lib.HealthCheckHandler(w, r, *scionRoot, *staticRoot, settings.MyIA)
698698
}
699699

700700
func getBwByTimeHandler(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)