2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-05 02:07:18 +08:00

refactor: 重构 tools.Chmod 函数

This commit is contained in:
耗子
2023-11-12 03:12:35 +08:00
parent 4c41ec036c
commit edd526d3b8
6 changed files with 18 additions and 16 deletions

View File

@@ -182,7 +182,9 @@ func (r *PureFtpdController) Add(ctx http.Context) http.Response {
return controllers.Error(ctx, http.StatusUnprocessableEntity, "目录不存在")
}
tools.Chmod(path, 0755)
if err = tools.Chmod(path, 0755); err != nil {
return controllers.Error(ctx, http.StatusUnprocessableEntity, "修改目录权限失败")
}
tools.Chown(path, "www", "www")
tools.Exec(`yes '` + password + `' | pure-pw useradd ` + username + ` -u www -g www -d ` + path)
tools.Exec("pure-pw mkdb")

View File

@@ -123,7 +123,9 @@ func (r *ToolBoxController) SetSWAP(ctx http.Context) http.Response {
} else {
tools.Exec("dd if=/dev/zero of=/www/swap bs=1M count=" + cast.ToString(size))
tools.Exec("mkswap -f /www/swap")
tools.Chmod("/www/swap", 0600)
if err := tools.Chmod("/www/swap", 0600); err != nil {
return controllers.Error(ctx, http.StatusUnprocessableEntity, "设置 SWAP 权限失败")
}
}
tools.Exec("swapon /www/swap")
tools.Exec("echo '/www/swap swap swap defaults 0 0' >> /etc/fstab")