Makeswap script

This commit is contained in:
Micke Nordin 2023-02-14 12:07:43 +01:00
parent d4c557b290
commit a1ce98a14d
Signed by untrusted user: Micke
GPG key ID: 0DA0A7A5708FE257
2 changed files with 13 additions and 1 deletions

View file

@ -4,7 +4,7 @@ class sunetdrive::scriptreceiver()
sunet::system_user {'script': username => 'script', group => 'script', managehome => true, shell => '/bin/bash' }
# These tasks correspond to a ${task}.erb.sh template
$tasks = ['list_users', 'list_files_for_user', 'create_bucket', 'backup_db', 'purge_backups', 'maintenancemode', 'restart_sunet_service', 'start_sentinel', 'stop_sentinel']
$tasks = ['list_users', 'list_files_for_user', 'create_bucket', 'backup_db', 'purge_backups', 'maintenancemode', 'restart_sunet_service', 'start_sentinel', 'stop_sentinel', 'makeswap']
$environment = sunetdrive::get_environment()
$config = hiera_hash($environment)

View file

@ -0,0 +1,12 @@
#!/bin/bash
if ! [[ -f /swapfile ]]; then
gb=$(free --gibi| grep Mem: | awk '{print $2}')
fallocate -l "${gb}G" /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
if ! grep -E '^(#)?/swapfile' /etc/fstab; then
echo '/swapfile none swap sw 0 0' >> /etc/fstab
fi
fi