Skip to content

Commit a9c5dc8

Browse files
committed
feat(install): 新增一键安装和卸载脚本
1 parent c3b22e3 commit a9c5dc8

4 files changed

Lines changed: 426 additions & 103 deletions

File tree

.gitignore

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
# If you prefer the allow list template instead of the deny list, see community template:
2-
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3-
#
4-
# Binaries for programs and plugins
1+
# Go build artifacts
52
*.exe
63
*.exe~
74
*.dll
85
*.so
96
*.dylib
10-
11-
# Test binary, built with `go test -c`
127
*.test
138

14-
# Code coverage profiles and other test artifacts
9+
# Coverage and profiling outputs
1510
*.out
1611
coverage.*
1712
*.coverprofile
1813
profile.cov
1914

20-
# Dependency directories (remove the comment below to include it)
21-
# vendor/
22-
23-
# Go workspace file
15+
# Local Go workspace files
2416
go.work
2517
go.work.sum
2618

27-
# env file
28-
.env
19+
# Dependency directories
20+
# vendor/
2921

30-
# Editor/IDE
22+
# Local environment and editor files
23+
.env
24+
.DS_Store
3125
# .idea/
3226
# .vscode/
3327

34-
.claude
35-
bin
36-
anssl
37-
certs
38-
ssl
39-
install.sh
40-
config.yaml
41-
anssl.log
42-
release.sh
43-
.DS_Store
44-
CLAUDE.md
45-
cert-deploy
46-
AGENTS.md
47-
goal
28+
# Build and runtime outputs
29+
/bin/
30+
/anssl
31+
/cert-deploy
32+
/anssl.log
33+
34+
# Local runtime data
35+
/certs/
36+
/ssl/
37+
38+
# Local configuration and helper scripts
39+
/config.yaml
40+
/install.sh
41+
/release.sh
42+
43+
# Local planning and assistant files
44+
/goal/
45+
/.claude/
46+
/AGENTS.md
47+
/CLAUDE.md

README.md

Lines changed: 61 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,37 @@
1616

1717
### 1. 安装
1818

19-
[GitHub Releases](https://github.com/https-cert/deploy/releases) 下载适合你系统的版本
19+
Linux/macOS 推荐使用一键安装脚本,默认安装 [GitHub Releases](https://github.com/https-cert/deploy/releases) 最新版本
2020

2121
```bash
22-
# Linux
23-
wget https://github.com/https-cert/deploy/releases/latest/download/anssl-linux-amd64.tar.gz
24-
tar -xzf anssl-linux-amd64.tar.gz
25-
chmod +x anssl
26-
sudo mv anssl /usr/local/bin/
22+
curl -fsSL https://raw.githubusercontent.com/https-cert/deploy/main/scripts/install.sh | sh
23+
```
24+
25+
国内服务器可使用 GitHub 代理加速下载:
26+
27+
```bash
28+
curl -fsSL https://ghproxy.net/https://raw.githubusercontent.com/https-cert/deploy/main/scripts/install.sh | MIRROR=ghproxy sh
29+
```
30+
31+
如需固定版本或修改安装目录:
32+
33+
```bash
34+
curl -fsSL https://raw.githubusercontent.com/https-cert/deploy/main/scripts/install.sh | VERSION=v0.6.0 APP_DIR=/opt/anssl sh
35+
```
36+
37+
默认安装到 `/opt/anssl`,并创建 `/usr/local/bin/anssl` 软链接。如需卸载:
38+
39+
```bash
40+
# 卸载程序,保留配置
41+
curl -fsSL https://raw.githubusercontent.com/https-cert/deploy/main/scripts/install.sh | sh -s -- --uninstall
42+
43+
# 卸载程序并删除配置
44+
curl -fsSL https://raw.githubusercontent.com/https-cert/deploy/main/scripts/install.sh | sh -s -- --uninstall --purge
2745
```
2846

2947
### 2. 配置
3048

31-
发布包中已包含 `config.yaml` 模板。首次安装时直接编辑解压出来的 `config.yaml`,修改其中的 `accessKey` 和需要启用的部署目标。
49+
安装脚本会把发布包中的 `config.yaml` 模板复制到 `/opt/anssl/config.yaml`,如果配置文件已存在则不会覆盖。首次安装后直接编辑该文件,修改其中的 `accessKey` 和需要启用的部署目标。
3250

3351
后续更新时只替换 `anssl` 可执行文件即可,避免手动解压覆盖已有的 `config.yaml`
3452

@@ -86,22 +104,13 @@ provider:
86104
secretKey: "your-tencent-secret-key"
87105
```
88106
89-
> #### 已支持的云服务商
90-
>
91-
> | 服务商 | name 值 | 认证字段 |
92-
> | :----: | :------------: | :--------------------------: |
107+
#### 已支持的云服务商
108+
109+
> | 服务商 | name 值 | 认证字段 |
110+
> | :----: | :------------: | :------------------------------------------------: |
93111
> | 阿里云 | `aliyun` | accessKeyId, accessKeySecret(ESA可选:esaSiteId) |
94-
> | 七牛云 | `qiniu` | accessKey, accessSecret |
95-
> | 腾讯云 | `cloudTencent` | secretId, secretKey |
96-
97-
> #### 阿里云 CAS/ESA 业务分离(无自动识别)
98-
>
99-
> - 选择“阿里云-CAS 上传证书”业务:调用 CAS `UploadUserCertificate`
100-
> - 选择“阿里云-ESA 上传证书”业务:调用 ESA `SetCertificate`(需要 `esaSiteId`)
101-
>
102-
> #### 腾讯云上传证书
103-
>
104-
> - 选择“腾讯云-上传证书”业务:通过腾讯云官方 Go SDK 调用 SSL `UploadCertificate`(`ssl.tencentcloudapi.com`, `2019-12-05`)
112+
> | 七牛云 | `qiniu` | accessKey, accessSecret |
113+
> | 腾讯云 | `cloudTencent` | secretId, secretKey |
105114

106115
### 3. 配置 Nginx
107116

@@ -125,13 +134,13 @@ sudo nginx -t && sudo nginx -s reload
125134

126135
```bash
127136
# 启动守护进程
128-
sudo ./anssl daemon -c config.yaml
137+
sudo anssl daemon -c /opt/anssl/config.yaml
129138
130139
# 查看状态
131-
./anssl status
140+
anssl status
132141
133142
# 查看日志
134-
./anssl log -f
143+
anssl log -f
135144
```
136145

137146
## HTTP-01 验证工作流程
@@ -149,36 +158,36 @@ sudo ./anssl daemon -c config.yaml
149158

150159
```bash
151160
# 守护进程管理
152-
./anssl daemon -c config.yaml # 启动守护进程
153-
./anssl status # 查看状态
154-
./anssl stop # 停止
155-
./anssl restart -c config.yaml # 重启
161+
anssl daemon -c /opt/anssl/config.yaml # 启动守护进程
162+
anssl status # 查看状态
163+
anssl stop # 停止
164+
anssl restart -c /opt/anssl/config.yaml # 重启
156165
157166
# 日志查看
158-
./anssl log # 查看日志
159-
./anssl log -f # 实时跟踪
167+
anssl log # 查看日志
168+
anssl log -f # 实时跟踪
160169
161170
# 更新
162-
./anssl check-update # 检查更新
163-
./anssl update # 执行更新
171+
anssl check-update # 检查更新
172+
anssl update # 执行更新
164173
```
165174

166175
## 配置说明
167176

168-
| 配置项 | 必填 | 说明 |
169-
| ---------------------- | ---- | -------------------------------------------- |
170-
| `server.accessKey` | ✅ | 从 anssl.cn 获取的访问密钥 |
171-
| `server.port` | ❌ | HTTP-01 验证端口,默认 19000 |
172-
| `ssl.nginxPath` | ❌ | Nginx 证书目录,配置后自动部署并重载 Nginx |
173-
| `ssl.apachePath` | ❌ | Apache 证书目录,配置后自动部署并重载 Apache |
174-
| `ssl.rustFSPath` | ❌ | RustFS TLS 证书目录,配置后自动部署证书 |
175-
| `ssl.feiNiuEnabled` | ❌ | 飞牛 OS 证书部署开关,默认 false |
176-
| `ssl.onePanel.url` | ❌ | 1Panel 面板地址(如 http://localhost:10000) |
177-
| `ssl.onePanel.apiKey` | ❌ | 1Panel API 密钥,在面板设置中生成 |
178-
| `log.maxSizeMB` | ❌ | 单个日志文件最大体积,默认 20 MB |
179-
| `log.maxBackups` | ❌ | 最多保留的轮转日志数量,默认 5 |
180-
| `log.maxAgeDays` | ❌ | 轮转日志最长保留天数,默认 30 |
181-
| `provider` | ❌ | 云服务配置(阿里云/七牛云/腾讯云) |
177+
| 配置项 | 必填 | 说明 |
178+
| --------------------- | ---- | -------------------------------------------- |
179+
| `server.accessKey` | ✅ | 从 anssl.cn 获取的访问密钥 |
180+
| `server.port` | ❌ | HTTP-01 验证端口,默认 19000 |
181+
| `ssl.nginxPath` | ❌ | Nginx 证书目录,配置后自动部署并重载 Nginx |
182+
| `ssl.apachePath` | ❌ | Apache 证书目录,配置后自动部署并重载 Apache |
183+
| `ssl.rustFSPath` | ❌ | RustFS TLS 证书目录,配置后自动部署证书 |
184+
| `ssl.feiNiuEnabled` | ❌ | 飞牛 OS 证书部署开关,默认 false |
185+
| `ssl.onePanel.url` | ❌ | 1Panel 面板地址(如 http://localhost:10000) |
186+
| `ssl.onePanel.apiKey` | ❌ | 1Panel API 密钥,在面板设置中生成 |
187+
| `log.maxSizeMB` | ❌ | 单个日志文件最大体积,默认 20 MB |
188+
| `log.maxBackups` | ❌ | 最多保留的轮转日志数量,默认 5 |
189+
| `log.maxAgeDays` | ❌ | 轮转日志最长保留天数,默认 30 |
190+
| `provider` | ❌ | 云服务配置(阿里云/七牛云/腾讯云) |
182191

183192
## 故障排除
184193

@@ -196,18 +205,18 @@ lsof -i :19000
196205
curl http://localhost:19000/acme-challenge/test-token
197206
198207
# 4. 查看日志
199-
./anssl log -f
208+
anssl log -f
200209
```
201210

202211
### 权限错误
203212

204213
```bash
205214
# 方式 1:使用 sudo
206-
sudo ./anssl daemon -c config.yaml
215+
sudo anssl daemon -c /opt/anssl/config.yaml
207216
208217
# 方式 2:配置用户目录
209-
# 修改 config.yaml: ssl.path: "$HOME/nginx/ssl"
210-
./anssl daemon -c config.yaml
218+
# 修改 /opt/anssl/config.yaml: ssl.path: "$HOME/nginx/ssl"
219+
anssl daemon -c /opt/anssl/config.yaml
211220
```
212221

213222
### 开机自启动(systemd)
@@ -221,7 +230,7 @@ After=network.target
221230
[Service]
222231
Type=simple
223232
User=root
224-
ExecStart=/usr/local/bin/anssl start -c /etc/anssl/config.yaml
233+
ExecStart=/usr/local/bin/anssl start -c /opt/anssl/config.yaml
225234
Restart=always
226235
RestartSec=10
227236

README_EN.md

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,37 @@ An automated SSL certificate deployment tool for downloading certificates from [
1616

1717
### 1. Install
1818

19-
Download the binary for your OS from [GitHub Releases](https://github.com/https-cert/deploy/releases):
19+
For Linux/macOS, use the install script. It installs the latest version from [GitHub Releases](https://github.com/https-cert/deploy/releases) by default:
2020

2121
```bash
22-
# Linux
23-
wget https://github.com/https-cert/deploy/releases/latest/download/anssl-linux-amd64.tar.gz
24-
tar -xzf anssl-linux-amd64.tar.gz
25-
chmod +x anssl
26-
sudo mv anssl /usr/local/bin/
22+
curl -fsSL https://raw.githubusercontent.com/https-cert/deploy/main/scripts/install.sh | sh
23+
```
24+
25+
For servers with slow GitHub access, use a GitHub proxy:
26+
27+
```bash
28+
curl -fsSL https://ghproxy.net/https://raw.githubusercontent.com/https-cert/deploy/main/scripts/install.sh | MIRROR=ghproxy sh
29+
```
30+
31+
To pin a version or customize paths:
32+
33+
```bash
34+
curl -fsSL https://raw.githubusercontent.com/https-cert/deploy/main/scripts/install.sh | VERSION=v0.6.0 APP_DIR=/opt/anssl sh
35+
```
36+
37+
By default, anssl is installed into `/opt/anssl` and linked as `/usr/local/bin/anssl`. To uninstall:
38+
39+
```bash
40+
# Remove the binary and keep config
41+
curl -fsSL https://raw.githubusercontent.com/https-cert/deploy/main/scripts/install.sh | sh -s -- --uninstall
42+
43+
# Remove the binary and config
44+
curl -fsSL https://raw.githubusercontent.com/https-cert/deploy/main/scripts/install.sh | sh -s -- --uninstall --purge
2745
```
2846

2947
### 2. Configure
3048

31-
Release archives include a `config.yaml` template. On first install, edit the extracted `config.yaml` and set its `accessKey` and any deployment targets you want to enable.
49+
The install script copies the packaged `config.yaml` template to `/opt/anssl/config.yaml` and never overwrites an existing config file. On first install, edit that file and set its `accessKey` and any deployment targets you want to enable.
3250

3351
For later updates, replace only the `anssl` executable to avoid overwriting an existing `config.yaml`.
3452

@@ -125,13 +143,13 @@ sudo nginx -t && sudo nginx -s reload
125143

126144
```bash
127145
# Start daemon
128-
sudo ./anssl daemon -c config.yaml
146+
sudo anssl daemon -c /opt/anssl/config.yaml
129147
130148
# Check status
131-
./anssl status
149+
anssl status
132150
133151
# View logs
134-
./anssl log -f
152+
anssl log -f
135153
```
136154

137155
## HTTP-01 Validation Flow
@@ -149,18 +167,18 @@ sudo ./anssl daemon -c config.yaml
149167

150168
```bash
151169
# Daemon management
152-
./anssl daemon -c config.yaml # Start daemon
153-
./anssl status # Check status
154-
./anssl stop # Stop
155-
./anssl restart -c config.yaml # Restart
170+
anssl daemon -c /opt/anssl/config.yaml # Start daemon
171+
anssl status # Check status
172+
anssl stop # Stop
173+
anssl restart -c /opt/anssl/config.yaml # Restart
156174
157175
# Logs
158-
./anssl log # View logs
159-
./anssl log -f # Follow logs
176+
anssl log # View logs
177+
anssl log -f # Follow logs
160178
161179
# Update
162-
./anssl check-update # Check updates
163-
./anssl update # Run update
180+
anssl check-update # Check updates
181+
anssl update # Run update
164182
```
165183

166184
## Configuration Reference
@@ -196,18 +214,18 @@ lsof -i :19000
196214
curl http://localhost:19000/acme-challenge/test-token
197215
198216
# 4. Check logs
199-
./anssl log -f
217+
anssl log -f
200218
```
201219

202220
### Permission errors
203221

204222
```bash
205223
# Option 1: Use sudo
206-
sudo ./anssl daemon -c config.yaml
224+
sudo anssl daemon -c /opt/anssl/config.yaml
207225
208226
# Option 2: Use user-owned directories
209-
# Update config.yaml: ssl.path: "$HOME/nginx/ssl"
210-
./anssl daemon -c config.yaml
227+
# Update /opt/anssl/config.yaml: ssl.path: "$HOME/nginx/ssl"
228+
anssl daemon -c /opt/anssl/config.yaml
211229
```
212230

213231
### Auto-start on boot (systemd)
@@ -221,7 +239,7 @@ After=network.target
221239
[Service]
222240
Type=simple
223241
User=root
224-
ExecStart=/usr/local/bin/anssl start -c /etc/anssl/config.yaml
242+
ExecStart=/usr/local/bin/anssl start -c /opt/anssl/config.yaml
225243
Restart=always
226244
RestartSec=10
227245

0 commit comments

Comments
 (0)