Skip to content

Commit 104a7e1

Browse files
committed
Script to update live Nakamochi with locally built nd and ngui
1 parent 5f684f8 commit 104a7e1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tools/update-nakamochi.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ -z $1 ]]; then
4+
echo "Update Nakamochi with locally built nd and ngui."
5+
echo "Usage: $(basename "$0") nakamochi-ip [binaries-path]"
6+
echo "Where:"
7+
echo " nakamochi-ip IP address of the Nakamochi device"
8+
echo " binaries-path (Optional) Path to the directory containing 'nd' and 'ngui' binaries. Defaults to ./zig-out/bin."
9+
exit 1
10+
fi
11+
12+
NAKAMOCHI_IP=$1
13+
BINARIES_PATH=${2:-./zig-out/bin}
14+
15+
if [[ ! -f "$BINARIES_PATH/nd" || ! -f "$BINARIES_PATH/ngui" ]]; then
16+
echo "Could not find nd/ngui binaries in the specified path: $BINARIES_PATH"
17+
exit 1
18+
fi
19+
20+
ssh_cmd="ssh root@$NAKAMOCHI_IP"
21+
22+
nakamochi_nd_path="$($ssh_cmd 'grep -o "/home/uiuser/v[0-9]\.[0-9]\.[0-9]" /etc/sv/nd/run | head -n 1')"
23+
if [[ -z $nakamochi_nd_path ]]; then
24+
echo "Could not determine Nakamochi nd installation path."
25+
exit 1
26+
fi
27+
28+
$ssh_cmd "sha256sum $nakamochi_nd_path/*; sv stop nd" || { echo "Failed to stop nd service"; exit 1; }
29+
scp "$BINARIES_PATH/nd" "root@$NAKAMOCHI_IP:$nakamochi_nd_path/nd" || { echo "Failed to copy nd binary"; exit 1; }
30+
scp "$BINARIES_PATH/ngui" "root@$NAKAMOCHI_IP:$nakamochi_nd_path/ngui" || { echo "Failed to copy ngui binary"; exit 1; }
31+
$ssh_cmd "sha256sum $nakamochi_nd_path/*; sv start nd; grep ndg /var/log/socklog/daemon/current | tail"
32+
33+
echo "Nakamochi NDG update completed."

0 commit comments

Comments
 (0)