2025-08-05 13:24:21
This commit is contained in:
@@ -48,7 +48,7 @@ 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:9000:localhost:1313 <ip address>
|
||||
autossh -M 0 -f -N -R 0.0.0.0:1313:localhost:1313 <ip address>
|
||||
fi
|
||||
sleep 60
|
||||
done
|
||||
@@ -63,7 +63,7 @@ server {
|
||||
server_name www.<your domain> <your domain>;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:9000;
|
||||
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;
|
||||
@@ -71,6 +71,13 @@ server {
|
||||
}
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
@@ -21,7 +21,7 @@ Still, none of the other options really fit my expectations either. One day, I m
|
||||
diskutil list
|
||||
```
|
||||
|
||||
Solution: HFS+ + SMB3.0, 客户端设置“延迟加载目录”或“按需索引”
|
||||
|
||||
|
||||
```diskutil list```
|
||||
|
||||
|
||||
@@ -13,11 +13,7 @@ brew install git
|
||||
brew install gitea
|
||||
```
|
||||
|
||||
Start the configuration page of Gitea:
|
||||
```
|
||||
gitea web
|
||||
```
|
||||
|
||||
## The database
|
||||
Install MySQL:
|
||||
```
|
||||
brew install mysql
|
||||
@@ -28,6 +24,7 @@ Login MySQL and create the database and user:
|
||||
```
|
||||
mysql -u root
|
||||
```
|
||||
|
||||
Then, execute:
|
||||
```
|
||||
CREATE DATABASE gitea CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
@@ -36,8 +33,23 @@ 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.
|
||||
|
||||
CREATE DATABASE gitea CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'gitea';
|
||||
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
@@ -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`.
|
||||
69
content/en/projects/self_host/mac_mini_m4/05_pdf_shelf.md
Normal file
69
content/en/projects/self_host/mac_mini_m4/05_pdf_shelf.md
Normal 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
|
||||
```
|
||||
40
content/en/projects/self_host/mac_mini_m4/06_photo_server.md
Normal file
40
content/en/projects/self_host/mac_mini_m4/06_photo_server.md
Normal 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`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user