nix formating, sops secrets migration, vps-init auto update
This commit is contained in:
parent
db022df80b
commit
fcee389f8e
17 changed files with 950 additions and 818 deletions
|
|
@ -1,7 +1,6 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
{ config, pkgs, ... }: {
|
||||
sops = {
|
||||
secrets.awg0-spec = {};
|
||||
secrets.awg0-spec = { };
|
||||
templates.awg0-conf.content = ''
|
||||
${config.sops.placeholder.awg-obf}
|
||||
${config.sops.placeholder.awg0-spec}
|
||||
|
|
@ -9,10 +8,9 @@
|
|||
};
|
||||
systemd.services.vps-init = {
|
||||
path = [ pkgs.openssh ];
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = ''
|
||||
cd /root/run/awg
|
||||
date +%s > start-time
|
||||
cd /root/run
|
||||
date +%s > awg-start-time
|
||||
. vps-init.env
|
||||
scp -i /root/.ssh/vps ${config.sops.templates.awg0-conf.path} $SSHCONN:awg0.conf
|
||||
until cat <<'EOF' | ssh -i /root/.ssh/vps $SSHCONN
|
||||
|
|
@ -26,18 +24,30 @@
|
|||
FILENAME="$(mktemp)"
|
||||
(echo PasswordAuthentication no; cat sshd_config) > "$FILENAME"
|
||||
mv "$FILENAME" sshd_config
|
||||
fallocate -l 1GiB /var/swapfile
|
||||
chmod 600 /var/swapfile
|
||||
mkswap /var/swapfile
|
||||
echo "/var/swapfile none swap defaults 0 0" >> /etc/fstab
|
||||
SIZE="$(awk '/MemTotal:/ { print $2 "KiB" }' /proc/meminfo)"
|
||||
fallocate -l $SIZE /swapfile
|
||||
chmod 600 /swapfile
|
||||
mkswap /swapfile
|
||||
echo "/swapfile none swap defaults 0 0" >> /etc/fstab
|
||||
cd /etc/apt/apt.conf.d
|
||||
cat <<' EOF' > 99policy
|
||||
Dpkg::Options { "--force-confnew"; };
|
||||
Unattended-Upgrade::Automatic-Reboot "true";
|
||||
Unattended-Upgrade::Remove-Unused-Dependencies "true";
|
||||
EOF
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get install -y unattended-upgrades
|
||||
cat <<' EOF' > 20auto-upgrades
|
||||
APT::Periodic::Unattended-Upgrade "1";
|
||||
APT::Periodic::Update-Package-Lists "1";
|
||||
EOF
|
||||
apt-get update
|
||||
apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold";;
|
||||
apt-get dist-upgrade -y;;
|
||||
1)
|
||||
cat <<' EOF' >> /etc/sysctl.conf
|
||||
net.ipv6.conf.all.forwarding = 1
|
||||
net.ipv4.ip_forward = 1
|
||||
net.ipv4.conf.all.forwarding = 1
|
||||
net.ipv4.ip_forward = 1
|
||||
net.ipv6.conf.all.forwarding = 1
|
||||
EOF
|
||||
for v in 6 ""; do
|
||||
ip''${v}tables -P FORWARD DROP
|
||||
|
|
@ -83,7 +93,8 @@
|
|||
exit 1
|
||||
EOF
|
||||
do sleep 1; done
|
||||
echo Installed in $(($(date +%s)-$(cat start-time)))s
|
||||
echo Installed in $(($(date +%s)-$(cat awg-start-time)))s
|
||||
'';
|
||||
serviceConfig.Type = "oneshot";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue