share-copilot/install.sh
2023-09-09 10:35:39 +08:00

47 lines
918 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
START_SCRIPT_PATH="/usr/local/bin/scop"
cat > "$START_SCRIPT_PATH" <<EOF
#!/bin/bash
EXECUTABLE_DIR="$SCRIPT_DIR"
EXECUTABLE="\$EXECUTABLE_DIR/share-copilot"
case "\$1" in
r)
echo "Running share-copilot..."
"\$EXECUTABLE"
;;
rb)
echo "Running share-copilot in the background..."
"\$EXECUTABLE" >/dev/null 2>&1 &
;;
st)
echo "Stopping share-copilot..."
pkill -f "\$EXECUTABLE"
;;
v)
if pgrep -f "\$EXECUTABLE" >/dev/null; then
echo "share-copilot is running"
else
echo "share-copilot is not running"
fi
;;
*)
echo "Usage: \$0 {r|rb|st|v}"
exit 1
;;
esac
exit 0
EOF
chmod +x "$START_SCRIPT_PATH"
echo "-----------------
install success
-----------------
scop r --运行
scop rb --后台运行
scop st --停止
scop v --查看状态
-----------------"