First commit on Mac Mini server

This commit is contained in:
2025-07-25 02:15:37 +08:00
parent 6f09b5f46f
commit 64eed4e7ce
358 changed files with 67829 additions and 14729 deletions

View File

@@ -0,0 +1,31 @@
+++
title = 'Self-host Projects'
date = 2024-09-20T04:17:50Z
draft = false
weight = 90
+++
Ive recently been exploring the world of self-hosted solutions, and its nothing short of amazing. There are some great collections out there that showcase powerful, privacy-respecting tools you can run on your own hardware:
- [A collection on GitHub](https://github.com/awesome-selfhosted/awesome-selfhosted)
- [selfh.st](https://selfh.st/)
## ❓ Why Self-Host?
I enjoy automating tasks and making my life smarter with scripts and small tools. Having control over the services I use, running them on my own hardware, and customizing everything to suit my needs—its both empowering and educational.
<!-- ## 🧠 My Home Lab Vision
Im currently running some of my own projects on lightweight setups, but I have a bigger plan in mind: a dedicated, used physical server. That will take more time and energy to set up properly, so Ive decided to gamify the process. -->
<!-- 🎯 Goal: Once Ive built 10 great and interesting projects, with at least 3 generating income, Ill reward myself by setting up a real home lab server.
Projects:
🟩⬜⬜⬜⬜⬜⬜⬜⬜⬜ (1/10)
Income Goals:
⬜⬜⬜ (0/3) -->
Ill use this space to document the projects I build and share what I learn along the way.
## List

Binary file not shown.

After

Width:  |  Height:  |  Size: 967 KiB

View File

@@ -0,0 +1,81 @@
+++
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:9000: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:9000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
```
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
```
Solution: HFS+ + SMB3.0 客户端设置“延迟加载目录”或“按需索引”
```diskutil list```
```
sudo smartctl -a /dev/disk2
```
```brew install smartmontools```

View File

@@ -0,0 +1,43 @@
+++
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
```
Start the configuration page of Gitea:
```
gitea web
```
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;
```
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;

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

View File

@@ -0,0 +1,15 @@
+++
title = 'TODO List'
date = 2024-09-20T04:17:50Z
draft = false
series = ["StockBot"]
series_order = 1
weight = 10
+++
## Short-term TODO
- 🚧 The Initial Policy implement (Parameterizing transaction variables)
- ⬜️ The evaluate & logger script
- ⬜ The automatic scripts with Email Sender deployed on the Server
- ⬜ Web UI, will not be too complex just a simple one to synchronous my account for customized policy
- ⬜️ Implement RL algorithms

View File

@@ -0,0 +1,10 @@
+++
title = 'Showcases'
date = 2024-09-20T04:17:50Z
draft = false
series = ["StockBot"]
series_order = 2
weight = 20
+++
This section will feature occasional showcases of my technical achievements—focused purely on the engineering side, not the income.

View File

@@ -0,0 +1,20 @@
+++
title = 'StockBot'
date = 2024-09-20T04:17:50Z
draft = false
tags = ["Private", "Ongoing", "Original", "AI"]
weight = 10
+++
This is a bot that assists in making daily index fund trading decisions.
## Introduction
This project was inspired by my mother. Over the course of ten years, she watched my father struggle in the stock market. From those hard lessons, she developed her own strategy—one that focuses on the predictable fluctuations in index fund values. Armed with nothing more than paper, a pen, and a calculator, shes been able to achieve steady profits.
I believe theres even more potential here.
By digitizing her process and gradually introducing quantifiable algorithms, I hope to both increase efficiency and explore new edges for profitability. My strategy might cause others' losses, so this project is private permanently.
## List
Here, Ill keep track of the to-do list and showcase the results as the project evolves. Ill also highlight some interesting technical insights along the way.

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB