Update 'etc-init.d-swapfile'
This commit is contained in:
parent
38140127de
commit
3addb104ce
@ -8,7 +8,8 @@ EXTRA_COMMANDS="status create"
|
|||||||
EXTRA_HELP=" status Check service status
|
EXTRA_HELP=" status Check service status
|
||||||
create Create a swapfile"
|
create Create a swapfile"
|
||||||
|
|
||||||
SWPATH="/mnt/routerdata/swapfile"
|
# default value, it'd be better to use other place than overlay
|
||||||
|
SWPATH="/overlay/swapfile"
|
||||||
|
|
||||||
boot() {
|
boot() {
|
||||||
if [ -f $SWPATH ]; then
|
if [ -f $SWPATH ]; then
|
||||||
@ -56,7 +57,11 @@ stop() {
|
|||||||
create() {
|
create() {
|
||||||
RAMTOTAL=`fgrep MemTotal /proc/meminfo | awk '{print $2}'`
|
RAMTOTAL=`fgrep MemTotal /proc/meminfo | awk '{print $2}'`
|
||||||
SWAPTOTAL=`fgrep SwapTotal /proc/meminfo | awk '{print $2}'`
|
SWAPTOTAL=`fgrep SwapTotal /proc/meminfo | awk '{print $2}'`
|
||||||
if [ $SWAPTOTAL != 0 ]; then
|
OVERLAYSIZE=`df | grep overlayfs | awk '{print $3}'`
|
||||||
|
if [ $OVERLAYSIZE < $RAMTOTAL ]; then
|
||||||
|
echo "ERROR: Not enough storage for a swapfile, quitting..."
|
||||||
|
exit 1
|
||||||
|
elif [ $SWAPTOTAL != 0 ]; then
|
||||||
echo "ERROR: Swap already in use, quitting..."
|
echo "ERROR: Swap already in use, quitting..."
|
||||||
else
|
else
|
||||||
dd if=/dev/zero of=$SWFILE bs=1024 count=$RAMTOTAL
|
dd if=/dev/zero of=$SWFILE bs=1024 count=$RAMTOTAL
|
||||||
|
Loading…
Reference in New Issue
Block a user