Skip to content

Commit

Permalink
Stop the container when configuring or upgrading IPA fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
adelton committed Dec 14, 2015
1 parent d48eb5a commit bf768d9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ RUN echo LANG=C > /etc/locale.conf
RUN for i in swap.target local-fs.target rhel-autorelabel-mark.service systemd-update-done.service rpcbind.socket rhel-dmesg.service systemd-user-sessions.service network.service rhsmcertd.service proc-fs-nfsd.mount nfs-config.service nfs-client.target systemd-hwdb-update.service ldconfig.service slices.target dnf-makecache.service dnf-makecache.timer fedora-autorelabel-mark.service named.service ; do rm -f /usr/lib/systemd/system/$i ; ln -s /dev/null /usr/lib/systemd/system/$i ; done
RUN /sbin/ldconfig -X

COPY init-data ipa-server-configure-first ipa-volume-upgrade-* /usr/sbin/
RUN chmod -v +x /usr/sbin/init-data /usr/sbin/ipa-server-configure-first /usr/sbin/ipa-volume-upgrade-*
COPY init-data ipa-server-configure-first exit-with-status ipa-volume-upgrade-* /usr/sbin/
RUN chmod -v +x /usr/sbin/init-data /usr/sbin/ipa-server-configure-first /usr/sbin/exit-with-status /usr/sbin/ipa-volume-upgrade-*
COPY ipa-server-configure-first.service ipa-server-upgrade.service ipa-server-update-self-ip-address.service /usr/lib/systemd/system/
RUN systemctl enable ipa-server-configure-first.service
RUN mkdir -p /usr/lib/systemd/system/systemd-poweroff.service.d && ( echo '[Service]' ; echo 'ExecStartPre=/usr/bin/systemctl switch-root /usr /sbin/exit-with-status' ) > /usr/lib/systemd/system/systemd-poweroff.service.d/exit-via-chroot.conf

RUN groupadd -g 389 dirsrv ; useradd -u 389 -g 389 -c 'DS System User' -d '/var/lib/dirsrv' --no-create-home -s '/sbin/nologin' dirsrv
RUN groupadd -g 288 kdcproxy ; useradd -u 288 -g 288 -c 'IPA KDC Proxy User' -d '/var/lib/kdcproxy' -s '/sbin/nologin' kdcproxy
Expand Down
4 changes: 4 additions & 0 deletions exit-with-status
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

exit_code=$( cat /run/ipa/exit_code )
exit $exit_code
8 changes: 8 additions & 0 deletions ipa-server-configure-first
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

mark_exit_code () {
exit_code=$?
echo $exit_code > /run/ipa/exit_code
exit $exit_code
}
mkdir -p /run/ipa
trap mark_exit_code ERR EXIT

set -e

if ! [ -t /dev/stdout ] ; then
Expand Down
1 change: 1 addition & 0 deletions ipa-server-configure-first.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Description=Configure IPA server upon the first start
[Service]
Type=oneshot
ExecStart=/usr/sbin/ipa-server-configure-first
FailureAction=poweroff

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions ipa-server-upgrade.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Before=ipa.service
[Service]
Type=oneshot
ExecStart=/usr/sbin/ipa-server-configure-first upgrade
FailureAction=poweroff

[Install]
WantedBy=multi-user.target

0 comments on commit bf768d9

Please sign in to comment.