mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 07:57:21 +08:00
chore: 框架更新的其他调整和更新 PHP 版本号
This commit is contained in:
@@ -25,19 +25,17 @@ func Error(ctx http.Context, code int, message any) http.Response {
|
||||
}
|
||||
|
||||
// Check 检查插件是否可用
|
||||
func Check(ctx http.Context, slug string) bool {
|
||||
func Check(ctx http.Context, slug string) http.Response {
|
||||
plugin := services.NewPluginImpl().GetBySlug(slug)
|
||||
installedPlugin := services.NewPluginImpl().GetInstalledBySlug(slug)
|
||||
installedPlugins, err := services.NewPluginImpl().AllInstalled()
|
||||
if err != nil {
|
||||
facades.Log().Error("[面板][插件] 获取已安装插件失败")
|
||||
Error(ctx, http.StatusInternalServerError, "系统内部错误")
|
||||
return false
|
||||
return Error(ctx, http.StatusInternalServerError, "系统内部错误")
|
||||
}
|
||||
|
||||
if installedPlugin.Version != plugin.Version || installedPlugin.Slug != plugin.Slug {
|
||||
Error(ctx, http.StatusForbidden, "插件 "+slug+" 需要更新至 "+plugin.Version+" 版本")
|
||||
return false
|
||||
return Error(ctx, http.StatusForbidden, "插件 "+slug+" 需要更新至 "+plugin.Version+" 版本")
|
||||
}
|
||||
|
||||
var lock sync.RWMutex
|
||||
@@ -54,8 +52,7 @@ func Check(ctx http.Context, slug string) bool {
|
||||
_, requireFound := pluginsMap[require]
|
||||
lock.RUnlock()
|
||||
if !requireFound {
|
||||
Error(ctx, http.StatusForbidden, "插件 "+slug+" 需要依赖 "+require+" 插件")
|
||||
return false
|
||||
return Error(ctx, http.StatusForbidden, "插件 "+slug+" 需要依赖 "+require+" 插件")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,10 +61,9 @@ func Check(ctx http.Context, slug string) bool {
|
||||
_, excludeFound := pluginsMap[exclude]
|
||||
lock.RUnlock()
|
||||
if excludeFound {
|
||||
Error(ctx, http.StatusForbidden, "插件 "+slug+" 不兼容 "+exclude+" 插件")
|
||||
return false
|
||||
return Error(ctx, http.StatusForbidden, "插件 "+slug+" 不兼容 "+exclude+" 插件")
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -35,8 +35,9 @@ type Jail struct {
|
||||
|
||||
// Status 获取运行状态
|
||||
func (c *Fail2banController) Status(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "fail2ban") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "fail2ban")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status fail2ban | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -53,8 +54,9 @@ func (c *Fail2banController) Status(ctx http.Context) http.Response {
|
||||
|
||||
// Reload 重载配置
|
||||
func (c *Fail2banController) Reload(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "fail2ban") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "fail2ban")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl reload fail2ban")
|
||||
@@ -72,8 +74,9 @@ func (c *Fail2banController) Reload(ctx http.Context) http.Response {
|
||||
|
||||
// Restart 重启服务
|
||||
func (c *Fail2banController) Restart(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "fail2ban") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "fail2ban")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl restart fail2ban")
|
||||
@@ -91,8 +94,9 @@ func (c *Fail2banController) Restart(ctx http.Context) http.Response {
|
||||
|
||||
// Start 启动服务
|
||||
func (c *Fail2banController) Start(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "fail2ban") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "fail2ban")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl start fail2ban")
|
||||
@@ -110,8 +114,9 @@ func (c *Fail2banController) Start(ctx http.Context) http.Response {
|
||||
|
||||
// Stop 停止服务
|
||||
func (c *Fail2banController) Stop(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "fail2ban") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "fail2ban")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl stop fail2ban")
|
||||
@@ -129,8 +134,9 @@ func (c *Fail2banController) Stop(ctx http.Context) http.Response {
|
||||
|
||||
// List 所有 Fail2ban 规则
|
||||
func (c *Fail2banController) List(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "fail2ban") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "fail2ban")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
page := ctx.Request().QueryInt("page", 1)
|
||||
@@ -193,8 +199,9 @@ func (c *Fail2banController) List(ctx http.Context) http.Response {
|
||||
|
||||
// Add 添加 Fail2ban 规则
|
||||
func (c *Fail2banController) Add(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "fail2ban") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "fail2ban")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -329,8 +336,9 @@ logpath = ` + logPath + `
|
||||
|
||||
// Delete 删除规则
|
||||
func (c *Fail2banController) Delete(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "fail2ban") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "fail2ban")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
jailName := ctx.Request().Input("name")
|
||||
@@ -350,8 +358,9 @@ func (c *Fail2banController) Delete(ctx http.Context) http.Response {
|
||||
|
||||
// BanList 获取封禁列表
|
||||
func (c *Fail2banController) BanList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "fail2ban") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "fail2ban")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
name := ctx.Request().Query("name")
|
||||
@@ -383,8 +392,9 @@ func (c *Fail2banController) BanList(ctx http.Context) http.Response {
|
||||
|
||||
// Unban 解封
|
||||
func (c *Fail2banController) Unban(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "fail2ban") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "fail2ban")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
name := ctx.Request().Input("name")
|
||||
@@ -399,8 +409,9 @@ func (c *Fail2banController) Unban(ctx http.Context) http.Response {
|
||||
|
||||
// SetWhiteList 设置白名单
|
||||
func (c *Fail2banController) SetWhiteList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "fail2ban") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "fail2ban")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
ip := ctx.Request().Input("ip")
|
||||
@@ -424,8 +435,9 @@ func (c *Fail2banController) SetWhiteList(ctx http.Context) http.Response {
|
||||
|
||||
// GetWhiteList 获取白名单
|
||||
func (c *Fail2banController) GetWhiteList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "fail2ban") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "fail2ban")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
raw := tools.Read("/etc/fail2ban/jail.local")
|
||||
|
||||
@@ -30,8 +30,9 @@ func NewMysql57Controller() *Mysql57Controller {
|
||||
|
||||
// Status 获取运行状态
|
||||
func (c *Mysql57Controller) Status(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status mysqld | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -48,8 +49,9 @@ func (c *Mysql57Controller) Status(ctx http.Context) http.Response {
|
||||
|
||||
// Reload 重载配置
|
||||
func (c *Mysql57Controller) Reload(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl reload mysqld")
|
||||
@@ -67,8 +69,9 @@ func (c *Mysql57Controller) Reload(ctx http.Context) http.Response {
|
||||
|
||||
// Restart 重启服务
|
||||
func (c *Mysql57Controller) Restart(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl restart mysqld")
|
||||
@@ -86,8 +89,9 @@ func (c *Mysql57Controller) Restart(ctx http.Context) http.Response {
|
||||
|
||||
// Start 启动服务
|
||||
func (c *Mysql57Controller) Start(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl start mysqld")
|
||||
@@ -105,8 +109,9 @@ func (c *Mysql57Controller) Start(ctx http.Context) http.Response {
|
||||
|
||||
// Stop 停止服务
|
||||
func (c *Mysql57Controller) Stop(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl stop mysqld")
|
||||
@@ -124,8 +129,9 @@ func (c *Mysql57Controller) Stop(ctx http.Context) http.Response {
|
||||
|
||||
// GetConfig 获取配置
|
||||
func (c *Mysql57Controller) GetConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
// 获取配置
|
||||
@@ -139,8 +145,9 @@ func (c *Mysql57Controller) GetConfig(ctx http.Context) http.Response {
|
||||
|
||||
// SaveConfig 保存配置
|
||||
func (c *Mysql57Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := ctx.Request().Input("config")
|
||||
@@ -157,8 +164,9 @@ func (c *Mysql57Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
|
||||
// Load 获取负载
|
||||
func (c *Mysql57Controller) Load(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
rootPassword := c.setting.Get(models.SettingKeyMysqlRootPassword)
|
||||
@@ -231,8 +239,9 @@ func (c *Mysql57Controller) Load(ctx http.Context) http.Response {
|
||||
|
||||
// ErrorLog 获取错误日志
|
||||
func (c *Mysql57Controller) ErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Escape(tools.Exec("tail -n 100 /www/server/mysql/mysql-error.log"))
|
||||
@@ -241,8 +250,9 @@ func (c *Mysql57Controller) ErrorLog(ctx http.Context) http.Response {
|
||||
|
||||
// ClearErrorLog 清空错误日志
|
||||
func (c *Mysql57Controller) ClearErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/server/mysql/mysql-error.log")
|
||||
@@ -251,8 +261,9 @@ func (c *Mysql57Controller) ClearErrorLog(ctx http.Context) http.Response {
|
||||
|
||||
// SlowLog 获取慢查询日志
|
||||
func (c *Mysql57Controller) SlowLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Escape(tools.Exec("tail -n 100 /www/server/mysql/mysql-slow.log"))
|
||||
@@ -261,8 +272,9 @@ func (c *Mysql57Controller) SlowLog(ctx http.Context) http.Response {
|
||||
|
||||
// ClearSlowLog 清空慢查询日志
|
||||
func (c *Mysql57Controller) ClearSlowLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/server/mysql/mysql-slow.log")
|
||||
@@ -271,8 +283,9 @@ func (c *Mysql57Controller) ClearSlowLog(ctx http.Context) http.Response {
|
||||
|
||||
// GetRootPassword 获取root密码
|
||||
func (c *Mysql57Controller) GetRootPassword(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
rootPassword := c.setting.Get(models.SettingKeyMysqlRootPassword)
|
||||
@@ -285,8 +298,9 @@ func (c *Mysql57Controller) GetRootPassword(ctx http.Context) http.Response {
|
||||
|
||||
// SetRootPassword 设置root密码
|
||||
func (c *Mysql57Controller) SetRootPassword(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status mysqld | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -319,8 +333,9 @@ func (c *Mysql57Controller) SetRootPassword(ctx http.Context) http.Response {
|
||||
|
||||
// DatabaseList 获取数据库列表
|
||||
func (c *Mysql57Controller) DatabaseList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
rootPassword := c.setting.Get(models.SettingKeyMysqlRootPassword)
|
||||
@@ -381,8 +396,9 @@ func (c *Mysql57Controller) DatabaseList(ctx http.Context) http.Response {
|
||||
|
||||
// AddDatabase 添加数据库
|
||||
func (c *Mysql57Controller) AddDatabase(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -412,8 +428,9 @@ func (c *Mysql57Controller) AddDatabase(ctx http.Context) http.Response {
|
||||
|
||||
// DeleteDatabase 删除数据库
|
||||
func (c *Mysql57Controller) DeleteDatabase(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -435,8 +452,9 @@ func (c *Mysql57Controller) DeleteDatabase(ctx http.Context) http.Response {
|
||||
|
||||
// BackupList 获取备份列表
|
||||
func (c *Mysql57Controller) BackupList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
backupList, err := c.backup.MysqlList()
|
||||
@@ -450,8 +468,9 @@ func (c *Mysql57Controller) BackupList(ctx http.Context) http.Response {
|
||||
|
||||
// UploadBackup 上传备份
|
||||
func (c *Mysql57Controller) UploadBackup(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
file, err := ctx.Request().File("file")
|
||||
@@ -475,8 +494,9 @@ func (c *Mysql57Controller) UploadBackup(ctx http.Context) http.Response {
|
||||
|
||||
// CreateBackup 创建备份
|
||||
func (c *Mysql57Controller) CreateBackup(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -501,8 +521,9 @@ func (c *Mysql57Controller) CreateBackup(ctx http.Context) http.Response {
|
||||
|
||||
// DeleteBackup 删除备份
|
||||
func (c *Mysql57Controller) DeleteBackup(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -524,8 +545,9 @@ func (c *Mysql57Controller) DeleteBackup(ctx http.Context) http.Response {
|
||||
|
||||
// RestoreBackup 还原备份
|
||||
func (c *Mysql57Controller) RestoreBackup(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -550,8 +572,9 @@ func (c *Mysql57Controller) RestoreBackup(ctx http.Context) http.Response {
|
||||
|
||||
// UserList 用户列表
|
||||
func (c *Mysql57Controller) UserList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
type user struct {
|
||||
@@ -635,8 +658,9 @@ func (c *Mysql57Controller) UserList(ctx http.Context) http.Response {
|
||||
|
||||
// AddUser 添加用户
|
||||
func (c *Mysql57Controller) AddUser(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -664,8 +688,9 @@ func (c *Mysql57Controller) AddUser(ctx http.Context) http.Response {
|
||||
|
||||
// DeleteUser 删除用户
|
||||
func (c *Mysql57Controller) DeleteUser(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -687,8 +712,9 @@ func (c *Mysql57Controller) DeleteUser(ctx http.Context) http.Response {
|
||||
|
||||
// SetUserPassword 设置用户密码
|
||||
func (c *Mysql57Controller) SetUserPassword(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -713,8 +739,9 @@ func (c *Mysql57Controller) SetUserPassword(ctx http.Context) http.Response {
|
||||
|
||||
// SetUserPrivileges 设置用户权限
|
||||
func (c *Mysql57Controller) SetUserPrivileges(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql57") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql57")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
|
||||
@@ -30,8 +30,9 @@ func NewMysql80Controller() *Mysql80Controller {
|
||||
|
||||
// Status 获取运行状态
|
||||
func (c *Mysql80Controller) Status(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status mysqld | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -48,8 +49,9 @@ func (c *Mysql80Controller) Status(ctx http.Context) http.Response {
|
||||
|
||||
// Reload 重载配置
|
||||
func (c *Mysql80Controller) Reload(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl reload mysqld")
|
||||
@@ -67,8 +69,9 @@ func (c *Mysql80Controller) Reload(ctx http.Context) http.Response {
|
||||
|
||||
// Restart 重启服务
|
||||
func (c *Mysql80Controller) Restart(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl restart mysqld")
|
||||
@@ -86,8 +89,9 @@ func (c *Mysql80Controller) Restart(ctx http.Context) http.Response {
|
||||
|
||||
// Start 启动服务
|
||||
func (c *Mysql80Controller) Start(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl start mysqld")
|
||||
@@ -105,8 +109,9 @@ func (c *Mysql80Controller) Start(ctx http.Context) http.Response {
|
||||
|
||||
// Stop 停止服务
|
||||
func (c *Mysql80Controller) Stop(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl stop mysqld")
|
||||
@@ -124,8 +129,9 @@ func (c *Mysql80Controller) Stop(ctx http.Context) http.Response {
|
||||
|
||||
// GetConfig 获取配置
|
||||
func (c *Mysql80Controller) GetConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
// 获取配置
|
||||
@@ -139,8 +145,9 @@ func (c *Mysql80Controller) GetConfig(ctx http.Context) http.Response {
|
||||
|
||||
// SaveConfig 保存配置
|
||||
func (c *Mysql80Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := ctx.Request().Input("config")
|
||||
@@ -157,8 +164,9 @@ func (c *Mysql80Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
|
||||
// Load 获取负载
|
||||
func (c *Mysql80Controller) Load(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
rootPassword := c.setting.Get(models.SettingKeyMysqlRootPassword)
|
||||
@@ -231,8 +239,9 @@ func (c *Mysql80Controller) Load(ctx http.Context) http.Response {
|
||||
|
||||
// ErrorLog 获取错误日志
|
||||
func (c *Mysql80Controller) ErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Escape(tools.Exec("tail -n 100 /www/server/mysql/mysql-error.log"))
|
||||
@@ -241,8 +250,9 @@ func (c *Mysql80Controller) ErrorLog(ctx http.Context) http.Response {
|
||||
|
||||
// ClearErrorLog 清空错误日志
|
||||
func (c *Mysql80Controller) ClearErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/server/mysql/mysql-error.log")
|
||||
@@ -251,8 +261,9 @@ func (c *Mysql80Controller) ClearErrorLog(ctx http.Context) http.Response {
|
||||
|
||||
// SlowLog 获取慢查询日志
|
||||
func (c *Mysql80Controller) SlowLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Escape(tools.Exec("tail -n 100 /www/server/mysql/mysql-slow.log"))
|
||||
@@ -261,8 +272,9 @@ func (c *Mysql80Controller) SlowLog(ctx http.Context) http.Response {
|
||||
|
||||
// ClearSlowLog 清空慢查询日志
|
||||
func (c *Mysql80Controller) ClearSlowLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/server/mysql/mysql-slow.log")
|
||||
@@ -271,8 +283,9 @@ func (c *Mysql80Controller) ClearSlowLog(ctx http.Context) http.Response {
|
||||
|
||||
// GetRootPassword 获取root密码
|
||||
func (c *Mysql80Controller) GetRootPassword(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
rootPassword := c.setting.Get(models.SettingKeyMysqlRootPassword)
|
||||
@@ -285,8 +298,9 @@ func (c *Mysql80Controller) GetRootPassword(ctx http.Context) http.Response {
|
||||
|
||||
// SetRootPassword 设置root密码
|
||||
func (c *Mysql80Controller) SetRootPassword(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status mysqld | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -319,8 +333,9 @@ func (c *Mysql80Controller) SetRootPassword(ctx http.Context) http.Response {
|
||||
|
||||
// DatabaseList 获取数据库列表
|
||||
func (c *Mysql80Controller) DatabaseList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
rootPassword := c.setting.Get(models.SettingKeyMysqlRootPassword)
|
||||
@@ -381,8 +396,9 @@ func (c *Mysql80Controller) DatabaseList(ctx http.Context) http.Response {
|
||||
|
||||
// AddDatabase 添加数据库
|
||||
func (c *Mysql80Controller) AddDatabase(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -412,8 +428,9 @@ func (c *Mysql80Controller) AddDatabase(ctx http.Context) http.Response {
|
||||
|
||||
// DeleteDatabase 删除数据库
|
||||
func (c *Mysql80Controller) DeleteDatabase(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -435,8 +452,9 @@ func (c *Mysql80Controller) DeleteDatabase(ctx http.Context) http.Response {
|
||||
|
||||
// BackupList 获取备份列表
|
||||
func (c *Mysql80Controller) BackupList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
backupList, err := c.backup.MysqlList()
|
||||
@@ -450,8 +468,9 @@ func (c *Mysql80Controller) BackupList(ctx http.Context) http.Response {
|
||||
|
||||
// UploadBackup 上传备份
|
||||
func (c *Mysql80Controller) UploadBackup(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
file, err := ctx.Request().File("file")
|
||||
@@ -475,8 +494,9 @@ func (c *Mysql80Controller) UploadBackup(ctx http.Context) http.Response {
|
||||
|
||||
// CreateBackup 创建备份
|
||||
func (c *Mysql80Controller) CreateBackup(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -501,8 +521,9 @@ func (c *Mysql80Controller) CreateBackup(ctx http.Context) http.Response {
|
||||
|
||||
// DeleteBackup 删除备份
|
||||
func (c *Mysql80Controller) DeleteBackup(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -524,8 +545,9 @@ func (c *Mysql80Controller) DeleteBackup(ctx http.Context) http.Response {
|
||||
|
||||
// RestoreBackup 还原备份
|
||||
func (c *Mysql80Controller) RestoreBackup(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -550,8 +572,9 @@ func (c *Mysql80Controller) RestoreBackup(ctx http.Context) http.Response {
|
||||
|
||||
// UserList 用户列表
|
||||
func (c *Mysql80Controller) UserList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
type user struct {
|
||||
@@ -635,8 +658,9 @@ func (c *Mysql80Controller) UserList(ctx http.Context) http.Response {
|
||||
|
||||
// AddUser 添加用户
|
||||
func (c *Mysql80Controller) AddUser(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -664,8 +688,9 @@ func (c *Mysql80Controller) AddUser(ctx http.Context) http.Response {
|
||||
|
||||
// DeleteUser 删除用户
|
||||
func (c *Mysql80Controller) DeleteUser(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -687,8 +712,9 @@ func (c *Mysql80Controller) DeleteUser(ctx http.Context) http.Response {
|
||||
|
||||
// SetUserPassword 设置用户密码
|
||||
func (c *Mysql80Controller) SetUserPassword(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -713,8 +739,9 @@ func (c *Mysql80Controller) SetUserPassword(ctx http.Context) http.Response {
|
||||
|
||||
// SetUserPrivileges 设置用户权限
|
||||
func (c *Mysql80Controller) SetUserPrivileges(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "mysql80") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "mysql80")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
|
||||
@@ -25,8 +25,9 @@ func NewOpenrestyController() *OpenRestyController {
|
||||
|
||||
// Status 获取运行状态
|
||||
func (c *OpenRestyController) Status(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status openresty | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -43,8 +44,9 @@ func (c *OpenRestyController) Status(ctx http.Context) http.Response {
|
||||
|
||||
// Reload 重载配置
|
||||
func (c *OpenRestyController) Reload(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl reload openresty")
|
||||
@@ -62,8 +64,9 @@ func (c *OpenRestyController) Reload(ctx http.Context) http.Response {
|
||||
|
||||
// Start 启动OpenResty
|
||||
func (c *OpenRestyController) Start(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl start openresty")
|
||||
@@ -81,8 +84,9 @@ func (c *OpenRestyController) Start(ctx http.Context) http.Response {
|
||||
|
||||
// Stop 停止OpenResty
|
||||
func (c *OpenRestyController) Stop(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl stop openresty")
|
||||
@@ -100,8 +104,9 @@ func (c *OpenRestyController) Stop(ctx http.Context) http.Response {
|
||||
|
||||
// Restart 重启OpenResty
|
||||
func (c *OpenRestyController) Restart(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl restart openresty")
|
||||
@@ -119,8 +124,9 @@ func (c *OpenRestyController) Restart(ctx http.Context) http.Response {
|
||||
|
||||
// GetConfig 获取配置
|
||||
func (c *OpenRestyController) GetConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := tools.Read("/www/server/openresty/conf/nginx.conf")
|
||||
@@ -133,8 +139,9 @@ func (c *OpenRestyController) GetConfig(ctx http.Context) http.Response {
|
||||
|
||||
// SaveConfig 保存配置
|
||||
func (c *OpenRestyController) SaveConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := ctx.Request().Input("config")
|
||||
@@ -151,8 +158,9 @@ func (c *OpenRestyController) SaveConfig(ctx http.Context) http.Response {
|
||||
|
||||
// ErrorLog 获取错误日志
|
||||
func (c *OpenRestyController) ErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
if !tools.Exists("/www/wwwlogs/nginx_error.log") {
|
||||
@@ -165,8 +173,9 @@ func (c *OpenRestyController) ErrorLog(ctx http.Context) http.Response {
|
||||
|
||||
// ClearErrorLog 清空错误日志
|
||||
func (c *OpenRestyController) ClearErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/wwwlogs/nginx_error.log")
|
||||
@@ -175,8 +184,9 @@ func (c *OpenRestyController) ClearErrorLog(ctx http.Context) http.Response {
|
||||
|
||||
// Load 获取负载
|
||||
func (c *OpenRestyController) Load(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
client := req.C().SetTimeout(10 * time.Second)
|
||||
|
||||
@@ -31,8 +31,9 @@ func NewPhp74Controller() *Php74Controller {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) Status(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status php-fpm-" + c.version + " | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -48,8 +49,9 @@ func (c *Php74Controller) Status(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) Reload(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl reload php-fpm-" + c.version)
|
||||
@@ -67,8 +69,9 @@ func (c *Php74Controller) Reload(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) Start(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl start php-fpm-" + c.version)
|
||||
@@ -86,8 +89,9 @@ func (c *Php74Controller) Start(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) Stop(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl stop php-fpm-" + c.version)
|
||||
@@ -105,8 +109,9 @@ func (c *Php74Controller) Stop(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) Restart(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl restart php-fpm-" + c.version)
|
||||
@@ -124,8 +129,9 @@ func (c *Php74Controller) Restart(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) GetConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := tools.Read("/www/server/php/" + c.version + "/etc/php.ini")
|
||||
@@ -133,8 +139,9 @@ func (c *Php74Controller) GetConfig(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := ctx.Request().Input("config")
|
||||
@@ -143,8 +150,9 @@ func (c *Php74Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) Load(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
client := req.C().SetTimeout(10 * time.Second)
|
||||
@@ -178,8 +186,9 @@ func (c *Php74Controller) Load(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) ErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Escape(tools.Exec("tail -n 100 /www/server/php/" + c.version + "/var/log/php-fpm.log"))
|
||||
@@ -187,8 +196,9 @@ func (c *Php74Controller) ErrorLog(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) SlowLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Escape(tools.Exec("tail -n 100 /www/server/php/" + c.version + "/var/log/slow.log"))
|
||||
@@ -196,8 +206,9 @@ func (c *Php74Controller) SlowLog(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) ClearErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/server/php/" + c.version + "/var/log/php-fpm.log")
|
||||
@@ -205,8 +216,9 @@ func (c *Php74Controller) ClearErrorLog(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) ClearSlowLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/server/php/" + c.version + "/var/log/slow.log")
|
||||
@@ -221,8 +233,9 @@ type Extension struct {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) GetExtensionList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
extensions := c.GetExtensions()
|
||||
@@ -230,8 +243,9 @@ func (c *Php74Controller) GetExtensionList(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) InstallExtension(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
slug := ctx.Request().Input("slug")
|
||||
@@ -266,8 +280,9 @@ func (c *Php74Controller) InstallExtension(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php74Controller) UninstallExtension(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
slug := ctx.Request().Input("slug")
|
||||
|
||||
@@ -31,8 +31,9 @@ func NewPhp80Controller() *Php80Controller {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) Status(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status php-fpm-" + c.version + " | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -48,8 +49,9 @@ func (c *Php80Controller) Status(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) Reload(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl reload php-fpm-" + c.version)
|
||||
@@ -67,8 +69,9 @@ func (c *Php80Controller) Reload(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) Start(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl start php-fpm-" + c.version)
|
||||
@@ -86,8 +89,9 @@ func (c *Php80Controller) Start(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) Stop(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl stop php-fpm-" + c.version)
|
||||
@@ -105,8 +109,9 @@ func (c *Php80Controller) Stop(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) Restart(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl restart php-fpm-" + c.version)
|
||||
@@ -124,8 +129,9 @@ func (c *Php80Controller) Restart(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) GetConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := tools.Read("/www/server/php/" + c.version + "/etc/php.ini")
|
||||
@@ -133,8 +139,9 @@ func (c *Php80Controller) GetConfig(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := ctx.Request().Input("config")
|
||||
@@ -143,8 +150,9 @@ func (c *Php80Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) Load(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
client := req.C().SetTimeout(10 * time.Second)
|
||||
@@ -178,8 +186,9 @@ func (c *Php80Controller) Load(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) ErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Escape(tools.Exec("tail -n 100 /www/server/php/" + c.version + "/var/log/php-fpm.log"))
|
||||
@@ -187,8 +196,9 @@ func (c *Php80Controller) ErrorLog(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) SlowLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Escape(tools.Exec("tail -n 100 /www/server/php/" + c.version + "/var/log/slow.log"))
|
||||
@@ -196,8 +206,9 @@ func (c *Php80Controller) SlowLog(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) ClearErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/server/php/" + c.version + "/var/log/php-fpm.log")
|
||||
@@ -205,8 +216,9 @@ func (c *Php80Controller) ClearErrorLog(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) ClearSlowLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/server/php/" + c.version + "/var/log/slow.log")
|
||||
@@ -221,8 +233,9 @@ type Extension struct {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) GetExtensionList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
extensions := c.GetExtensions()
|
||||
@@ -230,8 +243,9 @@ func (c *Php80Controller) GetExtensionList(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) InstallExtension(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
slug := ctx.Request().Input("slug")
|
||||
@@ -266,8 +280,9 @@ func (c *Php80Controller) InstallExtension(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php80Controller) UninstallExtension(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
slug := ctx.Request().Input("slug")
|
||||
|
||||
@@ -31,8 +31,9 @@ func NewPhp81Controller() *Php81Controller {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) Status(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status php-fpm-" + c.version + " | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -48,8 +49,9 @@ func (c *Php81Controller) Status(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) Reload(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl reload php-fpm-" + c.version)
|
||||
@@ -67,8 +69,9 @@ func (c *Php81Controller) Reload(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) Start(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl start php-fpm-" + c.version)
|
||||
@@ -86,8 +89,9 @@ func (c *Php81Controller) Start(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) Stop(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl stop php-fpm-" + c.version)
|
||||
@@ -105,8 +109,9 @@ func (c *Php81Controller) Stop(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) Restart(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl restart php-fpm-" + c.version)
|
||||
@@ -124,8 +129,9 @@ func (c *Php81Controller) Restart(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) GetConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := tools.Read("/www/server/php/" + c.version + "/etc/php.ini")
|
||||
@@ -133,8 +139,9 @@ func (c *Php81Controller) GetConfig(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := ctx.Request().Input("config")
|
||||
@@ -143,8 +150,9 @@ func (c *Php81Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) Load(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
client := req.C().SetTimeout(10 * time.Second)
|
||||
@@ -178,8 +186,9 @@ func (c *Php81Controller) Load(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) ErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Escape(tools.Exec("tail -n 100 /www/server/php/" + c.version + "/var/log/php-fpm.log"))
|
||||
@@ -187,8 +196,9 @@ func (c *Php81Controller) ErrorLog(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) SlowLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Escape(tools.Exec("tail -n 100 /www/server/php/" + c.version + "/var/log/slow.log"))
|
||||
@@ -196,8 +206,9 @@ func (c *Php81Controller) SlowLog(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) ClearErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/server/php/" + c.version + "/var/log/php-fpm.log")
|
||||
@@ -205,8 +216,9 @@ func (c *Php81Controller) ClearErrorLog(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) ClearSlowLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/server/php/" + c.version + "/var/log/slow.log")
|
||||
@@ -221,8 +233,9 @@ type Extension struct {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) GetExtensionList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
extensions := c.GetExtensions()
|
||||
@@ -230,8 +243,9 @@ func (c *Php81Controller) GetExtensionList(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) InstallExtension(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
slug := ctx.Request().Input("slug")
|
||||
@@ -266,8 +280,9 @@ func (c *Php81Controller) InstallExtension(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php81Controller) UninstallExtension(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
slug := ctx.Request().Input("slug")
|
||||
|
||||
@@ -31,8 +31,9 @@ func NewPhp82Controller() *Php82Controller {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) Status(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status php-fpm-" + c.version + " | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -48,8 +49,9 @@ func (c *Php82Controller) Status(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) Reload(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl reload php-fpm-" + c.version)
|
||||
@@ -67,8 +69,9 @@ func (c *Php82Controller) Reload(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) Start(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl start php-fpm-" + c.version)
|
||||
@@ -86,8 +89,9 @@ func (c *Php82Controller) Start(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) Stop(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl stop php-fpm-" + c.version)
|
||||
@@ -105,8 +109,9 @@ func (c *Php82Controller) Stop(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) Restart(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl restart php-fpm-" + c.version)
|
||||
@@ -124,8 +129,9 @@ func (c *Php82Controller) Restart(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) GetConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := tools.Read("/www/server/php/" + c.version + "/etc/php.ini")
|
||||
@@ -133,8 +139,9 @@ func (c *Php82Controller) GetConfig(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := ctx.Request().Input("config")
|
||||
@@ -143,8 +150,9 @@ func (c *Php82Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) Load(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
client := req.C().SetTimeout(10 * time.Second)
|
||||
@@ -178,8 +186,9 @@ func (c *Php82Controller) Load(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) ErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Escape(tools.Exec("tail -n 100 /www/server/php/" + c.version + "/var/log/php-fpm.log"))
|
||||
@@ -187,8 +196,9 @@ func (c *Php82Controller) ErrorLog(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) SlowLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Escape(tools.Exec("tail -n 100 /www/server/php/" + c.version + "/var/log/slow.log"))
|
||||
@@ -196,8 +206,9 @@ func (c *Php82Controller) SlowLog(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) ClearErrorLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/server/php/" + c.version + "/var/log/php-fpm.log")
|
||||
@@ -205,8 +216,9 @@ func (c *Php82Controller) ClearErrorLog(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) ClearSlowLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/server/php/" + c.version + "/var/log/slow.log")
|
||||
@@ -221,8 +233,9 @@ type Extension struct {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) GetExtensionList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
extensions := c.GetExtensions()
|
||||
@@ -230,8 +243,9 @@ func (c *Php82Controller) GetExtensionList(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) InstallExtension(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
slug := ctx.Request().Input("slug")
|
||||
@@ -266,8 +280,9 @@ func (c *Php82Controller) InstallExtension(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *Php82Controller) UninstallExtension(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "php"+c.version) {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "php"+c.version)
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
slug := ctx.Request().Input("slug")
|
||||
|
||||
@@ -19,8 +19,9 @@ func NewPhpMyAdminController() *PhpMyAdminController {
|
||||
}
|
||||
|
||||
func (c *PhpMyAdminController) Info(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "phpmyadmin") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "phpmyadmin")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
files, err := os.ReadDir("/www/server/phpmyadmin")
|
||||
@@ -51,8 +52,9 @@ func (c *PhpMyAdminController) Info(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
func (c *PhpMyAdminController) SetPort(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "phpmyadmin") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "phpmyadmin")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
port := ctx.Request().Input("port")
|
||||
|
||||
@@ -32,8 +32,9 @@ func NewPostgresql15Controller() *Postgresql15Controller {
|
||||
|
||||
// Status 获取运行状态
|
||||
func (c *Postgresql15Controller) Status(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status postgresql | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -50,8 +51,9 @@ func (c *Postgresql15Controller) Status(ctx http.Context) http.Response {
|
||||
|
||||
// Reload 重载配置
|
||||
func (c *Postgresql15Controller) Reload(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl reload postgresql")
|
||||
@@ -69,8 +71,9 @@ func (c *Postgresql15Controller) Reload(ctx http.Context) http.Response {
|
||||
|
||||
// Restart 重启服务
|
||||
func (c *Postgresql15Controller) Restart(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl restart postgresql")
|
||||
@@ -88,8 +91,9 @@ func (c *Postgresql15Controller) Restart(ctx http.Context) http.Response {
|
||||
|
||||
// Start 启动服务
|
||||
func (c *Postgresql15Controller) Start(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl start postgresql")
|
||||
@@ -107,8 +111,9 @@ func (c *Postgresql15Controller) Start(ctx http.Context) http.Response {
|
||||
|
||||
// Stop 停止服务
|
||||
func (c *Postgresql15Controller) Stop(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl stop postgresql")
|
||||
@@ -126,8 +131,9 @@ func (c *Postgresql15Controller) Stop(ctx http.Context) http.Response {
|
||||
|
||||
// GetConfig 获取配置
|
||||
func (c *Postgresql15Controller) GetConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
// 获取配置
|
||||
@@ -141,8 +147,9 @@ func (c *Postgresql15Controller) GetConfig(ctx http.Context) http.Response {
|
||||
|
||||
// GetUserConfig 获取用户配置
|
||||
func (c *Postgresql15Controller) GetUserConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
// 获取配置
|
||||
@@ -156,8 +163,9 @@ func (c *Postgresql15Controller) GetUserConfig(ctx http.Context) http.Response {
|
||||
|
||||
// SaveConfig 保存配置
|
||||
func (c *Postgresql15Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := ctx.Request().Input("config")
|
||||
@@ -174,8 +182,9 @@ func (c *Postgresql15Controller) SaveConfig(ctx http.Context) http.Response {
|
||||
|
||||
// SaveUserConfig 保存用户配置
|
||||
func (c *Postgresql15Controller) SaveUserConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := ctx.Request().Input("config")
|
||||
@@ -192,8 +201,9 @@ func (c *Postgresql15Controller) SaveUserConfig(ctx http.Context) http.Response
|
||||
|
||||
// Load 获取负载
|
||||
func (c *Postgresql15Controller) Load(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status postgresql | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -214,8 +224,9 @@ func (c *Postgresql15Controller) Load(ctx http.Context) http.Response {
|
||||
|
||||
// Log 获取日志
|
||||
func (c *Postgresql15Controller) Log(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Exec("tail -n 100 /www/server/postgresql/logs/postgresql-" + carbon.Now().ToDateString() + ".log")
|
||||
@@ -224,8 +235,9 @@ func (c *Postgresql15Controller) Log(ctx http.Context) http.Response {
|
||||
|
||||
// ClearLog 清空日志
|
||||
func (c *Postgresql15Controller) ClearLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("echo '' > /www/server/postgresql/logs/postgresql-" + carbon.Now().ToDateString() + ".log")
|
||||
@@ -234,8 +246,9 @@ func (c *Postgresql15Controller) ClearLog(ctx http.Context) http.Response {
|
||||
|
||||
// DatabaseList 获取数据库列表
|
||||
func (c *Postgresql15Controller) DatabaseList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status postgresql | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -290,8 +303,9 @@ func (c *Postgresql15Controller) DatabaseList(ctx http.Context) http.Response {
|
||||
|
||||
// AddDatabase 添加数据库
|
||||
func (c *Postgresql15Controller) AddDatabase(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -322,8 +336,9 @@ func (c *Postgresql15Controller) AddDatabase(ctx http.Context) http.Response {
|
||||
|
||||
// DeleteDatabase 删除数据库
|
||||
func (c *Postgresql15Controller) DeleteDatabase(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -344,8 +359,9 @@ func (c *Postgresql15Controller) DeleteDatabase(ctx http.Context) http.Response
|
||||
|
||||
// BackupList 获取备份列表
|
||||
func (c *Postgresql15Controller) BackupList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
backupList, err := c.backup.PostgresqlList()
|
||||
@@ -359,8 +375,9 @@ func (c *Postgresql15Controller) BackupList(ctx http.Context) http.Response {
|
||||
|
||||
// UploadBackup 上传备份
|
||||
func (c *Postgresql15Controller) UploadBackup(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
file, err := ctx.Request().File("file")
|
||||
@@ -384,8 +401,9 @@ func (c *Postgresql15Controller) UploadBackup(ctx http.Context) http.Response {
|
||||
|
||||
// CreateBackup 创建备份
|
||||
func (c *Postgresql15Controller) CreateBackup(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -410,8 +428,9 @@ func (c *Postgresql15Controller) CreateBackup(ctx http.Context) http.Response {
|
||||
|
||||
// DeleteBackup 删除备份
|
||||
func (c *Postgresql15Controller) DeleteBackup(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -433,8 +452,9 @@ func (c *Postgresql15Controller) DeleteBackup(ctx http.Context) http.Response {
|
||||
|
||||
// RestoreBackup 还原备份
|
||||
func (c *Postgresql15Controller) RestoreBackup(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -459,8 +479,9 @@ func (c *Postgresql15Controller) RestoreBackup(ctx http.Context) http.Response {
|
||||
|
||||
// UserList 用户列表
|
||||
func (c *Postgresql15Controller) UserList(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
type user struct {
|
||||
@@ -511,8 +532,9 @@ func (c *Postgresql15Controller) UserList(ctx http.Context) http.Response {
|
||||
|
||||
// AddUser 添加用户
|
||||
func (c *Postgresql15Controller) AddUser(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -541,8 +563,9 @@ func (c *Postgresql15Controller) AddUser(ctx http.Context) http.Response {
|
||||
|
||||
// DeleteUser 删除用户
|
||||
func (c *Postgresql15Controller) DeleteUser(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -564,8 +587,9 @@ func (c *Postgresql15Controller) DeleteUser(ctx http.Context) http.Response {
|
||||
|
||||
// SetUserPassword 设置用户密码
|
||||
func (c *Postgresql15Controller) SetUserPassword(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "postgresql15") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "postgresql15")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
|
||||
@@ -24,8 +24,9 @@ func NewPureFtpdController() *PureFtpdController {
|
||||
|
||||
// Status 获取运行状态
|
||||
func (c *PureFtpdController) Status(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "pureftpd") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "pureftpd")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status pure-ftpd | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -42,8 +43,9 @@ func (c *PureFtpdController) Status(ctx http.Context) http.Response {
|
||||
|
||||
// Reload 重载配置
|
||||
func (c *PureFtpdController) Reload(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "pureftpd") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "pureftpd")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl reload pure-ftpd")
|
||||
@@ -61,8 +63,9 @@ func (c *PureFtpdController) Reload(ctx http.Context) http.Response {
|
||||
|
||||
// Restart 重启服务
|
||||
func (c *PureFtpdController) Restart(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "pureftpd") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "pureftpd")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl restart pure-ftpd")
|
||||
@@ -80,8 +83,9 @@ func (c *PureFtpdController) Restart(ctx http.Context) http.Response {
|
||||
|
||||
// Start 启动服务
|
||||
func (c *PureFtpdController) Start(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "pureftpd") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "pureftpd")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl start pure-ftpd")
|
||||
@@ -99,8 +103,9 @@ func (c *PureFtpdController) Start(ctx http.Context) http.Response {
|
||||
|
||||
// Stop 停止服务
|
||||
func (c *PureFtpdController) Stop(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "pureftpd") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "pureftpd")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl stop pure-ftpd")
|
||||
@@ -118,8 +123,9 @@ func (c *PureFtpdController) Stop(ctx http.Context) http.Response {
|
||||
|
||||
// List 获取用户列表
|
||||
func (c *PureFtpdController) List(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "pureftpd") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "pureftpd")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
listRaw := tools.Exec("pure-pw list")
|
||||
@@ -167,8 +173,9 @@ func (c *PureFtpdController) List(ctx http.Context) http.Response {
|
||||
|
||||
// Add 添加用户
|
||||
func (c *PureFtpdController) Add(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "pureftpd") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "pureftpd")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -204,8 +211,9 @@ func (c *PureFtpdController) Add(ctx http.Context) http.Response {
|
||||
|
||||
// Delete 删除用户
|
||||
func (c *PureFtpdController) Delete(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "pureftpd") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "pureftpd")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -228,8 +236,9 @@ func (c *PureFtpdController) Delete(ctx http.Context) http.Response {
|
||||
|
||||
// ChangePassword 修改密码
|
||||
func (c *PureFtpdController) ChangePassword(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "pureftpd") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "pureftpd")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -254,8 +263,9 @@ func (c *PureFtpdController) ChangePassword(ctx http.Context) http.Response {
|
||||
|
||||
// GetPort 获取端口
|
||||
func (c *PureFtpdController) GetPort(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "pureftpd") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "pureftpd")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
port := tools.Exec(`cat /www/server/pure-ftpd/etc/pure-ftpd.conf | grep "Bind" | awk '{print $2}' | awk -F "," '{print $2}'`)
|
||||
@@ -268,8 +278,9 @@ func (c *PureFtpdController) GetPort(ctx http.Context) http.Response {
|
||||
|
||||
// SetPort 设置端口
|
||||
func (c *PureFtpdController) SetPort(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "pureftpd") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "pureftpd")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
|
||||
@@ -23,8 +23,9 @@ func NewRedisController() *RedisController {
|
||||
|
||||
// Status 获取运行状态
|
||||
func (c *RedisController) Status(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "redis") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "redis")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status redis | grep Active | grep -v grep | awk '{print $2}'")
|
||||
@@ -41,8 +42,9 @@ func (c *RedisController) Status(ctx http.Context) http.Response {
|
||||
|
||||
// Reload 重载配置
|
||||
func (c *RedisController) Reload(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "redis") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "redis")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl reload redis")
|
||||
@@ -60,8 +62,9 @@ func (c *RedisController) Reload(ctx http.Context) http.Response {
|
||||
|
||||
// Restart 重启服务
|
||||
func (c *RedisController) Restart(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "redis") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "redis")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl restart redis")
|
||||
@@ -79,8 +82,9 @@ func (c *RedisController) Restart(ctx http.Context) http.Response {
|
||||
|
||||
// Start 启动服务
|
||||
func (c *RedisController) Start(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "redis") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "redis")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl start redis")
|
||||
@@ -98,8 +102,9 @@ func (c *RedisController) Start(ctx http.Context) http.Response {
|
||||
|
||||
// Stop 停止服务
|
||||
func (c *RedisController) Stop(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "redis") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "redis")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec("systemctl stop redis")
|
||||
@@ -117,8 +122,9 @@ func (c *RedisController) Stop(ctx http.Context) http.Response {
|
||||
|
||||
// GetConfig 获取配置
|
||||
func (c *RedisController) GetConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "redis") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "redis")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
// 获取配置
|
||||
@@ -132,8 +138,9 @@ func (c *RedisController) GetConfig(ctx http.Context) http.Response {
|
||||
|
||||
// SaveConfig 保存配置
|
||||
func (c *RedisController) SaveConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "redis") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "redis")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := ctx.Request().Input("config")
|
||||
@@ -150,8 +157,9 @@ func (c *RedisController) SaveConfig(ctx http.Context) http.Response {
|
||||
|
||||
// Load 获取负载
|
||||
func (c *RedisController) Load(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "redis") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "redis")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec("systemctl status redis | grep Active | grep -v grep | awk '{print $2}'")
|
||||
|
||||
@@ -32,8 +32,9 @@ func NewS3fsController() *S3fsController {
|
||||
|
||||
// List 所有 S3fs 挂载
|
||||
func (c *S3fsController) List(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "s3fs") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "s3fs")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
page := ctx.Request().QueryInt("page", 1)
|
||||
@@ -66,8 +67,9 @@ func (c *S3fsController) List(ctx http.Context) http.Response {
|
||||
|
||||
// Add 添加 S3fs 挂载
|
||||
func (c *S3fsController) Add(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "s3fs") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "s3fs")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -119,13 +121,13 @@ func (c *S3fsController) Add(ctx http.Context) http.Response {
|
||||
password := ak + ":" + sk
|
||||
tools.Write("/etc/passwd-s3fs-"+cast.ToString(id), password, 0600)
|
||||
tools.Exec(`echo 's3fs#` + bucket + ` ` + path + ` fuse _netdev,allow_other,nonempty,url=` + url + `,passwd_file=/etc/passwd-s3fs-` + cast.ToString(id) + ` 0 0' >> /etc/fstab`)
|
||||
check := tools.Exec("mount -a 2>&1")
|
||||
if len(check) != 0 {
|
||||
mountCheck := tools.Exec("mount -a 2>&1")
|
||||
if len(mountCheck) != 0 {
|
||||
tools.Exec(`sed -i 's@^s3fs#` + bucket + `\s` + path + `.*$@@g' /etc/fstab`)
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "检测到/etc/fstab有误: "+check)
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "检测到/etc/fstab有误: "+mountCheck)
|
||||
}
|
||||
check2 := tools.Exec("df -h | grep " + path + " 2>&1")
|
||||
if len(check2) == 0 {
|
||||
dfCheck := tools.Exec("df -h | grep " + path + " 2>&1")
|
||||
if len(dfCheck) == 0 {
|
||||
tools.Exec(`sed -i 's@^s3fs#` + bucket + `\s` + path + `.*$@@g' /etc/fstab`)
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "挂载失败,请检查配置是否正确")
|
||||
}
|
||||
@@ -150,8 +152,9 @@ func (c *S3fsController) Add(ctx http.Context) http.Response {
|
||||
|
||||
// Delete 删除 S3fs 挂载
|
||||
func (c *S3fsController) Delete(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "s3fs") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "s3fs")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
id := ctx.Request().Input("id")
|
||||
@@ -179,9 +182,9 @@ func (c *S3fsController) Delete(ctx http.Context) http.Response {
|
||||
tools.Exec(`fusermount -u '` + mount.Path + `' 2>&1`)
|
||||
tools.Exec(`umount '` + mount.Path + `' 2>&1`)
|
||||
tools.Exec(`sed -i 's@^s3fs#` + mount.Bucket + `\s` + mount.Path + `.*$@@g' /etc/fstab`)
|
||||
check := tools.Exec("mount -a 2>&1")
|
||||
if len(check) != 0 {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "检测到/etc/fstab有误: "+check)
|
||||
mountCheck := tools.Exec("mount -a 2>&1")
|
||||
if len(mountCheck) != 0 {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "检测到/etc/fstab有误: "+mountCheck)
|
||||
}
|
||||
tools.Remove("/etc/passwd-s3fs-" + cast.ToString(mount.ID))
|
||||
|
||||
|
||||
@@ -29,8 +29,9 @@ func NewSupervisorController() *SupervisorController {
|
||||
|
||||
// Status 状态
|
||||
func (c *SupervisorController) Status(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
status := tools.Exec(`systemctl status ` + c.ServiceName + ` | grep Active | grep -v grep | awk '{print $2}'`)
|
||||
@@ -43,8 +44,9 @@ func (c *SupervisorController) Status(ctx http.Context) http.Response {
|
||||
|
||||
// Start 启动
|
||||
func (c *SupervisorController) Start(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec(`systemctl start ` + c.ServiceName)
|
||||
@@ -58,8 +60,9 @@ func (c *SupervisorController) Start(ctx http.Context) http.Response {
|
||||
|
||||
// Stop 停止
|
||||
func (c *SupervisorController) Stop(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec(`systemctl stop ` + c.ServiceName)
|
||||
@@ -73,8 +76,9 @@ func (c *SupervisorController) Stop(ctx http.Context) http.Response {
|
||||
|
||||
// Restart 重启
|
||||
func (c *SupervisorController) Restart(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec(`systemctl restart ` + c.ServiceName)
|
||||
@@ -88,8 +92,9 @@ func (c *SupervisorController) Restart(ctx http.Context) http.Response {
|
||||
|
||||
// Reload 重载
|
||||
func (c *SupervisorController) Reload(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec(`systemctl reload ` + c.ServiceName)
|
||||
@@ -103,8 +108,9 @@ func (c *SupervisorController) Reload(ctx http.Context) http.Response {
|
||||
|
||||
// Log 日志
|
||||
func (c *SupervisorController) Log(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
log := tools.Exec(`tail -n 200 /var/log/supervisor/supervisord.log`)
|
||||
@@ -113,8 +119,9 @@ func (c *SupervisorController) Log(ctx http.Context) http.Response {
|
||||
|
||||
// ClearLog 清空日志
|
||||
func (c *SupervisorController) ClearLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
tools.Exec(`echo "" > /var/log/supervisor/supervisord.log`)
|
||||
@@ -123,8 +130,9 @@ func (c *SupervisorController) ClearLog(ctx http.Context) http.Response {
|
||||
|
||||
// Config 获取配置
|
||||
func (c *SupervisorController) Config(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
var config string
|
||||
@@ -138,8 +146,9 @@ func (c *SupervisorController) Config(ctx http.Context) http.Response {
|
||||
|
||||
// SaveConfig 保存配置
|
||||
func (c *SupervisorController) SaveConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
config := ctx.Request().Input("config")
|
||||
@@ -154,8 +163,9 @@ func (c *SupervisorController) SaveConfig(ctx http.Context) http.Response {
|
||||
|
||||
// Processes 进程列表
|
||||
func (c *SupervisorController) Processes(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
page := ctx.Request().QueryInt("page", 1)
|
||||
@@ -209,8 +219,9 @@ func (c *SupervisorController) Processes(ctx http.Context) http.Response {
|
||||
|
||||
// StartProcess 启动进程
|
||||
func (c *SupervisorController) StartProcess(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
process := ctx.Request().Input("process")
|
||||
@@ -220,8 +231,9 @@ func (c *SupervisorController) StartProcess(ctx http.Context) http.Response {
|
||||
|
||||
// StopProcess 停止进程
|
||||
func (c *SupervisorController) StopProcess(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
process := ctx.Request().Input("process")
|
||||
@@ -231,8 +243,9 @@ func (c *SupervisorController) StopProcess(ctx http.Context) http.Response {
|
||||
|
||||
// RestartProcess 重启进程
|
||||
func (c *SupervisorController) RestartProcess(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
process := ctx.Request().Input("process")
|
||||
@@ -242,8 +255,9 @@ func (c *SupervisorController) RestartProcess(ctx http.Context) http.Response {
|
||||
|
||||
// ProcessLog 进程日志
|
||||
func (c *SupervisorController) ProcessLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
process := ctx.Request().Input("process")
|
||||
@@ -260,8 +274,9 @@ func (c *SupervisorController) ProcessLog(ctx http.Context) http.Response {
|
||||
|
||||
// ClearProcessLog 清空进程日志
|
||||
func (c *SupervisorController) ClearProcessLog(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
process := ctx.Request().Input("process")
|
||||
@@ -278,8 +293,9 @@ func (c *SupervisorController) ClearProcessLog(ctx http.Context) http.Response {
|
||||
|
||||
// ProcessConfig 获取进程配置
|
||||
func (c *SupervisorController) ProcessConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
process := ctx.Request().Query("process")
|
||||
@@ -295,8 +311,9 @@ func (c *SupervisorController) ProcessConfig(ctx http.Context) http.Response {
|
||||
|
||||
// SaveProcessConfig 保存进程配置
|
||||
func (c *SupervisorController) SaveProcessConfig(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
process := ctx.Request().Input("process")
|
||||
@@ -315,8 +332,9 @@ func (c *SupervisorController) SaveProcessConfig(ctx http.Context) http.Response
|
||||
|
||||
// AddProcess 添加进程
|
||||
func (c *SupervisorController) AddProcess(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
@@ -364,8 +382,9 @@ stdout_logfile_maxbytes=2MB
|
||||
|
||||
// DeleteProcess 删除进程
|
||||
func (c *SupervisorController) DeleteProcess(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "supervisor") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "supervisor")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
process := ctx.Request().Input("process")
|
||||
|
||||
@@ -21,8 +21,9 @@ func NewToolBoxController() *ToolBoxController {
|
||||
|
||||
// GetDNS 获取 DNS 信息
|
||||
func (c *ToolBoxController) GetDNS(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "toolbox") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "toolbox")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
raw := tools.Read("/etc/resolv.conf")
|
||||
@@ -41,8 +42,9 @@ func (c *ToolBoxController) GetDNS(ctx http.Context) http.Response {
|
||||
|
||||
// SetDNS 设置 DNS 信息
|
||||
func (c *ToolBoxController) SetDNS(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "toolbox") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "toolbox")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
dns1 := ctx.Request().Input("dns1")
|
||||
@@ -62,8 +64,9 @@ func (c *ToolBoxController) SetDNS(ctx http.Context) http.Response {
|
||||
|
||||
// GetSWAP 获取 SWAP 信息
|
||||
func (c *ToolBoxController) GetSWAP(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "toolbox") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "toolbox")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
var total, size, used, free string
|
||||
@@ -93,8 +96,9 @@ func (c *ToolBoxController) GetSWAP(ctx http.Context) http.Response {
|
||||
|
||||
// SetSWAP 设置 SWAP 信息
|
||||
func (c *ToolBoxController) SetSWAP(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "toolbox") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "toolbox")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
size := ctx.Request().InputInt("size")
|
||||
@@ -127,8 +131,9 @@ func (c *ToolBoxController) SetSWAP(ctx http.Context) http.Response {
|
||||
|
||||
// GetTimezone 获取时区
|
||||
func (c *ToolBoxController) GetTimezone(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "toolbox") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "toolbox")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
raw := tools.Exec("LC_ALL=C timedatectl | grep zone")
|
||||
@@ -148,8 +153,9 @@ func (c *ToolBoxController) GetTimezone(ctx http.Context) http.Response {
|
||||
|
||||
// SetTimezone 设置时区
|
||||
func (c *ToolBoxController) SetTimezone(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "toolbox") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "toolbox")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
timezone := ctx.Request().Input("timezone")
|
||||
@@ -164,8 +170,9 @@ func (c *ToolBoxController) SetTimezone(ctx http.Context) http.Response {
|
||||
|
||||
// GetHosts 获取 hosts 信息
|
||||
func (c *ToolBoxController) GetHosts(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "toolbox") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "toolbox")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, tools.Read("/etc/hosts"))
|
||||
@@ -173,8 +180,9 @@ func (c *ToolBoxController) GetHosts(ctx http.Context) http.Response {
|
||||
|
||||
// SetHosts 设置 hosts 信息
|
||||
func (c *ToolBoxController) SetHosts(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "toolbox") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "toolbox")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
hosts := ctx.Request().Input("hosts")
|
||||
@@ -189,8 +197,9 @@ func (c *ToolBoxController) SetHosts(ctx http.Context) http.Response {
|
||||
|
||||
// SetRootPassword 设置 root 密码
|
||||
func (c *ToolBoxController) SetRootPassword(ctx http.Context) http.Response {
|
||||
if !controllers.Check(ctx, "toolbox") {
|
||||
return nil
|
||||
check := controllers.Check(ctx, "toolbox")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
|
||||
password := ctx.Request().Input("password")
|
||||
|
||||
@@ -47,8 +47,9 @@ func (c *WebsiteController) List(ctx http.Context) http.Response {
|
||||
|
||||
// Add 添加网站
|
||||
func (c *WebsiteController) Add(ctx http.Context) http.Response {
|
||||
if !Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
"name": "required|regex:^[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)*$|not_exists:websites,name",
|
||||
@@ -88,8 +89,9 @@ func (c *WebsiteController) Add(ctx http.Context) http.Response {
|
||||
|
||||
// Delete 删除网站
|
||||
func (c *WebsiteController) Delete(ctx http.Context) http.Response {
|
||||
if !Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
id := ctx.Request().InputInt("id")
|
||||
err := c.website.Delete(id)
|
||||
@@ -103,8 +105,9 @@ func (c *WebsiteController) Delete(ctx http.Context) http.Response {
|
||||
|
||||
// GetDefaultConfig 获取默认配置
|
||||
func (c *WebsiteController) GetDefaultConfig(ctx http.Context) http.Response {
|
||||
if !Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
index := tools.Read("/www/server/openresty/html/index.html")
|
||||
stop := tools.Read("/www/server/openresty/html/stop.html")
|
||||
@@ -117,8 +120,9 @@ func (c *WebsiteController) GetDefaultConfig(ctx http.Context) http.Response {
|
||||
|
||||
// SaveDefaultConfig 保存默认配置
|
||||
func (c *WebsiteController) SaveDefaultConfig(ctx http.Context) http.Response {
|
||||
if !Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
index := ctx.Request().Input("index")
|
||||
stop := ctx.Request().Input("stop")
|
||||
@@ -138,8 +142,9 @@ func (c *WebsiteController) SaveDefaultConfig(ctx http.Context) http.Response {
|
||||
|
||||
// GetConfig 获取配置
|
||||
func (c *WebsiteController) GetConfig(ctx http.Context) http.Response {
|
||||
if !Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
id := ctx.Request().InputInt("id")
|
||||
if id == 0 {
|
||||
@@ -157,8 +162,9 @@ func (c *WebsiteController) GetConfig(ctx http.Context) http.Response {
|
||||
|
||||
// SaveConfig 保存配置
|
||||
func (c *WebsiteController) SaveConfig(ctx http.Context) http.Response {
|
||||
if !Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
"id": "required",
|
||||
@@ -379,8 +385,9 @@ func (c *WebsiteController) SaveConfig(ctx http.Context) http.Response {
|
||||
|
||||
// ClearLog 清空日志
|
||||
func (c *WebsiteController) ClearLog(ctx http.Context) http.Response {
|
||||
if !Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
id := ctx.Request().InputInt("id")
|
||||
if id == 0 {
|
||||
@@ -526,8 +533,9 @@ func (c *WebsiteController) DeleteBackup(ctx http.Context) http.Response {
|
||||
|
||||
// ResetConfig 重置配置
|
||||
func (c *WebsiteController) ResetConfig(ctx http.Context) http.Response {
|
||||
if !Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
id := ctx.Request().InputInt("id")
|
||||
if id == 0 {
|
||||
@@ -615,8 +623,9 @@ server
|
||||
|
||||
// Status 网站状态
|
||||
func (c *WebsiteController) Status(ctx http.Context) http.Response {
|
||||
if !Check(ctx, "openresty") {
|
||||
return nil
|
||||
check := Check(ctx, "openresty")
|
||||
if check != nil {
|
||||
return check
|
||||
}
|
||||
id := ctx.Request().InputInt("id")
|
||||
if id == 0 {
|
||||
|
||||
@@ -4,7 +4,7 @@ var (
|
||||
Name = "PHP-8.0"
|
||||
Description = "PHP 是世界上最好的语言!"
|
||||
Slug = "php80"
|
||||
Version = "8.0.29"
|
||||
Version = "8.0.30"
|
||||
Requires = []string{}
|
||||
Excludes = []string{}
|
||||
Install = `bash /www/panel/scripts/php/install.sh 80`
|
||||
|
||||
@@ -4,7 +4,7 @@ var (
|
||||
Name = "PHP-8.1"
|
||||
Description = "PHP 是世界上最好的语言!"
|
||||
Slug = "php81"
|
||||
Version = "8.1.21"
|
||||
Version = "8.1.23"
|
||||
Requires = []string{}
|
||||
Excludes = []string{}
|
||||
Install = `bash /www/panel/scripts/php/install.sh 81`
|
||||
|
||||
@@ -4,7 +4,7 @@ var (
|
||||
Name = "PHP-8.2"
|
||||
Description = "PHP 是世界上最好的语言!"
|
||||
Slug = "php82"
|
||||
Version = "8.2.8"
|
||||
Version = "8.2.10"
|
||||
Requires = []string{}
|
||||
Excludes = []string{}
|
||||
Install = `bash /www/panel/scripts/php/install.sh 82`
|
||||
|
||||
@@ -8,6 +8,6 @@ func init() {
|
||||
config := facades.Config()
|
||||
config.Add("panel", map[string]any{
|
||||
"name": "耗子Linux面板",
|
||||
"version": "v2.0.39",
|
||||
"version": "v2.0.40",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -59,11 +59,11 @@ cd ${phpPath}
|
||||
if [ "${phpVersion}" == "74" ]; then
|
||||
phpVersionCode="7.4.33"
|
||||
elif [ "${phpVersion}" == "80" ]; then
|
||||
phpVersionCode="8.0.29"
|
||||
phpVersionCode="8.0.30"
|
||||
elif [ "${phpVersion}" == "81" ]; then
|
||||
phpVersionCode="8.1.21"
|
||||
phpVersionCode="8.1.23"
|
||||
elif [ "${phpVersion}" == "82" ]; then
|
||||
phpVersionCode="8.2.8"
|
||||
phpVersionCode="8.2.10"
|
||||
else
|
||||
echo -e $HR
|
||||
echo "错误:PHP-${phpVersion}不支持,请检查版本号是否正确。"
|
||||
|
||||
Reference in New Issue
Block a user