refactor(build_library): Add a function for enabling systemd units.

This commit is contained in:
Michael Marineau 2014-05-17 11:14:37 -07:00
parent 38fa0f92a8
commit a93cb921d8
2 changed files with 14 additions and 3 deletions

View File

@ -104,6 +104,19 @@ emerge_to_image() {
sudo -E ROOT="${root_fs_dir}" env-update
}
# Usage: systemd_enable /root default.target something.service
# Or: systemd_enable /root default.target some@.service some@thing.service
systemd_enable() {
local root_fs_dir="$1"
local target="$2"
local unit_file="$3"
local unit_alias="${4:-$3}"
local wants_dir="${root_fs_dir}/usr/lib/systemd/system/${target}.wants"
sudo mkdir -p "${wants_dir}"
sudo ln -sf "../${unit_file}" "${wants_dir}/${unit_alias}"
}
start_image() {
local image_name="$1"
local disk_layout="$2"

View File

@ -94,9 +94,7 @@ EOF
# Remount the system partition read-write by default.
# The remount services are provided by coreos-base/coreos-init
local fs_wants="${root_fs_dir}/usr/lib/systemd/system/local-fs.target.wants"
sudo mkdir -p "${fs_wants}"
sudo ln -s ../remount-usr.service "${fs_wants}"
systemd_enable "${root_fs_dir}" "local-fs.target" "remount-usr.service"
finish_image "${disk_layout}" "${root_fs_dir}" "${update_group}"
}