| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #!/usr/bin/env bash
- set -euo pipefail
- PREFIX="${1:-/opt/mynetspeeder}"
- BIN_PATH="/usr/local/bin/mynetspeeder"
- PYTHON_BIN="${PYTHON_BIN:-$(command -v python3 || true)}"
- PACKAGE_PARENT="$(dirname "$PREFIX")"
- PACKAGE_NAME="$(basename "$PREFIX")"
- if [[ $EUID -ne 0 ]]; then
- echo "need root"
- exit 1
- fi
- if [[ -z "$PYTHON_BIN" ]]; then
- echo "python3 not found"
- exit 1
- fi
- if ! command -v rsync >/dev/null 2>&1; then
- echo "rsync not found"
- exit 1
- fi
- mkdir -p "$PREFIX"
- rsync -a --delete /home/mynetspeeder/ "$PREFIX/"
- find "$PREFIX" -name '__pycache__' -type d -prune -exec rm -rf {} +
- cat > "$BIN_PATH" <<EOF
- #!/usr/bin/env bash
- set -euo pipefail
- export PYTHONPATH="$PACKAGE_PARENT\${PYTHONPATH:+:\$PYTHONPATH}"
- cd "$PACKAGE_PARENT"
- exec "$PYTHON_BIN" -m "$PACKAGE_NAME" "\$@"
- EOF
- chmod +x "$BIN_PATH"
- chmod +x \
- "$PREFIX/scripts/install.sh" \
- "$PREFIX/scripts/start-main.sh" \
- "$PREFIX/scripts/stop-main.sh" \
- "$PREFIX/scripts/start-relay-main.sh" \
- "$PREFIX/scripts/stop-relay-main.sh" \
- "$PREFIX/scripts/commands/tcp_only_start.sh" \
- "$PREFIX/scripts/commands/tcp_only_stop.sh" \
- "$PREFIX/scripts/commands/udp_only_start.sh" \
- "$PREFIX/scripts/commands/udp_only_stop.sh" \
- "$PREFIX/scripts/commands/start-relay-tcp.sh" \
- "$PREFIX/scripts/commands/stop-relay-tcp.sh" \
- "$PREFIX/scripts/commands/start-relay-udp.sh" \
- "$PREFIX/scripts/commands/stop-relay-udp.sh"
- echo "installed to $PREFIX"
- echo "package parent: $PACKAGE_PARENT"
- echo "command: $BIN_PATH"
- echo "test: mynetspeeder --help"
|