Skip to content

Commit be169d2

Browse files
committed
upload bridge-executor.sh
1 parent 5147b1d commit be169d2

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

scripts/bridge-executor.sh

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/bin/bash
2+
3+
# SCRIPT_PATH=$HOME/.parallel_bridge_install.sh
4+
BASE_KEYSTORE_DIR=$HOME/.parallel_bridge_keystore
5+
ORG=paraspace
6+
IMAGE_NAME=bridge-executor
7+
SERVICE_NAME=bridge-executor
8+
9+
function install_executor() {
10+
echo "Installing bridge executor service at $BASE_KEYSTORE_DIR"
11+
if ! command -v docker &>/dev/null; then
12+
sudo apt upgrade -y
13+
sudo apt install pkg-config curl build-essential libssl-dev libclang-dev ufw docker-compose-plugin -y
14+
15+
sudo apt-get install ca-certificates curl gnupg lsb-release
16+
17+
sudo mkdir -p /etc/apt/keyrings
18+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
19+
20+
echo \
21+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
22+
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
23+
24+
sudo chmod a+r /etc/apt/keyrings/docker.gpg
25+
sudo apt-get update
26+
27+
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
28+
else
29+
echo "🌀 Docker Installed"
30+
fi
31+
32+
# sudo docker run hello-world
33+
echo "🌀 Pulling the latest image of bridge executor ..."
34+
docker pull $ORG/$IMAGE_NAME:latest
35+
echo "🐤 Parallel Bridge Executor installed successfully >#<"
36+
}
37+
38+
function create_keystore() {
39+
echo "🌀 Creating keystore at $BASE_KEYSTORE_DIR ..."
40+
docker run --rm -it -v "$BASE_KEYSTORE_DIR:/app/keystore" -e "CI=true" $ORG/$IMAGE_NAME pnpm create-keystore
41+
}
42+
43+
function start_service() {
44+
echo ":::::::::: 🙌 Ctrl+C 🙌 to exit the service and hang up the container"
45+
docker run --rm -it --name $SERVICE_NAME -v "$BASE_KEYSTORE_DIR:/app/keystore" --detach-keys="ctrl-c" -e "CI=true" $ORG/$IMAGE_NAME pnpm prod
46+
echo "🌀 Parallel Bridge Executor service started successfully >#<"
47+
}
48+
49+
function check_service_status() {
50+
docker logs -f $SERVICE_NAME
51+
}
52+
53+
function check_keystore_status() {
54+
# list all files in the keystore
55+
ls -l $BASE_KEYSTORE_DIR/default
56+
echo "All files in the keystore are listed above"
57+
}
58+
59+
function stop_service() {
60+
echo "Stopping bridge executor service"
61+
docker rm -f $SERVICE_NAME
62+
}
63+
64+
function uninstall_executor() {
65+
echo "Uninstalling bridge executor service"
66+
docker stop $SERVICE_NAME
67+
docker rm $SERVICE_NAME
68+
docker rmi $ORG/$IMAGE_NAME
69+
echo "Cleaning up keystore at $BASE_KEYSTORE_DIR"
70+
rm -rf $BASE_KEYSTORE_DIR
71+
echo "Parallel Bridge Executor uninstalled successfully >#<"
72+
}
73+
74+
function show_menu() {
75+
echo "================================================================"
76+
echo "🪭 Parallel Bridge Executor Installer"
77+
echo "0. ⏩️ Intall parallel bridge executor (required ⛳️)"
78+
echo "1. 🐤 Create Keystore (required ⛳️)"
79+
echo "2. 🤖 Start service (required ⛳️)"
80+
echo "3. 🌀 Check service status"
81+
echo "4. 🦄 Check keystore status"
82+
echo "5. 🎯 Stop parallel bridge executor"
83+
echo "6. 🎨 Uninstall parallel bridge executor"
84+
echo "7. ✅ Exit the script"
85+
echo "The basic workflow is 0 -> 1 -> 2"
86+
read -p "😆 Enter your option: " OPTION
87+
echo "================================================================"
88+
89+
case $OPTION in
90+
0) install_executor ;;
91+
1) create_keystore ;;
92+
2) start_service ;;
93+
3) check_service_status ;;
94+
4) check_keystore_status ;;
95+
5) stop_service ;;
96+
6) uninstall_executor ;;
97+
7) exit ;;
98+
*) echo "❌ Invalid option. Please try again(0-7)." ;;
99+
esac
100+
}
101+
102+
function main_menu() {
103+
clear
104+
clear
105+
if [ "$(id -u)" != "0" ]; then
106+
echo "please run this script as root user to avoid permission issues."
107+
echo "try sudo ./ParallelBridgeExecutor.sh"
108+
exit 1
109+
fi
110+
111+
# echo "Script path: $SCRIPT_PATH"
112+
echo "Keystore path: $BASE_KEYSTORE_DIR"
113+
echo "HOME path: $HOME"
114+
while true; do
115+
show_menu
116+
done
117+
}
118+
119+
main_menu

0 commit comments

Comments
 (0)