-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·102 lines (86 loc) · 3.38 KB
/
setup.sh
File metadata and controls
executable file
·102 lines (86 loc) · 3.38 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
set -e
# --- Script to set up a new development environment for the Corecast Host ---
# This script must be run with sudo.
# 1. Check for root privileges
if [ "$EUID" -ne 0 ]; then
echo "❌ This script must be run with sudo."
echo "Please run as: sudo ./setup.sh"
exit 1
fi
echo "🚀 Starting Corecast Host development setup..."
# 2. Update package lists and install dependencies
echo " -> Updating package lists..."
apt-get update > /dev/null
echo " -> Installing build tools (build-essential, cmake, pkg-config) and libssh..."
# Note: Added 'build-essential' to ensure all core C/C++ headers are present.
apt-get install -y build-essential cmake pkg-config libssh-dev > /dev/null
# 3. Create the configuration directory
CONFIG_DIR="/etc/corecast"
echo " -> Ensuring directory exists: $CONFIG_DIR"
mkdir -p "$CONFIG_DIR"
# 4. Create the .env file if it doesn't exist
ENV_FILE="${CONFIG_DIR}/.env"
if [ ! -f "$ENV_FILE" ]; then
echo " -> No .env file found. Creating a default one at $ENV_FILE..."
# Use a 'here document' to write the default configuration
cat << 'EOF' > "$ENV_FILE"
# Corecast Host Configuration
# This file defines settings for the host application.
# --- Connection Settings ---
CORECAST_SERVER_HOST=127.0.0.1
CORECAST_SERVER_USER=corecast-host
CORECAST_SSH_PORT=2222
# !!! IMPORTANT: CHANGE THIS TO A STRONG, SECURE PASSWORD !!!
CORECAST_SERVER_PASS=CorecastPassword123!
# --- Port Forwarding Settings ---
CORECAST_FORWARD_PORT=6000
CORECAST_SOAPY_PORT=55132
# --- Advanced Settings ---
CORECAST_RPC_TIMEOUT=8000
EOF
echo " -> Default .env file created."
else
echo " -> Found existing .env file. Skipping creation."
fi
# ssh -N -R 6000:127.0.0.1:55132 corecast-host@127.0.0.1 -p 2222
# 5. Generate the SSH key pair if it doesn't exist
KEY_PATH="${CONFIG_DIR}/id_rsa"
if [ ! -f "$KEY_PATH" ]; then
echo " -> No SSH key found. Generating a new one at $KEY_PATH..."
ssh-keygen -t ed25519 -f "$KEY_PATH" -N "" # -N "" for no passphrase
echo " -> New SSH key generated."
else
echo " -> Found existing SSH key. Skipping generation."
fi
# 6. Set correct permissions for all configuration files
echo " -> Setting secure permissions for config files..."
# The .env file contains a password and should only be readable by its owner.
chmod 600 "$ENV_FILE"
# The private key must only be readable by its owner.
chmod 600 "$KEY_PATH"
# The public key is safe to be world-readable.
chmod 644 "${KEY_PATH}.pub"
# Optional: If you later run the service as a non-root user (e.g., 'ccrx'),
# you would set ownership like this:
# chown -R ccrx:ccrx "$CONFIG_DIR"
echo ""
echo "✅ Setup Complete! Your environment is ready to build."
echo "------------------------------------------------------------------"
echo "📝 NEXT STEP 1: Configure Your Server"
echo ""
echo " The default .env file has been created at:"
echo " ${ENV_FILE}"
echo ""
echo " YOU MUST EDIT THIS FILE to set a secure password!"
echo " sudo nano ${ENV_FILE}"
echo "------------------------------------------------------------------"
echo "🔑 NEXT STEP 2: Provide the Public Key to Your Docker Container"
echo ""
echo " Your PUBLIC key is:"
echo ""
cat "${KEY_PATH}.pub"
echo ""
echo " Copy the line above and place it in the 'host_key.pub' file"
echo " in your Docker project before building the container."
echo "------------------------------------------------------------------"