From b370482d79b8660741667baa80fb4f50f97c9444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com> Date: Tue, 27 Jul 2010 11:23:11 +0200 Subject: [PATCH] Allow ensure-dirs to run partially and skip big file chunks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The startup of the daemons would take a lot of time otherwise, also it's not needed to set the permissions of those file over and over again, because if the daemons are once migrated to the user they will keep creating the file for that user. The full run is intended as initial upgrade Signed-off-by: RenΓ© Nussbaumer <rn@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- daemons/ensure-dirs.in | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/daemons/ensure-dirs.in b/daemons/ensure-dirs.in index aed690a13..252f24af8 100644 --- a/daemons/ensure-dirs.in +++ b/daemons/ensure-dirs.in @@ -74,6 +74,8 @@ _gather_files() { } _ensure_datadir() { + local full_run="$1" + _ensure_dir ${DATADIR} 0755 "$(_fileset_owner masterd)" _ensure_dir ${DATADIR}/queue 0700 "$(_fileset_owner masterd)" _ensure_dir ${DATADIR}/queue/archive 0700 "$(_fileset_owner masterd)" @@ -94,15 +96,17 @@ _ensure_datadir() { touch ${DATADIR}/queue/lock _ensure_file ${DATADIR}/queue/lock 0600 "$(_fileset_owner masterd)" - for file in $(_gather_files ${DATADIR}/queue 0600 @GNTMASTERUSER@ \ - @GNTMASTERDGROUP@); do - _ensure_file "${file}" 0600 "$(_fileset_owner masterd)" - done + if ! [[ -z "${full_run}" ]]; then + for file in $(_gather_files ${DATADIR}/queue 0600 @GNTMASTERUSER@ \ + @GNTMASTERDGROUP@); do + _ensure_file "${file}" 0600 "$(_fileset_owner masterd)" + done - for file in $(_gather_files ${DATADIR} 0600 root \ - @GNTMASTERDGROUP@ -name 'ssconf_*'); do - _ensure_file "${file}" 0444 "$(_fileset_owner noded)" - done + for file in $(_gather_files ${DATADIR} 0600 root \ + @GNTMASTERDGROUP@ -name 'ssconf_*'); do + _ensure_file "${file}" 0444 "$(_fileset_owner noded)" + done + fi } _ensure_rundir() { @@ -143,7 +147,15 @@ _operate_while_hold() { } main() { - _operate_while_hold "_ensure_datadir" ${DATADIR} + local full_run + + while getopts "f" OPTION; do + case ${OPTION} in + f) full_run=1 ;; + esac + done + + _operate_while_hold "_ensure_datadir" ${DATADIR} ${full_run} _operate_while_hold "_ensure_rundir" ${RUNDIR} _operate_while_hold "_ensure_logdir" ${LOGDIR} _operate_while_hold "_ensure_lockdir" @LOCALSTATEDIR@ -- GitLab