#!/bin/bash # Author: yeho # BLOG: https://linuxeye.com # # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+ # # Project home page: # https://oneinstack.com # https://github.com/oneinstack/oneinstack export LANG=en_US.UTF-8 export LANGUAGE=en_US:en Mem=`free -m | awk '/Mem:/{print $2}'` Swap=`free -m | awk '/Swap:/{print $2}'` if [ $Mem -le 640 ]; then Mem_level=512M Memory_limit=64 THREAD=1 elif [ $Mem -gt 640 -a $Mem -le 1280 ]; then Mem_level=1G Memory_limit=128 elif [ $Mem -gt 1280 -a $Mem -le 2500 ]; then Mem_level=2G Memory_limit=192 elif [ $Mem -gt 2500 -a $Mem -le 3500 ]; then Mem_level=3G Memory_limit=256 elif [ $Mem -gt 3500 -a $Mem -le 4500 ]; then Mem_level=4G Memory_limit=320 elif [ $Mem -gt 4500 -a $Mem -le 8000 ]; then Mem_level=6G Memory_limit=384 elif [ $Mem -gt 8000 ]; then Mem_level=8G Memory_limit=448 fi # add swapfile if [ ! -e ~/.oneinstack ] && [ "${Swap}" == '0' ] && [ ${Mem} -le 2048 ]; then echo "${CWARNING}Add Swap file, It may take a few minutes... ${CEND}" dd if=/dev/zero of=/swapfile count=2048 bs=1M mkswap /swapfile swapon /swapfile chmod 600 /swapfile [ -z "`grep swapfile /etc/fstab`" ] && echo '/swapfile swap swap defaults 0 0' >> /etc/fstab fi