Skip to content

Commit 17ff779

Browse files
committed
Exposing params in run scripts
Before the run script had defaults for most values. This starting causing problems when hosting the server as it would require the run scripts to change. Now all the paramters are passed in when calling the run script. If any value is missing, the script exits and a usage message is printed.
1 parent f058608 commit 17ff779

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

run_client.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
LOCAL_MACHINE="localhost@2007"
17+
HOST="$1"
18+
PORT="$2"
1819

19-
cd './bin'
20+
if [[ "$HOST" == "" || "$PORT" == "" ]] ; then
21+
echo 'usage: <HOST> <PORT>'
22+
exit 1
23+
fi
2024

21-
java codeu.chat.ClientMain "$LOCAL_MACHINE"
25+
cd './bin'
26+
java codeu.chat.ClientMain "$HOST@$PORT"

run_relay.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,18 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
TEAMS_FILE="$(pwd)/teams"
17+
PORT="$1"
18+
TEAM_FILE="$2"
19+
20+
if [[ "$PORT" == "" || "$TEAM_FILE" == "" ]] ; then
21+
echo 'usage: <PORT> <TEAM FILE>'
22+
exit 1
23+
fi
24+
25+
if [ ! -f "$TEAM_FILE" ] ; then
26+
echo "No file at $TEAM_FILE"
27+
exit 1
28+
fi
1829

1930
cd './bin'
20-
java codeu.chat.RelayMain '2008' "$TEAMS_FILE"
31+
java codeu.chat.RelayMain "$PORT" "$TEAM_FILE"

run_server.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,14 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
TEAM_ID="$1"
18+
TEAM_SECRET="$2"
19+
PORT="$3"
20+
21+
if [[ "TEAM_ID" == "" || "$TEAM_SECRET" == "" || "$PORT" == "" ]] ; then
22+
echo 'usage: <TEAM ID> <TEAM SECRET> <PORT>'
23+
exit 1
24+
fi
25+
1726
cd './bin'
18-
java codeu.chat.ServerMain "100.101" "ABABAB" "2007"
27+
java codeu.chat.ServerMain "$TEAM_ID" "$TEAM_SECRET" "$PORT"

0 commit comments

Comments
 (0)