From 4be1448dab2afdfa3b14a9fc129e2ece9bc5af48 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Wed, 22 Mar 2023 08:01:18 +0100 Subject: [PATCH] Remove swap --- manifests/scriptreceiver.pp | 8 +++++++- templates/scriptreceiver/removeswap.erb.sh | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 templates/scriptreceiver/removeswap.erb.sh diff --git a/manifests/scriptreceiver.pp b/manifests/scriptreceiver.pp index 9187dcc..12e56ac 100644 --- a/manifests/scriptreceiver.pp +++ b/manifests/scriptreceiver.pp @@ -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', 'makeswap', 'backup_multinode_db'] + $tasks = ['list_users', 'list_files_for_user', 'create_bucket', 'backup_db', 'purge_backups', 'maintenancemode', 'restart_sunet_service', 'start_sentinel', 'stop_sentinel', 'removeswap', 'backup_multinode_db'] $environment = sunetdrive::get_environment() $config = hiera_hash($environment) @@ -90,6 +90,12 @@ class sunetdrive::scriptreceiver() minute => '*', hour => '*', } + file { '/home/script/bin/makeswap.sh': + ensure => absent, + } + file { '/etc/sudoers.d/99-makeswap': + ensure => absent, + } $tasks.each |String $task| { file { "/home/script/bin/${task}.sh": ensure => file, diff --git a/templates/scriptreceiver/removeswap.erb.sh b/templates/scriptreceiver/removeswap.erb.sh new file mode 100644 index 0000000..47340fd --- /dev/null +++ b/templates/scriptreceiver/removeswap.erb.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Clean up old swap version +swapoff -a +cryptsetup remove cryptswap1 +sed -i 's_^/dev/mapper/cryptswap1 none swap sw 0 0__' /etc/fstab +sed -i 's_/swapfile none swap sw 0 0__' /etc/fstab +sed -i 's_cryptswap1 /swapfile /dev/urandom swap,offset=1024,cipher=aes-xts-plain64__' /etc/crypttab +rm /swapfile +rm /cryptswap1