3
3
4
4
# Function to display help message
5
5
show_help () {
6
- echo " Usage: $0 [options] -h <host_ip> - r <remote_ip>"
6
+ echo " Usage: $0 [options] -r <remote_ip>"
7
7
echo
8
8
echo " Required:"
9
- echo " -h, --host <host_ip> Local host IP address"
10
9
echo " -r, --remote <remote_ip> Remote host IP address"
11
10
echo
12
11
echo " Optional:"
13
12
echo " -u, --user <remote_user> Remote username (default: root)"
14
- echo " -p, --port <port> Python server port (default: 8000)"
15
13
echo " --help Display this help message"
16
14
echo
17
15
echo " Example:"
18
- echo " $0 -h 192.168.0.13 - r 192.168.0.17"
19
- echo " $0 -h 192.168.0.13 - r 192.168.0.17 -u admin -p 8080 "
16
+ echo " $0 -r 192.168.0.17"
17
+ echo " $0 -r 192.168.0.17 -u admin"
20
18
exit 0
21
19
}
22
20
23
21
# Default values
24
- PYTHON_PORT=8000
25
22
REMOTE_USER=" root"
26
23
REMOTE_PATH=" /userdata/jetkvm/bin"
27
24
28
25
# Parse command line arguments
29
26
while [[ $# -gt 0 ]]; do
30
27
case $1 in
31
- -h|--host)
32
- HOST_IP=" $2 "
33
- shift 2
34
- ;;
35
28
-r|--remote)
36
29
REMOTE_HOST=" $2 "
37
30
shift 2
@@ -40,10 +33,6 @@ while [[ $# -gt 0 ]]; do
40
33
REMOTE_USER=" $2 "
41
34
shift 2
42
35
;;
43
- -p|--port)
44
- PYTHON_PORT=" $2 "
45
- shift 2
46
- ;;
47
36
--help)
48
37
show_help
49
38
exit 0
@@ -57,8 +46,8 @@ while [[ $# -gt 0 ]]; do
57
46
done
58
47
59
48
# Verify required parameters
60
- if [ -z " $HOST_IP " ] || [ -z " $ REMOTE_HOST" ]; then
61
- echo " Error: Host IP and Remote IP are required parameters "
49
+ if [ -z " $REMOTE_HOST " ]; then
50
+ echo " Error: Remote IP is a required parameter "
62
51
show_help
63
52
fi
64
53
@@ -69,12 +58,8 @@ make build_dev
69
58
# Change directory to the binary output directory
70
59
cd bin
71
60
72
- # Start a Python HTTP server in the background to serve files
73
- python3 -m http.server " $PYTHON_PORT " &
74
- PYTHON_SERVER_PID=$!
75
-
76
- # Ensure that the Python server is terminated if the script exits unexpectedly
77
- trap " echo 'Terminating Python server...'; kill $PYTHON_SERVER_PID " EXIT
61
+ # Copy the binary to the remote host
62
+ cat jetkvm_app | ssh " ${REMOTE_USER} @${REMOTE_HOST} " " cat > $REMOTE_PATH /jetkvm_app_debug"
78
63
79
64
# Deploy and run the application on the remote host
80
65
ssh " ${REMOTE_USER} @${REMOTE_HOST} " ash << EOF
@@ -90,23 +75,12 @@ killall jetkvm_app_debug || true
90
75
# Navigate to the directory where the binary will be stored
91
76
cd "$REMOTE_PATH "
92
77
93
- # Remove any old binary
94
- rm -f jetkvm_app
95
-
96
- # Download the new binary from the host
97
- wget ${HOST_IP} :${PYTHON_PORT} /jetkvm_app
98
-
99
78
# Make the new binary executable
100
- chmod +x jetkvm_app
101
-
102
- # Rename the binary to jetkvm_app_debug
103
- mv jetkvm_app jetkvm_app_debug
79
+ chmod +x jetkvm_app_debug
104
80
105
81
# Run the application in the background
106
82
./jetkvm_app_debug
107
83
108
84
EOF
109
85
110
- # Once the SSH session finishes, shut down the Python server
111
- kill " $PYTHON_SERVER_PID "
112
86
echo " Deployment complete."
0 commit comments