fix: Fixed installation issues with the install.sh script.
This commit is contained in:
@@ -57,7 +57,6 @@ One-click installation script that downloads pre-built binaries from GitHub Rele
|
|||||||
#### Installation Steps
|
#### Installation Steps
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Download and run the installation script
|
|
||||||
curl -sSL https://raw.githubusercontent.com/Wei-Shaw/sub2api/main/deploy/install.sh | sudo bash
|
curl -sSL https://raw.githubusercontent.com/Wei-Shaw/sub2api/main/deploy/install.sh | sudo bash
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ Sub2API 是一个 AI API 网关平台,用于分发和管理 AI 产品订阅(
|
|||||||
#### 安装步骤
|
#### 安装步骤
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 下载并运行安装脚本
|
|
||||||
curl -sSL https://raw.githubusercontent.com/Wei-Shaw/sub2api/main/deploy/install.sh | sudo bash
|
curl -sSL https://raw.githubusercontent.com/Wei-Shaw/sub2api/main/deploy/install.sh | sudo bash
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -260,8 +260,19 @@ print_error() {
|
|||||||
echo -e "${RED}[$(msg 'error')]${NC} $1"
|
echo -e "${RED}[$(msg 'error')]${NC} $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if running interactively (stdin is a terminal)
|
||||||
|
is_interactive() {
|
||||||
|
[ -t 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
# Select language
|
# Select language
|
||||||
select_language() {
|
select_language() {
|
||||||
|
# If not interactive (piped), use default language
|
||||||
|
if ! is_interactive; then
|
||||||
|
LANG_CHOICE="zh"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${CYAN}=============================================="
|
echo -e "${CYAN}=============================================="
|
||||||
echo " $(msg 'select_lang')"
|
echo " $(msg 'select_lang')"
|
||||||
@@ -271,8 +282,7 @@ select_language() {
|
|||||||
echo " 2) $(msg 'lang_en')"
|
echo " 2) $(msg 'lang_en')"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Read with timeout for piped input
|
read -p "$(msg 'enter_choice'): " lang_input
|
||||||
read -t 10 -p "$(msg 'enter_choice'): " lang_input 2>/dev/null || lang_input=""
|
|
||||||
|
|
||||||
case "$lang_input" in
|
case "$lang_input" in
|
||||||
2|en|EN|english|English)
|
2|en|EN|english|English)
|
||||||
@@ -297,6 +307,12 @@ validate_port() {
|
|||||||
|
|
||||||
# Configure server settings
|
# Configure server settings
|
||||||
configure_server() {
|
configure_server() {
|
||||||
|
# If not interactive (piped), use default settings
|
||||||
|
if ! is_interactive; then
|
||||||
|
print_info "$(msg 'server_config_summary'): ${SERVER_HOST}:${SERVER_PORT} (default)"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${CYAN}=============================================="
|
echo -e "${CYAN}=============================================="
|
||||||
echo " $(msg 'server_config_title')"
|
echo " $(msg 'server_config_title')"
|
||||||
@@ -663,11 +679,20 @@ upgrade() {
|
|||||||
# Uninstall function
|
# Uninstall function
|
||||||
uninstall() {
|
uninstall() {
|
||||||
print_warning "$(msg 'uninstall_confirm')"
|
print_warning "$(msg 'uninstall_confirm')"
|
||||||
read -p "$(msg 'are_you_sure') " -n 1 -r
|
|
||||||
echo
|
# If not interactive (piped), require -y flag or skip confirmation
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
if ! is_interactive; then
|
||||||
print_info "$(msg 'uninstall_cancelled')"
|
if [ "${FORCE_YES:-}" != "true" ]; then
|
||||||
exit 0
|
print_error "Non-interactive mode detected. Use 'bash -s -- uninstall -y' to confirm."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
read -p "$(msg 'are_you_sure') " -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
print_info "$(msg 'uninstall_cancelled')"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_info "$(msg 'stopping_service')"
|
print_info "$(msg 'stopping_service')"
|
||||||
@@ -693,6 +718,13 @@ uninstall() {
|
|||||||
|
|
||||||
# Main
|
# Main
|
||||||
main() {
|
main() {
|
||||||
|
# Parse -y flag first
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [ "$arg" = "-y" ] || [ "$arg" = "--yes" ]; then
|
||||||
|
FORCE_YES="true"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Select language first
|
# Select language first
|
||||||
select_language
|
select_language
|
||||||
|
|
||||||
@@ -716,13 +748,16 @@ main() {
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
--help|-h)
|
--help|-h)
|
||||||
echo "$(msg 'usage'): $0 [command]"
|
echo "$(msg 'usage'): $0 [command] [options]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
echo " $(msg 'cmd_none') $(msg 'cmd_install')"
|
echo " $(msg 'cmd_none') $(msg 'cmd_install')"
|
||||||
echo " upgrade $(msg 'cmd_upgrade')"
|
echo " upgrade $(msg 'cmd_upgrade')"
|
||||||
echo " uninstall $(msg 'cmd_uninstall')"
|
echo " uninstall $(msg 'cmd_uninstall')"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "Options:"
|
||||||
|
echo " -y, --yes Skip confirmation prompts (for uninstall)"
|
||||||
|
echo ""
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user