X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=jenkins-init-scripts%2Fcreate-swap-file.sh;h=8090bce6c7399921e1395d61be3f83171943d659;hb=d1e8579fac0f3a0aeba74f70b27a06ab3fdad54f;hp=cf8d97f109178e4b3fb3f0cc8b44b529df5bc4a1;hpb=d9aedddc8722e75fd24f9c7a9209e96ee5cea507;p=releng%2Fglobal-jjb.git diff --git a/jenkins-init-scripts/create-swap-file.sh b/jenkins-init-scripts/create-swap-file.sh index cf8d97f1..8090bce6 100755 --- a/jenkins-init-scripts/create-swap-file.sh +++ b/jenkins-init-scripts/create-swap-file.sh @@ -9,7 +9,22 @@ # http://www.eclipse.org/legal/epl-v10.html ############################################################################## -dd if=/dev/zero of=/swap count=1024 bs=1MiB +# Get the blockCount from the 'SWAP_SIZE' environmental variable +blockCount=${SWAP_SIZE-''} + +# Validate SWAP_SIZE +# Empty: Set blockCount 1 +# Zero: No Swap +# Integer: Set blockCount +# Else: No Swap +case $blockCount in + '') blockCount=1 ;; + [0-9]*) ;; + *) exit ;; +esac +[[ $blockCount == 0 ]] && exit + +dd if=/dev/zero of=/swap count="${blockCount}k" bs=1MiB chmod 600 /swap mkswap /swap swapon /swap