60 lines
2.0 KiB
Bash
60 lines
2.0 KiB
Bash
##-----------------------##
|
|
# Prerequisite packages #
|
|
##-----------------------##
|
|
|
|
curl --retry 7 --retry-delay 5 -s https://git.ictmaatwerk.com/VPS-scripts/General/raw/branch/Main/Setup-Repo.sh |repo=init osrel=$shortdist bash
|
|
|
|
##--------------##
|
|
# Repositories #
|
|
##--------------##
|
|
|
|
curl --retry 7 --retry-delay 5 -s https://git.ictmaatwerk.com/VPS-scripts/General/raw/branch/Main/Setup-Repo.sh |repo=universe osrel=$shortdist bash
|
|
curl --retry 7 --retry-delay 5 -s https://git.ictmaatwerk.com/VPS-scripts/General/raw/branch/Main/Setup-Repo.sh |repo=php osrel=$shortdist bash
|
|
curl --retry 7 --retry-delay 5 -s https://git.ictmaatwerk.com/VPS-scripts/General/raw/branch/Main/Setup-Repo.sh |repo=certbot osrel=$shortdist bash
|
|
|
|
|
|
##-------------##
|
|
# Updates #
|
|
##-------------##
|
|
|
|
debconf-set-selections <<< 'libssl1.1:amd64 libraries/restart-without-asking boolean true'
|
|
$PKGM update
|
|
$PKGM upgrade -y
|
|
|
|
|
|
##------------##
|
|
# System #
|
|
##------------##
|
|
|
|
hostnamectl set-hostname $hostname
|
|
sed -i 's/;preserve_hostname: false/preserve_hostname: true/g' /etc/cloud/cloud.cfg
|
|
timedatectl set-timezone Europe/Amsterdam
|
|
sed -i -e '/Port 22/c\Port 4242' -e 's/PermitRootLogin yes/PermitRootLogin prohibit-password/g' /etc/ssh/sshd_config
|
|
|
|
|
|
##----------##
|
|
# Swap #
|
|
##----------##
|
|
|
|
if free | awk '/^Swap:/ {exit !$2}'; then
|
|
echo "" > $OUTPUT 2>&1
|
|
else
|
|
fallocate -l 1G /swapfile
|
|
chmod 600 /swapfile
|
|
mkswap /swapfile
|
|
swapon /swapfile
|
|
echo '/swapfile swap swap defaults 0 0' >> /etc/fstab
|
|
fi
|
|
echo "vm.swappiness=10" >> /etc/sysctl.conf
|
|
echo "vm.vfs_cache_pressure=50" >> /etc/sysctl.conf
|
|
|
|
|
|
##-------------##
|
|
# Postfix #
|
|
##-------------##
|
|
|
|
#Checking if postfix exists on this system and if so 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 > $OUTPUT 2>&1; fi
|
|
|
|
debconf-set-selections <<< "postfix postfix/mailname string $domain"
|
|
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'" |