#NEWLINE# def add( self ) : #NEWLINE# #INDENT# 'Swap addition with EasyEngine' #NEWLINE# if ( EEVariables . ee_ram < 512 ) : #NEWLINE# #INDENT# if ( EEVariables . ee_swap < 1000 ) : #NEWLINE# #INDENT# Log . info ( self , 'Adding SWAP file, please wait...' ) #NEWLINE# EEAptGet . update ( self ) #NEWLINE# EEAptGet . install ( self , [ 'dphys-swapfile' ] ) #NEWLINE# EEShellExec . cmd_exec ( self , 'service dphys-swapfile stop' ) #NEWLINE# EEShellExec . cmd_exec ( self , '/sbin/dphys-swapfile uninstall' ) #NEWLINE# if os . path . isfile ( '/etc/dphys-swapfile' ) : #NEWLINE# #INDENT# EEFileUtils . searchreplace ( self , '/etc/dphys-swapfile' , '#CONF_SWAPFILE=/var/swap' , 'CONF_SWAPFILE=/ee-swapfile' ) #NEWLINE# EEFileUtils . searchreplace ( conffile , '/etc/dphys-swapfile' , '#CONF_MAXSWAP=2048' , 'CONF_MAXSWAP=1024' ) #NEWLINE# EEFileUtils . searchreplace ( self , '/etc/dphys-swapfile' , '#CONF_SWAPSIZE=' , 'CONF_SWAPSIZE=1024' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# with open ( '/etc/dphys-swapfile' , 'w' ) as conffile : #NEWLINE# #INDENT# conffile . write ( 'CONF_SWAPFILE=/ee-swapfile\nCONF_SWAPSIZE=1024\nCONF_MAXSWAP=1024\n' ) #NEWLINE# #UNINDENT# #UNINDENT# EEShellExec . cmd_exec ( self , 'service dphys-swapfile start' )