2025-08-18 20:01:21

This commit is contained in:
swangnice
2025-08-18 20:01:21 +08:00
parent 8a920994bf
commit 7c31f72eea
254 changed files with 29201 additions and 3566 deletions

View File

@@ -0,0 +1,88 @@
+++
title = 'Website Setup'
date = 2024-09-20T04:17:50Z
draft = false
series = ["My First Server in Room"]
series_order = 1
weight = 10
+++
I don't have a public IP, so my solution is SSH tunnel + reverse Proxy on cloud server.
## 🍎Mac Mini Side
As a server, my Mac won't sleep, so change the setting firstly.
```
sudo systemsetup -setcomputersleep Never # never sleep
sudo systemsetup -setdisplaysleep 10 # display will sleep in 10 min
```
Use autossh to avoid timeout:
```
brew install autossh
```
Add the configuration below in `~/.ssh/config` Mac Mini will send package per 30 seconds to keep the connection alive.
```
Host <ip address>
ServerAliveInterval 30
ServerAliveCountMax 5
TCPKeepAlive yes
```
Build the connection:
```
autossh -M 0 -f -N \
-i ~/.ssh/id_ed25519 \
-o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" \
-R 0.0.0.0:9000:localhost:1313 \
root@<ip address>
```
```
autossh -M 0 -f -N -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -R 0.0.0.0:9000:localhost:1313 user@<your.server.com>
```
A watchdog script to try reconnection when the network lost(add to LaunchAgent):
```
#!/bin/bash
while true; do
ping -c 1 <ip address> > /dev/null 2>&1
if [ $? -ne 0 ]; then
pkill -f autossh
autossh -M 0 -f -N -R 0.0.0.0:1313:localhost:1313 <ip address>
fi
sleep 60
done
```
## 💻Server Side
Install and config the Nginx, for me the config file in `/etc/nginx/sites-available`:
```
server {
listen 80;
server_name www.<your domain> <your domain>;
location / {
proxy_pass http://localhost:1313;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
```
Then, link the config file to `sites-enabled`, check and reload the Nginx configuration:
```
ln -s /etc/nginx/sites-available/<your config file> /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
```
To obtain a security certificate, use the certbot:
```
sudo apt update
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d swangnice.cn
```

View File

@@ -0,0 +1,33 @@
+++
title = 'NAS: Network Attachment Storage'
date = 2024-09-20T04:17:50Z
draft = false
series = ["My First Server in Room"]
series_order = 2
weight = 20
+++
## Hardware
I went with the UNITEK 3373BBK for one of my drive enclosures—and honestly, it wasnt the best decision.
The first big letdown? The bandwidth tops out at just 5Gbps. Thats fine for basic tasks, but definitely underwhelming if youre dealing with high-speed storage or large file transfers.
Even worse, it doesnt support S.M.A.R.T passthrough, which makes monitoring drive health a hassle. That was a big deal-breaker for me.
Still, none of the other options really fit my expectations either. One day, I might just go all-in and make my own enclosure—design the PCB, write the firmware, the whole deal. Maybe not today… but someday.
```
diskutil list
```
```diskutil list```
```
sudo smartctl -a /dev/disk2
```
```brew install smartmontools```

View File

@@ -0,0 +1,55 @@
+++
title = 'My Own Code Vault: Gitea on Mac Mini'
date = 2024-09-20T04:17:50Z
draft = false
series = ["My First Server in Room"]
series_order = 3
weight = 30
+++
Install dependence of gitea:
```
brew install git
brew install gitea
```
## The database
Install MySQL:
```
brew install mysql
brew services start mysql
```
Login MySQL and create the database and user:
```
mysql -u root
```
Then, execute:
```
CREATE DATABASE gitea CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'gitea'@'localhost' IDENTIFIED BY '<yourpassword>';
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost';
FLUSH PRIVILEGES;
```
## Config the Gitea
Start the configuration page of Gitea:
```
gitea web
```
After filling all information it required, it will generate a config file, for me, it's in`/opt/homebrew/var/gitea/custom/conf/app.ini`, then you can configure more details in this file. I strongly recommend close the public registration.
🚫outdated -- Use autossh to build the new connection
```
autossh -M 0 -f -N \
-i ~/.ssh/id_ed25519 \
-o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" \
-R 127.0.0.1:3000:localhost:3000 \
-R 127.0.0.1:9000:localhost:1313 \
root@<ip_address>
```
✅ Now I wrote a script to keep the connection alive, it contains some sensitive info like IP and ports, so I will not share it here.

View File

@@ -0,0 +1,67 @@
+++
title = 'MCU Benchmark'
date = 2024-09-20T04:17:50Z
draft = false
series = ["My First Server in Room"]
series_order = 4
weight = 40
+++
{{< gitea server="https://code.swangnice.cn" repo="swangnice/mcu-benchmark" >}}
This is a personal project to benchmark various MCUs (Microcontroller Units) using FastAPI and SQLite for the backend and Vue.js for the frontend. The project allows you to add, list, and compare different MCUs.
You can access the project at [HERE](https://mcubenchmark.swangnice.cn).
```
mcubenchmark/
├── backend/
│ ├── main.py # FastAPI Entrance
│ ├── database.py # SQLite Base operations
│ ├── admin.py # SQLite CURD
│ └── mcu.db
├── frontend/
│ ├── public/
│ ├── src/
│ │ ├── views/
│ │ │ ├── ListView.vue
│ │ │ ├── DetailView.vue
│ │ │ └── CompareView.vue
│ │ ├── App.vue
│ │ └── main.js
├── README.md
└── requirements.txt
```
## How to use?
Clone this repo, and install the requirements:
```bash
cd mcu-benchmark
conda create -n mcu-benchmark
conda activate mcu-benchmark
pip install -r requirements.txt
```
Then, start the backend server:
```bash
cd backend
uvicorn main:app --host 0.0.0.0 --port 3010 --reload
```
Use `admin.py` and follow the instructions to add MCUs to the database:
```
python admin.py
```
Now, you can access the backend API at `http://localhost:3010/api/mcus`.
Run the frontend (before this step, you need to install Node.js, npm and other dependencies):
```bash
cd backend
npm run dev
```
Now, you can access the frontend at `http://localhost:<port>`. The default port of Vite is `5173`.

View File

@@ -0,0 +1,69 @@
+++
title = 'My Own PDF Shelf: pdfding on Mac Mini'
date = 2024-09-20T04:17:50Z
draft = false
series = ["My First Server in Room"]
series_order = 5
weight = 50
+++
PDFding is a self-hosted PDF library management system, which is perfect for managing my personal PDF collection. It allows me to organize, search, and read PDFs directly from my Mac Mini. Later I will list a contents of my PDF library, if you need any of them, just email me. No commercial use, please.
## Install Docker and Prepare Directories
Download [Docker Desktop](https://www.docker.com/products/docker-desktop/), and install it.
```bash
mkdir -p <where you like>/pdfding/{data,media}
chmod a+w <where you like>/pdfding/{data,media}
cd <where you like>/pdfding/
```
data is used to store the database, media is used to store the PDF files.
## Build the Container
```
docker run --name pdfding \
-p <port>:<port> \
-v ./db:/home/nonroot/pdfding/db -v ./media:/home/nonroot/pdfding/media \
-e HOST_NAME=127.0.0.1,<your_domain> -e SECRET_KEY=<you_key> -e CSRF_COOKIE_SECURE=FALSE -e SESSION_COOKIE_SECURE=FALSE \
-d \
mrmn/pdfding:latest
```
Then, you should be able to access the PDFding web interface at `http://localhost:<port>`.
## Create an Account and Disable Registration
If it's your first time using PDFding, you will need to create an account. After that, I strongly recommend disabling the public registration to prevent unauthorized access. You can do this by editing the `/home/nonroot/pdfding/users/views.py` file in the container.
```
docker cp pdfding:/home/nonroot/pdfding/users/views.py ./views.py
```
Then, find a function named `PdfDingSignupView`, change it:
```python
from django.http import HttpResponseForbidden
@method_decorator(login_not_required, name="dispatch")
class PdfDingSignupView(SignupView):
"""
Overwrite allauths signup to be accessed without being logged in
"""
@login_not_required
def dispatch(self, request, *args, **kwargs):
#return super(PdfDingSignupView, self).dispatch(request, *args, **kwargs)
return HttpResponseForbidden("Registration is disabled by the administrator.")
```
Then, copy it back to the container:
```bash
docker cp ./views.py pdfding:/home/nonroot/pdfding/users/views.py
```
Finally, restart the container:
```
docker restart pdfding
```

View File

@@ -0,0 +1,40 @@
+++
title = 'My Own Photo Server: Immich on Mac Mini'
date = 2024-09-20T04:17:50Z
draft = false
series = ["My First Server in Room"]
series_order = 6
weight = 60
+++
Immich is a self-hosted photo and video management solution that allows you to organize, share, and access your media files from anywhere. It provides features like automatic backups, facial recognition, and easy sharing options.
## Installation
Follow the official [Immich installation guide](https://immich.app/docs/overview/quick-start) for detailed instructions. Below is a quick overview of the steps to get started.
```
cd <where you like>
mkdir ./immich-app
cd ./immich-app
wget -O docker-compose.yml https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
wget -O .env https://github.com/immich-app/immich/releases/latest/download/example.env
cp example.env .env
```
Edit the `.env` file to set your desired configuration options, such as database settings and server URLs. Make sure to set the `APP_URL` to your server's URL.
Then, run the following command to start Immich:
```bash
docker compose up -d
```
Then Enjoy!!!
## Quote Photos in Hugo page
1. Share the photo using Immich.
2. Navigate to `Sharing` > `Shared links` and select the tab corresponding to your shared content.
3. Open the web developer tools by pressing `F12`, then click on the photo you wish to quote.
4. In the `Network` tab, locate the request that displays the image preview and copy the URL. This URL should resemble `https://your-immich-domain.cn/api/assets/xxxxxxxxx/thumbnail?key=xxxxxxxxxxx=preview&c=xxxxxxxxx`.

View File

@@ -0,0 +1,13 @@
+++
title = 'My First Server in Room: Mac Mini + SSD Enclosure'
date = 2024-09-20T04:17:50Z
draft = false
tags = ["Public", "Ongoing", "Original", "AI"]
weight = 10
+++
For my first physical server in my life, I got an Mac Mini with M4 and an HDD enclosure.

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB