-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·52 lines (45 loc) · 1.72 KB
/
install.sh
File metadata and controls
executable file
·52 lines (45 loc) · 1.72 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
#!/bin/bash
#
# API Cockpit - Install Script
# Sets up the cockpit skill, permissions, and cron jobs
#
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "Installing API Cockpit in ${SCRIPT_DIR}..."
# Set correct permissions
echo "Setting permissions..."
chmod 700 "${SCRIPT_DIR}"
chmod 600 "${SCRIPT_DIR}/config" 2>/dev/null || true
chmod 600 "${SCRIPT_DIR}/config/.env" 2>/dev/null || true
chmod 700 "${SCRIPT_DIR}/"*.sh 2>/dev/null || true
chmod 700 "${SCRIPT_DIR}/lib/"*.py 2>/dev/null || true
# Create required directories
echo "Creating directories..."
mkdir -p "${SCRIPT_DIR}/logs"
mkdir -p "${SCRIPT_DIR}/data"
mkdir -p "${SCRIPT_DIR}/locks"
chmod 700 "${SCRIPT_DIR}/logs" "${SCRIPT_DIR}/data" "${SCRIPT_DIR}/locks"
# Install logrotate config
echo "Installing logrotate..."
if [ -d "/etc/logrotate.d" ]; then
if [ -f "${SCRIPT_DIR}/logrotate.d/api-cockpit" ]; then
cp "${SCRIPT_DIR}/logrotate.d/api-cockpit" "/etc/logrotate.d/api-cockpit"
chmod 644 "/etc/logrotate.d/api-cockpit"
echo "✓ logrotate config installed"
fi
fi
# Copy config template if not exists
if [ ! -f "${SCRIPT_DIR}/config/.env" ] && [ -f "${SCRIPT_DIR}/config/.env.example" ]; then
echo "Creating config from template..."
cp "${SCRIPT_DIR}/config/.env.example" "${SCRIPT_DIR}/config/.env"
chmod 600 "${SCRIPT_DIR}/config/.env"
echo "⚠️ Please edit ${SCRIPT_DIR}/config/.env and fill in your credentials!"
fi
echo ""
echo "✅ API Cockpit installed!"
echo ""
echo "Next steps:"
echo "1. Edit config: ${SCRIPT_DIR}/config/.env"
echo "2. Test health check: ${SCRIPT_DIR}/cockpit-admin.sh health"
echo "3. (Optional) Install cron: cp ${SCRIPT_DIR}/cron.example /etc/cron.d/api-cockpit"
echo ""