Skip to content

Commit 7d2feba

Browse files
authored
Fix a bug when swapfile doesn't exist (#6068)
I made a mistake in #6066 and should have checked if the file exists first.
1 parent dc41aa1 commit 7d2feba

File tree

1 file changed

+5
-3
lines changed
  • terraform-aws-github-runner/modules/runners-instances/templates

1 file changed

+5
-3
lines changed

terraform-aws-github-runner/modules/runners-instances/templates/user-data.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,11 @@ fi
138138

139139
${post_install}
140140

141-
# Cleanup any existing swapfile just to be sure
142-
sudo swapoff /swapfile
143-
sudo rm /swapfile
141+
if [[ -f /swapfile ]]; then
142+
# Cleanup any existing swapfile just to be sure
143+
sudo swapoff /swapfile
144+
sudo rm /swapfile
145+
fi
144146
# before allocating a new one
145147
sudo fallocate -l 3G /swapfile
146148
sudo chmod 600 /swapfile

0 commit comments

Comments
 (0)