Skip to content

Commit

Permalink
add missing service scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
xorel committed Nov 10, 2023
1 parent 18cefb0 commit 0337ad0
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packer/service_OneKE/82-configure-context.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

# Configures and enables service context.

policy_rc_d_disable() (echo "exit 101" >/usr/sbin/policy-rc.d && chmod a+x /usr/sbin/policy-rc.d)
policy_rc_d_enable() (echo "exit 0" >/usr/sbin/policy-rc.d && chmod a+x /usr/sbin/policy-rc.d)

exec 1>&2
set -o errexit -o nounset -o pipefail
set -x

policy_rc_d_disable

apt-get install -y apparmor tzdata

mv /etc/one-appliance/net-90 /etc/one-context.d/net-90-service-appliance
mv /etc/one-appliance/net-99 /etc/one-context.d/net-99-report-ready

chown root:root /etc/one-context.d/*
chmod u=rwx,go=rx /etc/one-context.d/*

policy_rc_d_enable

sync
27 changes: 27 additions & 0 deletions packer/service_OneKE/83-disable-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

# Removes man pages and share/doc data, then prevents
# from re-populating.

exec 1>&2
set -o errexit -o nounset -o pipefail
set -x

install -o 0 -g 0 -m u=rw,go=r -D /dev/fd/0 /etc/dpkg/dpkg.cfg.d/excludes <<'EOF'
path-exclude=/usr/share/man/*
path-exclude=/usr/share/locale/*/LC_MESSAGES/*.mo
path-exclude=/usr/share/doc/*
path-include=/usr/share/doc/*/copyright
path-include=/usr/share/doc/*/changelog.Debian.*
EOF

rm -rf /usr/share/man/* ||:
rm -f /usr/share/locale/*/LC_MESSAGES/*.mo ||:

TMP_DIR=$(mktemp -d) && cd "$TMP_DIR/"
mv -f /usr/share/doc/* . ||:
cp -rf --parents */copyright /usr/share/doc/ ||:
cp -rf --parents */changelog.Debian.* /usr/share/doc/ ||:
cd ../ && rm -rf "$TMP_DIR/"

sync
7 changes: 7 additions & 0 deletions packer/service_OneKE/OneKE.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ build {
]
}

provisioner "shell" {
scripts = [
"${var.input_dir}/82-configure-context.sh",
"83-disable-docs.sh"
]
}

post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
Expand Down
19 changes: 19 additions & 0 deletions packer/service_vnf/82-configure-context.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# Configures and enables service context.

exec 1>&2
set -o errexit -o nounset -o pipefail
set -x

printf '#!/bin/sh\n\ntrue\n' > /etc/one-context.d/loc-12-firewall
printf '#!/bin/sh\n\ntrue\n' > /etc/one-context.d/loc-15-ip_forward
printf '#!/bin/sh\n\ntrue\n' > /etc/one-context.d/loc-15-keepalived

mv /etc/one-appliance/net-90 /etc/one-context.d/net-90-service-appliance
mv /etc/one-appliance/net-99 /etc/one-context.d/net-99-report-ready

chown root:root /etc/one-context.d/*
chmod u=rwx,go=rx /etc/one-context.d/*

sync
4 changes: 4 additions & 0 deletions packer/service_vnf/vnf.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ build {
]
}

provisioner "shell" {
scripts = [ "${var.input_dir}/82-configure-context.sh" ]
}

post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
Expand Down
15 changes: 15 additions & 0 deletions packer/service_wordpress/82-configure-context.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# Configures and enables service context.

exec 1>&2
set -o errexit -o nounset -o pipefail
set -x

mv /etc/one-appliance/net-90 /etc/one-context.d/net-90-service-appliance
mv /etc/one-appliance/net-99 /etc/one-context.d/net-99-report-ready

chown root:root /etc/one-context.d/*
chmod u=rwx,go=rx /etc/one-context.d/*

sync
4 changes: 4 additions & 0 deletions packer/service_wordpress/wordpress.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ build {
]
}

provisioner "shell" {
scripts = [ "${var.input_dir}/82-configure-context.sh" ]
}

post-processor "shell-local" {
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
environment_vars = [
Expand Down

0 comments on commit 0337ad0

Please sign in to comment.