X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=jenkins-init-scripts%2Fcreate-swap-file.sh;h=6f077388b84c7a8b4e71dcf6306bec80458294f9;hb=refs%2Fchanges%2F78%2F14778%2F5;hp=cf8d97f109178e4b3fb3f0cc8b44b529df5bc4a1;hpb=2f22e7fa9fc24ac6c4cbca8eac2af7efc298f304;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..6f077388 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]*) blockCount=$blockCount ;; + *) exit ;; +esac +[[ $blockCount == 0 ]] && exit + +dd if=/dev/zero of=/swap count="${blockCount}k" bs=1MiB chmod 600 /swap mkswap /swap swapon /swap