Initial commit: OpenCode setup and configuration
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
.env
|
||||
node_modules/
|
||||
.DS_Store
|
||||
.opencode/
|
||||
16
AGENTS.md
Normal file
16
AGENTS.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# OpenCode Agents
|
||||
|
||||
This file provides context for OpenCode about the project structure and coding patterns.
|
||||
|
||||
## Project Structure
|
||||
- `setup.sh`: Installation script
|
||||
- `opencode.service`: Systemd service definition
|
||||
- `opencode.nginx`: Nginx configuration
|
||||
- `fix_setup.sh`: Repair script
|
||||
- `.env`: Environment variables
|
||||
|
||||
## Tech Stack
|
||||
- Bash scripts
|
||||
- Systemd
|
||||
- Nginx
|
||||
- Node.js (OpenCode runtime)
|
||||
22
apply_https.sh
Executable file
22
apply_https.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "Applying Nginx SSL configuration for OpenCode..."
|
||||
|
||||
# Copy new config to available sites
|
||||
sudo cp /home/wartana/opencode/opencode.nginx /etc/nginx/sites-available/opencode
|
||||
|
||||
# Ensure link exists
|
||||
if [ ! -L /etc/nginx/sites-enabled/opencode ]; then
|
||||
sudo ln -s /etc/nginx/sites-available/opencode /etc/nginx/sites-enabled/
|
||||
fi
|
||||
|
||||
# Test configuration
|
||||
echo "Testing Nginx configuration..."
|
||||
sudo nginx -t
|
||||
|
||||
# Reload Nginx
|
||||
echo "Reloading Nginx..."
|
||||
sudo systemctl reload nginx
|
||||
|
||||
echo "HTTPS configuration applied successfully!"
|
||||
7
check_port.sh
Executable file
7
check_port.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
echo "=== Port 3030 User ==="
|
||||
sudo ss -tulpn | grep 3030
|
||||
|
||||
echo "=== Change Port and Fix ==="
|
||||
# Prevent auto-execution of this part until confirmed, but the script puts it all together.
|
||||
# I will use separate steps.
|
||||
6
debug_nginx.sh
Executable file
6
debug_nginx.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
echo "=== Sites Enabled ==="
|
||||
ls -l /etc/nginx/sites-enabled/
|
||||
|
||||
echo -e "\n=== Server Names in Config ==="
|
||||
sudo nginx -T 2>/dev/null | grep -E "server_name|listen"
|
||||
31
fix_setup.sh
Executable file
31
fix_setup.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "Stopping service..."
|
||||
sudo systemctl stop opencode
|
||||
|
||||
echo "Updating service configuration (Port 3040)..."
|
||||
sudo cp /home/wartana/opencode/opencode.service /etc/systemd/system/opencode.service
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Updating Nginx configuration..."
|
||||
sudo cp /home/wartana/opencode/opencode.nginx /etc/nginx/sites-available/opencode
|
||||
|
||||
echo "Removing conflicting OpenCode config..."
|
||||
if [ -L /etc/nginx/sites-enabled/opencode.oncloud.my.id ]; then
|
||||
sudo rm /etc/nginx/sites-enabled/opencode.oncloud.my.id
|
||||
fi
|
||||
if [ -f /etc/nginx/sites-available/opencode.oncloud.my.id ]; then
|
||||
echo "Warning: Leaving /etc/nginx/sites-available/opencode.oncloud.my.id but disabled it."
|
||||
fi
|
||||
|
||||
echo "Starting OpenCode on new port..."
|
||||
sudo systemctl start opencode
|
||||
|
||||
echo "Reloading Nginx..."
|
||||
sudo nginx -t
|
||||
sudo systemctl reload nginx
|
||||
|
||||
echo "Verification:"
|
||||
sudo systemctl status opencode --no-pager
|
||||
echo "Done. Please check https://opencode.oncloud.my.id"
|
||||
6
inspect_nginx.sh
Executable file
6
inspect_nginx.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
echo "=== opencode.oncloud.my.id ==="
|
||||
cat /etc/nginx/sites-enabled/opencode.oncloud.my.id
|
||||
|
||||
echo -e "\n=== gitea ==="
|
||||
cat /etc/nginx/sites-enabled/gitea
|
||||
31
opencode.nginx
Normal file
31
opencode.nginx
Normal file
@@ -0,0 +1,31 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name opencode.oncloud.my.id;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name opencode.oncloud.my.id;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/opencode.oncloud.my.id/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/opencode.oncloud.my.id/privkey.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:3040;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Performance Optimizations
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
client_max_body_size 0;
|
||||
proxy_read_timeout 86400s;
|
||||
proxy_send_timeout 86400s;
|
||||
}
|
||||
}
|
||||
14
opencode.service
Normal file
14
opencode.service
Normal file
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=OpenCode Web Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=wartana
|
||||
WorkingDirectory=/home/wartana
|
||||
EnvironmentFile=/home/wartana/opencode/.env
|
||||
ExecStart=/home/wartana/.opencode/bin/opencode web --port 3040 --hostname 127.0.0.1
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
6
remove_registry.sh
Executable file
6
remove_registry.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
echo "Removing Registry Nginx Config..."
|
||||
sudo rm /etc/nginx/sites-enabled/registry.oncloud.my.id
|
||||
sudo systemctl reload nginx
|
||||
|
||||
echo "Registry has been disabled."
|
||||
21
setup.sh
Executable file
21
setup.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "Installing OpenCode service..."
|
||||
sudo cp /home/wartana/opencode/opencode.service /etc/systemd/system/opencode.service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable opencode
|
||||
sudo systemctl start opencode
|
||||
|
||||
echo "Configuring Nginx..."
|
||||
sudo cp /home/wartana/opencode/opencode.nginx /etc/nginx/sites-available/opencode
|
||||
sudo ln -sf /etc/nginx/sites-available/opencode /etc/nginx/sites-enabled/
|
||||
|
||||
echo "Testing Nginx configuration..."
|
||||
sudo nginx -t
|
||||
sudo systemctl reload nginx
|
||||
|
||||
echo "Setting up SSL with Certbot..."
|
||||
sudo certbot --nginx -d opencode.oncloud.my.id
|
||||
|
||||
echo "Done! OpenCode should be accessible at https://opencode.oncloud.my.id"
|
||||
Reference in New Issue
Block a user