mirror of https://github.com/allinssl/allinssl
修改部署到腾讯云cos,bucket参数获取
parent
4ce8627193
commit
98642c72da
|
@ -111,7 +111,7 @@ func DeployToTX(cfg map[string]any) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("参数错误:region")
|
return fmt.Errorf("参数错误:region")
|
||||||
}
|
}
|
||||||
bucket, ok := cfg["domain"].(string)
|
bucket, ok := cfg["bucket"].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("参数错误:bucket")
|
return fmt.Errorf("参数错误:bucket")
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,9 @@ func init() {
|
||||||
fmt.Fprintf(os.Stderr, "切换目录失败: %v\n", err)
|
fmt.Fprintf(os.Stderr, "切换目录失败: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
os.MkdirAll("data", os.ModePerm)
|
os.MkdirAll("data", os.ModePerm)
|
||||||
|
|
||||||
dbPath := "data/data.db"
|
dbPath := "data/data.db"
|
||||||
_, _ = filepath.Abs(dbPath)
|
_, _ = filepath.Abs(dbPath)
|
||||||
// fmt.Println("数据库路径:", absPath)
|
// fmt.Println("数据库路径:", absPath)
|
||||||
|
@ -187,15 +187,15 @@ func init() {
|
||||||
INSERT INTO access_type (name, type) VALUES ('ssh', 'host');
|
INSERT INTO access_type (name, type) VALUES ('ssh', 'host');
|
||||||
INSERT INTO access_type (name, type) VALUES ('btpanel', 'host');
|
INSERT INTO access_type (name, type) VALUES ('btpanel', 'host');
|
||||||
INSERT INTO access_type (name, type) VALUES ('1panel', 'host');`)
|
INSERT INTO access_type (name, type) VALUES ('1panel', 'host');`)
|
||||||
|
|
||||||
uuidStr := public.GenerateUUID()
|
uuidStr := public.GenerateUUID()
|
||||||
randomStr := public.RandomString(8)
|
randomStr := public.RandomString(8)
|
||||||
|
|
||||||
port, err := public.GetFreePort()
|
port, err := public.GetFreePort()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
port = 20773
|
port = 20773
|
||||||
}
|
}
|
||||||
|
|
||||||
Isql := fmt.Sprintf(
|
Isql := fmt.Sprintf(
|
||||||
`INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ('log_path', 'logs/ALLinSSL.log', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
`INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ('log_path', 'logs/ALLinSSL.log', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
||||||
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ( 'workflow_log_path', 'logs/workflows/', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ( 'workflow_log_path', 'logs/workflows/', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
||||||
|
@ -205,26 +205,26 @@ INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES
|
||||||
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ('session_key', '%s', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ('session_key', '%s', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
||||||
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ('secure', '/%s', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ('secure', '/%s', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
||||||
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ('port', '%d', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);`, uuidStr, uuidStr, randomStr, port)
|
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ('port', '%d', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);`, uuidStr, uuidStr, randomStr, port)
|
||||||
|
|
||||||
insertDefaultData(db, "settings", Isql)
|
insertDefaultData(db, "settings", Isql)
|
||||||
|
|
||||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "cloudflare", "type": "host"}, []string{"name", "type"}, []any{"cloudflare", "host"})
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "cloudflare", "type": "host"}, []string{"name", "type"}, []any{"cloudflare", "host"})
|
||||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "cloudflare", "type": "dns"}, []string{"name", "type"}, []any{"cloudflare", "dns"})
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "cloudflare", "type": "dns"}, []string{"name", "type"}, []any{"cloudflare", "dns"})
|
||||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "huaweicloud", "type": "host"}, []string{"name", "type"}, []any{"huaweicloud", "host"})
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "huaweicloud", "type": "host"}, []string{"name", "type"}, []any{"huaweicloud", "host"})
|
||||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "huaweicloud", "type": "dns"}, []string{"name", "type"}, []any{"huaweicloud", "dns"})
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "huaweicloud", "type": "dns"}, []string{"name", "type"}, []any{"huaweicloud", "dns"})
|
||||||
|
|
||||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "baidu", "type": "host"}, []string{"name", "type"}, []any{"baidu", "host"})
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "baidu", "type": "host"}, []string{"name", "type"}, []any{"baidu", "host"})
|
||||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "baidu", "type": "dns"}, []string{"name", "type"}, []any{"baidu", "dns"})
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "baidu", "type": "dns"}, []string{"name", "type"}, []any{"baidu", "dns"})
|
||||||
|
|
||||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "btwaf", "type": "host"}, []string{"name", "type"}, []any{"btwaf", "host"})
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "btwaf", "type": "host"}, []string{"name", "type"}, []any{"btwaf", "host"})
|
||||||
|
|
||||||
// 雷池
|
// 雷池
|
||||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "safeline", "type": "host"}, []string{"name", "type"}, []any{"safeline", "host"})
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "safeline", "type": "host"}, []string{"name", "type"}, []any{"safeline", "host"})
|
||||||
// 西部数码
|
// 西部数码
|
||||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "westcn", "type": "dns"}, []string{"name", "type"}, []any{"westcn", "dns"})
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "westcn", "type": "dns"}, []string{"name", "type"}, []any{"westcn", "dns"})
|
||||||
// 火山引擎
|
// 火山引擎
|
||||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "volcengine", "type": "dns"}, []string{"name", "type"}, []any{"volcengine", "dns"})
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "volcengine", "type": "dns"}, []string{"name", "type"}, []any{"volcengine", "dns"})
|
||||||
|
|
||||||
err = sqlite_migrate.EnsureDatabaseWithTables(
|
err = sqlite_migrate.EnsureDatabaseWithTables(
|
||||||
"data/site_monitor.db",
|
"data/site_monitor.db",
|
||||||
"data/data.db",
|
"data/data.db",
|
||||||
|
@ -233,7 +233,7 @@ INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("错误:", err)
|
fmt.Println("错误:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
db1, err := sql.Open("sqlite", "data/site_monitor.db")
|
db1, err := sql.Open("sqlite", "data/site_monitor.db")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// fmt.Println("创建数据库失败:", err)
|
// fmt.Println("创建数据库失败:", err)
|
||||||
|
@ -276,7 +276,7 @@ func insertDefaultData(db *sql.DB, table, insertSQL string) {
|
||||||
// fmt.Println("检查数据行数失败:", err)
|
// fmt.Println("检查数据行数失败:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果表为空,则插入默认数据
|
// 如果表为空,则插入默认数据
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
// fmt.Println("表为空,插入默认数据...")
|
// fmt.Println("表为空,插入默认数据...")
|
||||||
|
@ -310,7 +310,7 @@ func InsertIfNotExists(
|
||||||
whereArgs = append(whereArgs, val)
|
whereArgs = append(whereArgs, val)
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 判断是否存在
|
// 2. 判断是否存在
|
||||||
query := fmt.Sprintf("SELECT EXISTS(SELECT 1 FROM %s WHERE %s)", table, whereClause)
|
query := fmt.Sprintf("SELECT EXISTS(SELECT 1 FROM %s WHERE %s)", table, whereClause)
|
||||||
var exists bool
|
var exists bool
|
||||||
|
@ -321,7 +321,7 @@ func InsertIfNotExists(
|
||||||
if exists {
|
if exists {
|
||||||
return nil // 已存在
|
return nil // 已存在
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 构建 INSERT 语句
|
// 3. 构建 INSERT 语句
|
||||||
columnList := ""
|
columnList := ""
|
||||||
placeholderList := ""
|
placeholderList := ""
|
||||||
|
@ -334,11 +334,11 @@ func InsertIfNotExists(
|
||||||
placeholderList += "?"
|
placeholderList += "?"
|
||||||
}
|
}
|
||||||
insertSQL := fmt.Sprintf("INSERT INTO %s (%s) VALUES (%s)", table, columnList, placeholderList)
|
insertSQL := fmt.Sprintf("INSERT INTO %s (%s) VALUES (%s)", table, columnList, placeholderList)
|
||||||
|
|
||||||
_, err = db.Exec(insertSQL, insertValues...)
|
_, err = db.Exec(insertSQL, insertValues...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("insert failed: %w", err)
|
return fmt.Errorf("insert failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue