Files
VPS-scripts_Web-V2/CoreModules/generic/preconf.sh
2020-03-11 13:10:30 +01:00

35 lines
1.0 KiB
Bash

##------------##
# System #
##------------##
hostnamectl set-hostname $hostname
sed -i 's/;preserve_hostname: false/preserve_hostname: true/g' /etc/cloud/cloud.cfg
timedatectl set-timezone Europe/Amsterdam
##----------##
# Swap #
##----------##
if free | awk '/^Swap:/ {exit !$2}'; then
echo "swap enabled"
else
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile swap swap defaults 0 0' >> /etc/fstab
fi
sed -i 's/#/vm.swappiness=10/g' /etc/sysctl.conf
sed -i 's/#/vm.vfs_cache_pressure=50/g' /etc/sysctl.conf
##-------------##
# Postfix #
##-------------##
#cheking if postfix already was installed by the system and if yes it wil be removed to prevent config conflicts
if dpkg-query -Wf'${db:Status-abbrev}' postfix 2>/dev/null | grep -q '^i'; then apt purge -y postfix; fi
debconf-set-selections <<< "postfix postfix/mailname string $domain"
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"