Deploy OpenDevin

1. pull image:

docker pull ghcr.io/opendevin/opendevin:latest

2. make the installation script setup_opendevin.sh:

echo "Starting OpenDevin setup..."
export WORKSPACE_BASE=/home/yourUserName/dev/opendevin/workspace
echo "WORKSPACE_BASE set to $WORKSPACE_BASE"

echo "Checking .env file..."
cat .env

docker run \
    -it \
    --env-file .env \
    -e SANDBOX_USER_ID=$(id -u) \
    -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \
    -v $WORKSPACE_BASE:/opt/workspace_base \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -p 3000:3000 \
    --add-host host.docker.internal:host-gateway \
    ghcr.io/opendevin/opendevin:latest

echo "Docker container started."

3. make .env file: eg(Azure OpenAI):

LLM_BASE_URL="https://xxx.openai.azure.com/"
LLM_API_KEY=""
LLM_MODEL="azure/[yourDeployName]"
LLM_API_VERSION="2024-02-01"

4. run installation script

5.access http://localhost:3000/index.html

reference:

💻 OpenDevin

Azure OpenAI LLM

Azure OpenAI

Summary of Common WSL Commands

1.Install WSL with default Ubuntu:

wsl --install

and then reboot.

2.List Available Distributions for Installation:

wsl -l -o

output eg:

NAME                                   FRIENDLY NAME
Ubuntu                                 Ubuntu
Debian                                 Debian GNU/Linux
kali-linux                             Kali Linux Rolling
Ubuntu-18.04                           Ubuntu 18.04 LTS
Ubuntu-20.04                           Ubuntu 20.04 LTS
Ubuntu-22.04                           Ubuntu 22.04 LTS
Ubuntu-24.04                           Ubuntu 24.04 LTS
OracleLinux_7_9                        Oracle Linux 7.9
OracleLinux_8_7                        Oracle Linux 8.7
OracleLinux_9_1                        Oracle Linux 9.1
openSUSE-Leap-15.5                     openSUSE Leap 15.5
SUSE-Linux-Enterprise-Server-15-SP4    SUSE Linux Enterprise Server 15 SP4
SUSE-Linux-Enterprise-15-SP5           SUSE Linux Enterprise 15 SP5
openSUSE-Tumbleweed                    openSUSE Tumbleweed

3. Install a certain distribution:

wsl --install -d Ubuntu-24.04

4. List Installed Linux Distributions and Their WSL Versions:

wsl -l -v

5. Set Default Version for New Linux Installations (WSL 1 or WSL 2):

wsl --set-default-version <Version#>

Replace with 1 or 2 to set the default WSL version for new Linux installations.

6. Set Default Linux Distribution:

wsl -s <DistributionName>

7. Run a Specific Linux Distribution:

wsl -d <DistributionName>

8. Upgrade or Downgrade a Specific Linux Distribution between WSL 1 and WSL 2:

wsl --set-version <distro name> <Version#>

9. Launch the Default Linux Distribution from Command Prompt or PowerShell:

wsl

10. Run Linux Commands without Switching Distributions:

wsl [command]

11. remove an installed Linux distribution in WSL:

wsl --unregister <DistributionName>

12. Default Storage Location:

C:\Users\<YourUsername>\AppData\Local\Packages\CanonicalGroupLimited...Ubuntu..._\LocalState\ext4.vhdx

13. Export an Existing Distribution:

wsl --export <DistributionName> <ExportFilePath>
# eg: wsl --export Ubuntu C:\backups\ubuntu.tar

14. Import to a Custom Location:

wsl --import <NewDistributionName> <TargetFolder> <ImportFilePath>
# eg: wsl --import UbuntuCustom C:\wsl\UbuntuCustom C:\backups\ubuntu.tar

WSL を使用して Windows に Linux をインストールする方法

15. sets up a port proxy from any network interface on a certain port to the local machine’s port. eg:

netsh interface portproxy add v4tov4 listenport=2358 listenaddress=0.0.0.0 connectport=2358 connectaddress=127.0.0.1

just edit /etc/wsl.conf:

[boot]
systemd=true
[user]
default=fsi
[interop]
enabled=true
appendWindowsPath=true

  • Enables systemd
  • Sets default user fsi
  • Lets WSL run Windows apps
  • Adds Windows paths to $PATH

Restart WSL to apply

Steps to Create Users and Assign Databases in PostgreSQL

Log in to PostgreSQL:

psql -U postgres

Create two new users (user1 and user2):

CREATE USER user1 WITH PASSWORD 'yourPassword';
CREATE USER user2 WITH PASSWORD 'yourPassword';

Create databases for each user:

CREATE DATABASE user1dbshare OWNER user1;
CREATE DATABASE user1dbprivate OWNER user1;
CREATE DATABASE user2dbshare OWNER user2;
CREATE DATABASE user2dbprivate OWNER user2;

Create a common_readonly role and configure it to access shared data for all users:

CREATE ROLE common_readonly NOLOGIN;
GRANT CONNECT ON DATABASE user1dbshare TO common_readonly;
GRANT CONNECT ON DATABASE user2dbshare TO common_readonly;

GRANT USAGE ON SCHEMA public TO common_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO common_readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO common_readonly;

GRANT common_readonly TO user1;
GRANT common_readonly TO user2;

Log in to each database and create a table:

For user1dbshare:

\c user1dbshare user1
CREATE TABLE memo (
    id SERIAL PRIMARY KEY,
    key_words VARCHAR(255),
    content TEXT,
    english_content TEXT
);

For user1dbprivate:

\c user1dbprivate user1
CREATE TABLE memo (
    id SERIAL PRIMARY KEY,
    key_words VARCHAR(255),
    content TEXT,
    english_content TEXT
);

For user2dbshare:

\c user2dbshare user2
CREATE TABLE memo (
    id SERIAL PRIMARY KEY,
    key_words VARCHAR(255),
    content TEXT,
    english_content TEXT
);

For user2dbprivate:

\c user2dbprivate user2
CREATE TABLE memo (
    id SERIAL PRIMARY KEY,
    key_words VARCHAR(255),
    content TEXT,
    english_content TEXT
);

Exit:

\q

Linux ACL Management

Assigning Permissions:

This command sets ACL (Access Control List) for the file yourFileName.csv.
-m option indicates modifying the ACL.
u:yourUserName:r assigns read (r) permission to the user yourUserName.

sudo setfacl -m u:yourUserName:r yourFileName.csv

Revoking Permissions

This command removes the ACL entry for the user yourUserName from the file yourFileName.csv.
-x option indicates removing a specified ACL entry.

sudo setfacl -x u:yourUserName yourFileName.csv

Setting Default Permissions (Mask)

This command sets the mask permission for the file yourFileName.csv to read, write, and execute (rwx).
The mask defines the maximum permissions allowed for users other than the owner and the group. Here, setting the mask to rwx allows users to have up to read, write, and execute permissions.

sudo setfacl -m m::rwx yourFileName.csv

Removing All ACL Entries

This command removes all ACL entries from the file yourFileName.csv, resetting it to its default permission state. -b option indicates deleting all ACL entries.

sudo setfacl -b yourFileName.csv

Viewing ACL Settings

This command displays the current ACL settings for the file yourFileName.csv.

getfacl yourFileName.csv

Enable RDP by remote pwsh

# Enable Remote Desktop by modifying the registry
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0

# Check if there is any existing firewall rule for port 3389 (RDP)
$ExistingRule = Get-NetFirewallRule -Direction Inbound | Where-Object { $_.LocalPort -eq 3389 }

# Enable the rule if it exists
if ($ExistingRule) {
    $ExistingRule | Enable-NetFirewallRule
    "Existing Remote Desktop firewall rules have been enabled."
} else {
    # Create a new firewall rule if no existing rule is found
    New-NetFirewallRule -DisplayName "Allow RDP" -Direction Inbound -LocalPort 3389 -Protocol TCP -Action Allow
    "No existing rule found, a new Remote Desktop firewall rule has been created and enabled."
}

# Enable Network Level Authentication (NLA) by modifying the registry
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -value 1

# Check if Remote Desktop service has been enabled
$RDPStatus = (Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server').fDenyTSConnections
if ($RDPStatus -eq 0) {
    "Remote Desktop is enabled"
} else {
    "Remote Desktop is not enabled"
}

Setting a Static IP in Linux with nmcli

  1. If it uses NetworkManager:
    cat /etc/netplan/01-network-manager-all.yaml :
    # Let NetworkManager manage all devices on this system
    network:
     version: 2
     renderer: NetworkManager
  2. Determine the Default Gateway:
    Use the ip route command to find out the default gateway of your network, which is essential for configuring your static IP.
    ip route | grep default | awk '{print $3}'
  3. Setting a Static IP Address:
    Replace "WifiName" with your actual connection name. Here’s how you can set a static IP address, gateway, DNS, and switch the method to manual:
    nmcli con mod "WifiName" ipv4.addresses 192.168.1.10/24
    nmcli con mod "WifiName" ipv4.gateway 192.168.1.1
    nmcli con mod "WifiName" ipv4.dns "8.8.8.8"
    nmcli con mod "WifiName" ipv4.method manual
  4. Applying the Changes:
    After setting the static IP, you need to restart the network connection to apply these changes:
    nmcli con down "WifiName"
    nmcli con up "WifiName"
  5. Reverting to DHCP (Dynamic IP):
    If you encounter any issues or decide to return to using DHCP, you can reset the configuration as follows:
    nmcli con mod "WifiName" ipv4.method auto
    nmcli con down "WifiName"
    nmcli con up "WifiName"

Configure Nginx as a Reverse Proxy

Modify the Nginx configuration to act as a reverse proxy. Edit the Nginx site configuration file:

sudo vi /etc/nginx/sites-available/default

Update the following server block at the bottom (replace [yourDomain.com] and adjust the [YOUR_APP_PORT] to match your application):

server {
        listen 443 ssl;
#       listen [::]:80;

        server_name [yourDomain.com];
        ssl_certificate /etc/letsencrypt/live/[yourDomain.com]/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/[yourDomain.com]/privkey.pem;
#       root /var/www/example.com;
#        index index.html;

        location / {
#               try_files $uri $uri/ =404;
                proxy_pass http://localhost:[YOUR_APP_PORT];
                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;
        }
}

restart it to apply your changes:

sudo systemctl restart nginx

You should be able to access your web application over HTTPS by visiting https://[yourDomain.com]

Setting a New Static IP Address

Open the dhcpcd configuration file:

sudo vi /etc/dhcpcd.conf

Set the static IP address: At the end of the file, add the following lines, replacing the example network information with your own:

interface eth0
static ip_address=192.168.1.XX/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8

Here, 192.168.1.XX is the new IP address you wish to assign to your server. Ensure this IP address is not already in use within your local network.

sudo sync;sudo /sbin/shutdown -r now

Quick Fixes for WiFi Disconnection on Ubuntu

Method 1: Disable WiFi Power Management

Ubuntu might automatically turn off WiFi to save power. Here’s how to stop that:

  1. Check Your Network Interface Name: Use
    iwconfig
    to find your network interface name (it’s wlan0 for many but can differ).
  2. Turn Off Power Management: Execute
    sudo iwconfig wlan0 power off
    , replacing wlan0 with your actual interface name.

Method 2: Edit NetworkManager Configuration

Prevent automatic disconnections by tweaking NetworkManager:

  1. Open Configuration File: Run
    sudo vi /etc/NetworkManager/NetworkManager.conf.
  2. Add Power Save Setting: Insert the following lines:
    [connection]
    wifi.powersave = 2
  3. Restart NetworkManager: Apply changes with
    sudo systemctl restart NetworkManager.

Encountered “Operation not supported”? If disabling power management directly doesn’t work, try this alternative:

Alternative Method: Use TLP for Advanced Power Management

TLP offers granular control over power settings, including WiFi:

  1. Install TLP: Update your system and install TLP with
    sudo apt update
    followed by
    sudo apt install tlp tlp-rdw.
  2. Start TLP: Activate TLP using
    sudo tlp start.
  3. Edit TLP Configuration: Modify
    /etc/tlp.conf
    to disable WiFi power management. Uncomment (or add) the lines:
    WIFI_PWR_ON_AC=off
    WIFI_PWR_ON_BAT=off
  4. Restart TLP: Make your changes effective with
    sudo tlp start
通过 WordPress.com 设计一个这样的站点
从这里开始