gau1991
10 years ago
2 changed files with 26 additions and 0 deletions
@ -0,0 +1,24 @@ |
|||
from ee.core.variables import EEVariables |
|||
from ee.core.shellexec import EEShellExec |
|||
from ee.core.fileutils import EEFileUtils |
|||
|
|||
|
|||
class EESwap(): |
|||
"""Manage Swap""" |
|||
|
|||
def __init__(): |
|||
"""Initialize """ |
|||
pass |
|||
|
|||
def add(self): |
|||
if EEVariables.ee_ram < 512: |
|||
if EEVariables.ee_swap < 1000: |
|||
self.app.log.info("Adding SWAP") |
|||
EEShellExec.cmd_exec(self, "dd if=/dev/zero of=/ee-swapfile " |
|||
"bs=1024 count=1048k") |
|||
EEShellExec.cmd_exec(self, "mkswap /ee-swapfile") |
|||
EEFileUtils.chown(self, "/ee-swapfile", "root", "root") |
|||
EEFileUtils.chmod(self, "/ee-swapfile", 0o600) |
|||
EEShellExec.cmd_exec(self, "swapon /ee-swapfile") |
|||
with open("/etc/fstab", "a") as swap_file: |
|||
myfile.write("/ee-swapfile\tnone\tswap\tsw\t0 0") |
Loading…
Reference in new issue