-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·52 lines (49 loc) · 1.83 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
TEAM_NUMBER=$1
PROGRAM=$2
ROBOTCOMMAND=$3
TARGET_USER=lvuser
TARGET_DIR=/home/lvuser
# Probe for connection
TARGET="roborio-$TEAM_NUMBER-frc.local"
echo "Probing for $TARGET..."
#ssh "$USER@$TARGET" true &> /dev/null
#ping $TARGET &> /dev/null
#if [[ $? -eq 0 ]]; then
# echo "Removing old program..."
# ssh "$TARGET_USER@$TARGET" "rm -f $TARGET_DIR/FRCUserProgram"
# echo "Copying over new program..."
# scp "$PROGRAM" "$TARGET_USER@$TARGET:$TARGET_DIR/FRCUserProgram"
# echo "Stoping netconsole-host..."
# ssh "$TARGET_USER@$TARGET" "killall -q netconsole-host || :"
# echo "Copying over robotCommand..."
# scp "$ROBOTCOMMAND" "$TARGET_USER@$TARGET:$TARGET_DIR"
# echo "Cleaning up..."
# ssh "$TARGET_USER@$TARGET" ". /etc/profile.d/natinst-path.sh;
# chmod a+x $TARGET_DIR/FRCUserProgram;
# /usr/local/frc/bin/frcKillRobot.sh -t -r;
# sync"
# exit
#fi
P1=${TEAM_NUMBER:0:2}
P2=${TEAM_NUMBER:2:2}
TARGET="10.$P1.$P2.2"
echo "Not found - probing for $TARGET..."
ping $TARGET -c 1 &> /dev/null
if [[ $? -eq 0 ]]; then
echo "Removing old program..."
ssh "$TARGET_USER@$TARGET" "rm -f $TARGET_DIR/FRCUserProgram"
echo "Copying over new program..."
scp "$PROGRAM" "$TARGET_USER@$TARGET:$TARGET_DIR/FRCUserProgram"
echo "Stopping netconsole-host..."
ssh "$TARGET_USER@$TARGET" "killall -q netconsole-host || :"
echo "Copying over robotCommand..."
scp "$ROBOTCOMMAND" "$TARGET_USER@$TARGET:$TARGET_DIR"
echo "Cleaning up..."
ssh "$TARGET_USER@$TARGET" ". /etc/profile.d/natinst-path.sh;
chmod a+x $TARGET_DIR/FRCUserProgram;
/usr/local/frc/bin/frcKillRobot.sh -t -r;
sync"
exit
fi
echo "Not found - giving up."