Add new-api (ct)

This commit is contained in:
push-app-to-main[bot] committed 2026-11-13 07:41:51 +00:00
1 parent c9ba40bfdb
commit fcf67de6ec
2 files changed
+127

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func"
source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func")
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/QuantumNous/new-api
APP="New-API"
var_tags="${var_tags:-ai;llm;gateway}"
var_cpu="${var_cpu:-1}"
var_ram="${var_ram:-512}"
var_disk="${var_disk:-4}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_arm64="${var_arm64:-yes}"
var_unprivileged="${var_unprivileged:-1}"
export var_admin_user="${var_admin_user:-}"
export var_admin_pass="${var_admin_pass:-}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -f /opt/new-api/new-api ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if check_for_gh_release "new-api" "QuantumNous/new-api"; then
msg_info "Stopping New API"
systemctl stop new-api
msg_ok "Stopped New API"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "new-api" "QuantumNous/new-api" "singlefile" "latest" "/opt/new-api" "$(arch_resolve "new-api-v" "new-api-arm64-v")*[0-9]"
msg_info "Starting New API"
systemctl start new-api
msg_ok "Started New API"
msg_ok "Updated successfully!"
fi
exit
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW}Access it using the following URL:${CL}"
echo -e "${GATEWAY}${BGN}http://${IP}:3000${CL}"
echo -e "${INFO}${YW}Admin login: /opt/new-api_data/.env (inside the container)${CL}"
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/QuantumNous/new-api
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
fetch_and_deploy_gh_release "new-api" "QuantumNous/new-api" "singlefile" "latest" "/opt/new-api" "$(arch_resolve "new-api-v" "new-api-arm64-v")*[0-9]"
msg_info "Configuring New API"
ADMIN_USER="${var_admin_user:-admin}"
ADMIN_PASS="${var_admin_pass:-$(random_password)}"
mkdir -p /opt/new-api_data/logs
cat <<EOF >/opt/new-api_data/.env
PORT=3000
SQLITE_PATH=/opt/new-api_data/new-api.db
SESSION_SECRET=$(openssl rand -hex 32)
CRYPTO_SECRET=$(openssl rand -hex 32)
BATCH_UPDATE_ENABLED=true
NEW_API_ADMIN_USER=${ADMIN_USER}
NEW_API_ADMIN_PASSWORD=${ADMIN_PASS}
EOF
chmod 600 /opt/new-api_data/.env
msg_ok "Configured New API"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/new-api.service
[Unit]
Description=New API
After=network.target
[Service]
Type=simple
WorkingDirectory=/opt/new-api_data
EnvironmentFile=/opt/new-api_data/.env
ExecStart=/opt/new-api/new-api --log-dir /opt/new-api_data/logs
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now new-api
msg_ok "Created Service"
msg_info "Creating New API Admin Account"
for _ in {1..60}; do
curl -fsS http://127.0.0.1:3000/api/status &>/dev/null && break
sleep 1
done
jq -nc --arg u "$ADMIN_USER" --arg p "$ADMIN_PASS" \
'{username: $u, password: $p, confirmPassword: $p, SelfUseModeEnabled: false, DemoSiteEnabled: false}' |
curl -fsS -X POST http://127.0.0.1:3000/api/setup -H "Content-Type: application/json" --data-binary @- |
jq -e '.success' >/dev/null
msg_ok "Created New API Admin Account"
motd_ssh
customize
cleanup_lxc