-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73cc4f1
commit bf553d0
Showing
3 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/bash | ||
|
||
# Default paths | ||
DEFAULT_SYNC_CHOICES=( | ||
"./fabric-sync" | ||
"out/debug/standalone/fabric-sync" | ||
"out/linux-x64-fabric-sync/fabric-sync" | ||
) | ||
|
||
FABRIC_SYNC_PATH="" | ||
FABRIC_BRIDGE_APP_PATH="fabric-bridge" | ||
|
||
# Function to find a binary | ||
find_binary() { | ||
local choices=("$@") | ||
for path in "${choices[@]}"; do | ||
if [[ -e "$path" ]]; then | ||
echo "$path" | ||
return 0 | ||
fi | ||
done | ||
return 1 | ||
} | ||
|
||
# Parse arguments | ||
DEBUG=false | ||
SPECIFIED_SYNC_PATH="" | ||
|
||
for arg in "$@"; do | ||
case $arg in | ||
--debug) | ||
DEBUG=true | ||
;; | ||
--sync-path=*) | ||
SPECIFIED_SYNC_PATH="${arg#*=}" | ||
;; | ||
esac | ||
done | ||
|
||
# Use specified paths if provided | ||
if [[ -n "$SPECIFIED_SYNC_PATH" ]]; then | ||
if [[ -e "$SPECIFIED_SYNC_PATH" ]]; then | ||
FABRIC_SYNC_PATH="$SPECIFIED_SYNC_PATH" | ||
else | ||
echo >&2 "Specified fabric sync path does not exist: $SPECIFIED_SYNC_PATH" | ||
exit 1 | ||
fi | ||
else | ||
FABRIC_SYNC_PATH=$(find_binary "${DEFAULT_SYNC_CHOICES[@]}") | ||
if [[ $? -ne 0 ]]; then | ||
echo >&2 "Could not find the fabric-sync binary" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
echo "Fabric Sync path: $FABRIC_SYNC_PATH" | ||
|
||
# Kill fabric-bridge-app if it is running | ||
fabric_bridge_app_pid=$(pgrep "$FABRIC_BRIDGE_APP_PATH") | ||
echo "Found fabric-bridge-app PID: $fabric_bridge_app_pid" | ||
if [ ! -z "$fabric_bridge_app_pid" ]; then | ||
kill -9 "$fabric_bridge_app_pid" | ||
echo "Killed fabric-bridge-app with PID $fabric_bridge_app_pid" | ||
fi | ||
|
||
# Remove /tmp/chip_* files and directories | ||
rm -rf /tmp/chip_* | ||
rm -rf /tmp/fabric_sync.log | ||
echo "Removed /tmp/chip_* files and directories." | ||
|
||
# Start fabric-admin with or without log file path based on --verbose option | ||
if [ "$DEBUG" = true ]; then | ||
code . | ||
else | ||
"$FABRIC_SYNC_PATH" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters