Browse Source

Added Swap creation

bugfixes
gau1991 10 years ago
parent
commit
2950436dd5
  1. 2
      ee/cli/plugins/stack.py
  2. 24
      ee/core/addswap.py

2
ee/cli/plugins/stack.py

@ -10,6 +10,7 @@ from ee.core.fileutils import EEFileUtils
from ee.core.apt_repo import EERepo
from ee.core.extract import EEExtract
from ee.core.mysql import EEMysql
from ee.core.addswap import EESwap
from pynginxconfig import NginxConfig
import random
import string
@ -798,6 +799,7 @@ class EEStackController(CementBaseController):
self.app.log.debug("Calling pre_pref ")
self.pre_pref(apt_packages)
if len(apt_packages):
EESwap.add(self)
self.app.log.debug("Updating apt-cache")
EEAptGet.update()
self.app.log.debug("Installing all apt_packages")

24
ee/core/addswap.py

@ -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…
Cancel
Save