2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-05 04:37:17 +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

@@ -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")