diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1 @@ + diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f528245..0000000 --- a/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -# See https://help.github.com/articles/ignoring-files for more about ignoring files. -# -# If you find yourself ignoring temporary files generated by your text editor -# or operating system, you probably want to add a global ignore instead: -# git config --global core.excludesfile '~/.gitignore_global' - -# Ignore all logfiles and tempfiles. -/log/* -!/log/.keep -tmp -/.idea/* - diff --git a/README.md b/README.md index 780029d..e4a97c1 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,16 @@ Disclamer: This script may not work on every GNU/Linux distro. Sorry. ## Usage -First of all, download the main script: +First of all, download the main script using `wget` or `curl`: ``` wget https://raw.githubusercontent.com/Cretezy/Swap/master/swap.sh -O swap +# or using curl: +# curl https://raw.githubusercontent.com/Cretezy/Swap/master/swap.sh -o swap ``` Then simply run the file with this format: ``` -sh swap {size} +sh swap ``` Example (with 4G): @@ -25,23 +27,5 @@ sh swap 4G The default path for the swap file is /swapfile. If you wish to change this, simple the file location (file must not exist) add it to the command: ``` -sh swap 4G /mynewswapfile +sh swap 4G /swap ``` - -## Ansible - -Ansible Playbook collection to make things easier and faster - -### Run Playbook - -`ansible-playbook -i '0.0.0.0' ansible-swap/server.yml` - -With the server's IP. - - -### Changes to be made as required - -`ansible-swap/tasks/main.yml` - -1. Change location - location on your server/instance -2. Change Memory to be allocated diff --git a/ansible-swap/server.yml b/ansible-swap/server.yml deleted file mode 100644 index 0dc34ba..0000000 --- a/ansible-swap/server.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- hosts: all - remote_user: ubuntu - sudo: true - roles: - - ansible-swap \ No newline at end of file diff --git a/ansible-swap/tasks/main.yml b/ansible-swap/tasks/main.yml deleted file mode 100644 index 2d203ba..0000000 --- a/ansible-swap/tasks/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: Download Swap File - get_url: url=https://raw.githubusercontent.com/Cretezy/Swap/master/swap.sh dest=/home/ubuntu mode=0440 - -- name: Setup Swap - command: sh swap.sh 2G # Define memory amount you wish to allocate diff --git a/swap.sh b/swap.sh index f45a360..56c1482 100644 --- a/swap.sh +++ b/swap.sh @@ -30,8 +30,8 @@ fi ## Run sudo fallocate -l $SWAP_SIZE $SWAP_PATH # Allocate size -sudo chmod 600 $SWAP_PATH # Make it non-world readable (bad!) -sudo mkswap $SWAP_PATH # Setup swap" +sudo chmod 600 $SWAP_PATH # Set proper permission +sudo mkswap $SWAP_PATH # Setup swap sudo swapon $SWAP_PATH # Enable swap echo "$SWAP_PATH none swap sw 0 0" | sudo tee /etc/fstab -a # Add to fstab