-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
149 lines (130 loc) · 4.9 KB
/
Copy pathinstall.sh
File metadata and controls
149 lines (130 loc) · 4.9 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env bash
set -e
# ─────────────────────────────────────────────────────
# PATH safeguard – works even from GUI shells / cron
# ─────────────────────────────────────────────────────
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
# quick sanity-check (coreutils + git + python must exist)
for bin in mkdir git python3; do
command -v "$bin" >/dev/null || {
echo "❌ '$bin' not found in PATH – current PATH is: $PATH"
# exit 1
}
done
# ─────────────────────────────────────────────────────
# Variables & Paths
# ─────────────────────────────────────────────────────
ROOT="$(cd "$(dirname "$0")" && pwd)"
SRC="$ROOT/core"
VENVDIR="$ROOT/venv"
DATA="$SRC/desktop_data"
# ─────────────────────────────────────────────────────
# Bootstrap: clone repo, create venv, reinstall SDK & Rust
# ─────────────────────────────────────────────────────
bootstrap() {
echo "🔧 Bootstrapping environment..."
# Clone if missing
if [ ! -d "$SRC" ]; then
echo "📥 Cloning Summoner SDK..."
git clone --depth 1 https://github.com/Summoner-Network/summoner-core.git "$SRC"
fi
# Create venv if missing
if [ ! -d "$VENVDIR" ]; then
echo "🐍 Creating virtualenv..."
python3 -m venv "$VENVDIR"
fi
# Activate venv
. "$VENVDIR/bin/activate"
# Ensure build tools
echo "🔧 Installing build requirements..."
pip install --upgrade pip setuptools wheel maturin
# Create the .env file
cat <<EOF > "$SRC/.env"
DATABASE_URL=postgres://user:pass@localhost:5432/mydb
SECRET_KEY=supersecret
EOF
# Reinstall Python & Rust SDK via backend scripts
echo "🔁 Reinstalling Python & Rust SDK..."
bash "$SRC/reinstall_python_sdk.sh" rust_server_v1_0_0
}
# ─────────────────────────────────────────────────────
# Usage message
# ─────────────────────────────────────────────────────
usage() {
echo "Usage: $0 {setup|delete|reset|deps|test_server|clean}"
# exit 1
}
# ─────────────────────────────────────────────────────
# Dispatch
# ─────────────────────────────────────────────────────
case "$1" in
setup)
if [ ! -d "$VENVDIR" ]; then
echo "⚠️ Environment not found; running setup..."
bootstrap
else
. "$VENVDIR/bin/activate"
fi
echo "✅ Environment ready at $ROOT"
# exit 0
;;
delete)
echo "🔄 Deleting environment..."
rm -rf "$SRC" "$VENVDIR" "$ROOT"/logs
rm -f "$ROOT"/test_*.{py,json}
echo "✅ Deletion complete"
# exit 0
;;
reset)
echo "🔄 Resetting environment..."
rm -rf "$SRC" "$VENVDIR" "$ROOT"/logs
bootstrap
echo "✅ Reset complete"
# exit 0
;;
deps)
if [ ! -d "$VENVDIR" ]; then
echo "⚠️ Environment not found; running setup..."
bootstrap
else
. "$VENVDIR/bin/activate"
fi
bash "$SRC/reinstall_python_sdk.sh" rust_server_v1_0_0
echo "✅ Dependencies reinstalled"
# exit 0
;;
test_server)
if [ ! -d "$VENVDIR" ]; then
echo "⚠️ Environment not found; running setup..."
bootstrap
else
. "$VENVDIR/bin/activate"
fi
DEFAULT_CFG="$DATA/default_config.json"
if [ ! -f "$DEFAULT_CFG" ]; then
echo "❌ Default config missing: $DEFAULT_CFG"
# exit 1
fi
cp "$DEFAULT_CFG" "$ROOT/test_server_config.json"
cat > "$ROOT/test_server.py" <<'EOF'
from summoner.server import SummonerServer
from tooling.your_package import hello_summoner
if __name__ == "__main__":
hello_summoner()
srv = SummonerServer(name="test_Server")
srv.run(config_path="test_server_config.json")
EOF
LAUNCH_CMD="source \"$VENVDIR/bin/activate\" && python test_server.py --config test_server_config.json"
bash "$SRC/open_server.sh" "$ROOT" "$LAUNCH_CMD"
;;
clean)
echo "🧹 Cleaning test scripts..."
rm -rf "$ROOT"/logs/*
rm -f "$ROOT"/test_*.{py,json}
echo "✅ Clean complete"
# exit 0
;;
*)
usage
;;
esac