diff --git a/elements/base/dib-first-boot b/elements/base/dib-first-boot new file mode 100755 index 000000000..48a5bab9f --- /dev/null +++ b/elements/base/dib-first-boot @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +set -o xtrace + +touch /var/log/first-boot.d.log +chmod 0600 /var/log/first-boot.d.log + +run-parts /etc/first-boot.d >> /var/log/first-boot.d.log 2>&1 +rm -fr /etc/first-boot.d +# delete itself +rm $0 diff --git a/elements/base/finalise.d/01-install-dib-first-boot b/elements/base/finalise.d/01-install-dib-first-boot new file mode 100755 index 000000000..39e544d43 --- /dev/null +++ b/elements/base/finalise.d/01-install-dib-first-boot @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +if [ -d /etc/first-boot.d ]; then + install -m 0755 -o root -g root $(dirname $0)/../dib-first-boot /usr/sbin/ +fi diff --git a/elements/fedora/finalise.d/99-setup-first-boot b/elements/fedora/finalise.d/99-setup-first-boot new file mode 100755 index 000000000..7e7870590 --- /dev/null +++ b/elements/fedora/finalise.d/99-setup-first-boot @@ -0,0 +1,35 @@ +#!/bin/bash +set -e + +if [ -d /etc/first-boot.d ]; then + rc_local=/etc/rc.d/rc.local + + FILE_EXISTED= + if [ -f $rc_local ] + then + FILE_EXISTED=1 + mv $rc_local $rc_local.REAL + fi + + dd of=$rc_local <> $rc_local + else + echo "rm \$0" >> $rc_local + fi + + echo "exit 0" >> $rc_local + + chmod 755 $rc_local + + # Enable the service + systemctl enable rc-local.service +fi diff --git a/elements/ubuntu/finalise.d/99-setup-first-boot b/elements/ubuntu/finalise.d/99-setup-first-boot new file mode 100755 index 000000000..4529d8196 --- /dev/null +++ b/elements/ubuntu/finalise.d/99-setup-first-boot @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +if [ -d /etc/first-boot.d ]; then + rc_local=/etc/rc.local + + mv $rc_local $rc_local.REAL + + dd of=$rc_local <> /var/log/first-boot.d.log 2>&1 -rm -fr /etc/first-boot.d -rm -f /etc/rc.local -if [ -f /etc/rc.local.REAL ] ; then - mv /etc/rc.local.REAL /etc/rc.local -fi -exit 0 -EOF - run_in_target chmod 755 /etc/rc.local fi check_break after-first-boot run_in_target bash }