Skip to content

Commit

Permalink
Add Bootstrap Commands
Browse files Browse the repository at this point in the history
  • Loading branch information
piyush-jena committed Aug 12, 2024
1 parent 286ac64 commit 1af1cae
Show file tree
Hide file tree
Showing 18 changed files with 1,119 additions and 106 deletions.
2 changes: 2 additions & 0 deletions packages/os/bootstrap-commands-tmpfiles.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
d /etc/bootstrap-commands 0750 root root -
d /run/bootstrap-commands 0755 root root -
12 changes: 12 additions & 0 deletions packages/os/bootstrap-commands-toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[required-extensions]
bootstrap-commands= "v1"
std = { version = "v1", helpers = ["if_not_null", "join_nested_array"]}
+++
{{#if_not_null settings.bootstrap-commands}}
{{#each settings.bootstrap-commands}}
[bootstrap-commands."{{@key}}"]
commands = [{{join_nested_array this.commands}}]
mode = "{{{this.mode}}}"
essential = {{this.essential}}
{{/each}}
{{/if_not_null}}
18 changes: 18 additions & 0 deletions packages/os/bootstrap-commands.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=Bootstrap Commands
After=settings-applier.service apiserver.service
Requires=settings-applier.service apiserver.service
Before=preconfigured.target
RefuseManualStart=true
RefuseManualStop=true

[Service]
Type=oneshot
# Run the bootstrap commands
ExecStart=/usr/bin/bootstrap-commands
RemainAfterExit=true
StandardError=journal+console
SyslogIdentifier=bootstrap-commands

[Install]
WantedBy=preconfigured.target
25 changes: 22 additions & 3 deletions packages/os/os.spec
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Source17: corndog-toml
Source18: bootstrap-containers-toml
Source19: host-containers-toml
Source20: bottlerocket-fips-checks-metadata-json
Source21: bootstrap-commands-toml

# 1xx sources: systemd units
Source100: apiserver.service
Expand All @@ -52,13 +53,15 @@ Source119: reboot-if-required.service
Source120: warm-pool-wait.service
Source122: has-boot-ever-succeeded.service
Source123: pluto.service
Source124: bootstrap-commands.service

# 2xx sources: tmpfilesd configs
Source200: migration-tmpfiles.conf
Source201: host-containers-tmpfiles.conf
Source202: thar-be-updates-tmpfiles.conf
Source203: bootstrap-containers-tmpfiles.conf
Source204: storewolf-tmpfiles.conf
Source205: bootstrap-commands-tmpfiles.conf

# 3xx sources: udev rules
Source300: ephemeral-storage.rules
Expand Down Expand Up @@ -89,6 +92,7 @@ Requires: %{_cross_os}sundog
Requires: %{_cross_os}xfscli
Requires: %{_cross_os}thar-be-settings

Requires: %{_cross_os}bootstrap-commands
Requires: (%{_cross_os}bootstrap-containers or %{_cross_os}image-feature(no-host-containers))
Requires: (%{_cross_os}host-containers or %{_cross_os}image-feature(no-host-containers))

Expand Down Expand Up @@ -246,6 +250,12 @@ Requires: %{_cross_os}binutils
%description -n %{_cross_os}driverdog
%{summary}.


%package -n %{_cross_os}bootstrap-commands
Summary: Manages bootstrap-commands
%description -n %{_cross_os}bootstrap-commands
%{summary}.

%package -n %{_cross_os}bootstrap-containers
Summary: Manages bootstrap-containers
Requires: %{_cross_os}host-ctr
Expand Down Expand Up @@ -350,6 +360,7 @@ echo "** Output from non-static builds:"
-p metricdog \
-p ghostdog \
-p corndog \
-p bootstrap-commands \
-p bootstrap-containers \
-p prairiedog \
-p certdog \
Expand Down Expand Up @@ -385,7 +396,7 @@ for p in \
storewolf settings-committer \
migrator prairiedog certdog \
signpost updog metricdog logdog \
ghostdog bootstrap-containers \
ghostdog bootstrap-commands bootstrap-containers \
shimpei bloodhound \
bottlerocket-cis-checks \
bottlerocket-fips-checks \
Expand Down Expand Up @@ -473,14 +484,14 @@ if [ -s "%{_cross_repo_root_json}" ] ; then
fi

install -d %{buildroot}%{_cross_templatedir}
install -p -m 0644 %{S:5} %{S:6} %{S:7} %{S:8} %{S:14} %{S:15} %{S:16} %{S:17} %{S:18} %{S:19} \
install -p -m 0644 %{S:5} %{S:6} %{S:7} %{S:8} %{S:14} %{S:15} %{S:16} %{S:17} %{S:18} %{S:19} %{S:21} \
%{buildroot}%{_cross_templatedir}

install -d %{buildroot}%{_cross_unitdir}
install -p -m 0644 \
%{S:100} %{S:102} %{S:103} %{S:105} \
%{S:106} %{S:107} %{S:110} %{S:111} %{S:112} \
%{S:113} %{S:114} %{S:119} %{S:122} %{S:123} \
%{S:113} %{S:114} %{S:119} %{S:122} %{S:123} %{S:124} \
%{buildroot}%{_cross_unitdir}

sed -e 's|PREFIX|%{_cross_prefix}|g' %{S:115} > link-kernel-modules.service
Expand All @@ -502,6 +513,7 @@ install -p -m 0644 %{S:201} %{buildroot}%{_cross_tmpfilesdir}/host-containers.co
install -p -m 0644 %{S:202} %{buildroot}%{_cross_tmpfilesdir}/thar-be-updates.conf
install -p -m 0644 %{S:203} %{buildroot}%{_cross_tmpfilesdir}/bootstrap-containers.conf
install -p -m 0644 %{S:204} %{buildroot}%{_cross_tmpfilesdir}/storewolf.conf
install -p -m 0644 %{S:205} %{buildroot}%{_cross_tmpfilesdir}/bootstrap-commands.conf

install -d %{buildroot}%{_cross_udevrulesdir}
install -p -m 0644 %{S:300} %{buildroot}%{_cross_udevrulesdir}/80-ephemeral-storage.rules
Expand Down Expand Up @@ -640,6 +652,13 @@ install -p -m 0644 %{S:400} %{S:401} %{S:402} %{buildroot}%{_cross_licensedir}
%{_cross_bindir}/certdog
%{_cross_templatedir}/certdog-toml


%files -n %{_cross_os}bootstrap-commands
%{_cross_bindir}/bootstrap-commands
%{_cross_unitdir}/bootstrap-commands.service
%{_cross_tmpfilesdir}/bootstrap-commands.conf
%{_cross_templatedir}/bootstrap-commands-toml

%files -n %{_cross_os}bootstrap-containers
%{_cross_bindir}/bootstrap-containers
%{_cross_unitdir}/[email protected]
Expand Down
Loading

0 comments on commit 1af1cae

Please sign in to comment.