From af0801de3c1b1c51cf1a995c2939e182d2ef4926 Mon Sep 17 00:00:00 2001 From: Philipp Marek Date: Wed, 9 Dec 2015 13:51:56 +0100 Subject: [PATCH] Make logfile symlinks with relative names. Using absolute names for the symlink breaks in quite a few ways; * when creating a tar file of the logs, * when serving via NFS, or any other case where the directory gets transferred to a different machine. So just create the symlink with relative names, then they'll work in any location. Change-Id: I432a69754985fc71feb0068b7adca01066d7bc1b --- functions-common | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/functions-common b/functions-common index d4099ffcfa..0c5e48cadf 100644 --- a/functions-common +++ b/functions-common @@ -1309,10 +1309,11 @@ function _run_process { exec 3>&- exec 6>&- - local real_logfile="${LOGDIR}/${service}.log.${CURRENT_LOG_TIME}" + local logfile="${service}.log.${CURRENT_LOG_TIME}" + local real_logfile="${LOGDIR}/${logfile}" if [[ -n ${LOGDIR} ]]; then exec 1>&"$real_logfile" 2>&1 - ln -sf "$real_logfile" ${LOGDIR}/${service}.log + bash -c "cd '$LOGDIR' && ln -sf '$logfile' ${service}.log" if [[ -n ${SCREEN_LOGDIR} ]]; then # Drop the backward-compat symlink ln -sf "$real_logfile" ${SCREEN_LOGDIR}/screen-${service}.log @@ -1399,7 +1400,8 @@ function screen_process { screen -S $SCREEN_NAME -X screen -t $name - local real_logfile="${LOGDIR}/${name}.log.${CURRENT_LOG_TIME}" + local logfile="${name}.log.${CURRENT_LOG_TIME}" + local real_logfile="${LOGDIR}/${logfile}" echo "LOGDIR: $LOGDIR" echo "SCREEN_LOGDIR: $SCREEN_LOGDIR" echo "log: $real_logfile" @@ -1410,7 +1412,7 @@ function screen_process { fi # If logging isn't active then avoid a broken symlink touch "$real_logfile" - ln -sf "$real_logfile" ${LOGDIR}/${name}.log + bash -c "cd '$LOGDIR' && ln -sf '$logfile' ${name}.log" if [[ -n ${SCREEN_LOGDIR} ]]; then # Drop the backward-compat symlink ln -sf "$real_logfile" ${SCREEN_LOGDIR}/screen-${1}.log