diff --git a/images/linux/scripts/base/apt.sh b/images/linux/scripts/base/apt.sh new file mode 100644 index 00000000..15307421 --- /dev/null +++ b/images/linux/scripts/base/apt.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export DEBIAN_FRONTEND=noninteractive +apt-get -yqq update +apt-get -yqq dist-upgrade +systemctl disable apt-daily.service +systemctl disable apt-daily.timer +systemctl disable apt-daily-upgrade.timer +systemctl disable apt-daily-upgrade.service diff --git a/images/linux/scripts/base/limits.sh b/images/linux/scripts/base/limits.sh new file mode 100644 index 00000000..e3c43e33 --- /dev/null +++ b/images/linux/scripts/base/limits.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo '* soft nofile 65536' >> /etc/security/limits.conf +echo '* hard nofile 65536' >> /etc/security/limits.conf +echo 'session required pam_limits.so' >> /etc/pam.d/common-session +echo 'session required pam_limits.so' >> /etc/pam.d/common-session-noninteractive +echo 'DefaultLimitNOFILE=65536' >> /etc/systemd/system.conf diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index e576bf16..bcd7fa27 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -75,18 +75,12 @@ }, { "type": "shell", - "inline": [ - "apt-get update", - "apt-get dist-upgrade -y", - "systemctl disable apt-daily.service", - "systemctl disable apt-daily.timer", - "systemctl disable apt-daily-upgrade.timer", - "systemctl disable apt-daily-upgrade.service", - "echo '* soft nofile 65536 \n* hard nofile 65536' >> /etc/security/limits.conf", - "echo 'session required pam_limits.so' >> /etc/pam.d/common-session", - "echo 'session required pam_limits.so' >> /etc/pam.d/common-session-noninteractive", - "echo 'DefaultLimitNOFILE=65536' >> /etc/systemd/system.conf" - ], + "script": "{{template_dir}}/scripts/base/apt.sh", + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" + }, + { + "type": "shell", + "script": "{{template_dir}}/scripts/base/limits.sh", "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, { diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 55e9edba..3af30e62 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -78,18 +78,12 @@ }, { "type": "shell", - "inline": [ - "apt-get update", - "apt-get dist-upgrade -y", - "systemctl disable apt-daily.service", - "systemctl disable apt-daily.timer", - "systemctl disable apt-daily-upgrade.timer", - "systemctl disable apt-daily-upgrade.service", - "echo '* soft nofile 65536 \n* hard nofile 65536' >> /etc/security/limits.conf", - "echo 'session required pam_limits.so' >> /etc/pam.d/common-session", - "echo 'session required pam_limits.so' >> /etc/pam.d/common-session-noninteractive", - "echo 'DefaultLimitNOFILE=65536' >> /etc/systemd/system.conf" - ], + "script": "{{template_dir}}/scripts/base/apt.sh", + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" + }, + { + "type": "shell", + "script": "{{template_dir}}/scripts/base/limits.sh", "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, { diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index 489f748f..3112f0c9 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -78,18 +78,12 @@ }, { "type": "shell", - "inline": [ - "apt-get update", - "apt-get dist-upgrade -y", - "systemctl disable apt-daily.service", - "systemctl disable apt-daily.timer", - "systemctl disable apt-daily-upgrade.timer", - "systemctl disable apt-daily-upgrade.service", - "echo '* soft nofile 65536 \n* hard nofile 65536' >> /etc/security/limits.conf", - "echo 'session required pam_limits.so' >> /etc/pam.d/common-session", - "echo 'session required pam_limits.so' >> /etc/pam.d/common-session-noninteractive", - "echo 'DefaultLimitNOFILE=65536' >> /etc/systemd/system.conf" - ], + "script": "{{template_dir}}/scripts/base/apt.sh", + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" + }, + { + "type": "shell", + "script": "{{template_dir}}/scripts/base/limits.sh", "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, {