Allow only directories as arguments to -L
This commit is contained in:
parent
bb149fbb27
commit
5a816df980
2 changed files with 19 additions and 19 deletions
31
autobuildd
31
autobuildd
|
@ -1111,10 +1111,9 @@ function display_help() {
|
|||
echo ""
|
||||
echo " -L"
|
||||
echo " --log"
|
||||
echo " Write output to a provided file/directory instead of standard output"
|
||||
echo " If the argument is a directory, create a new file with the name of the Job ID"
|
||||
echo " e.g.: -L /tmp/some.log"
|
||||
echo " or: -L /tmp"
|
||||
echo " Write output to a provided directory instead of standard output"
|
||||
echo " e.g.: -L /tmp"
|
||||
echo " Autobuild will output to /tmp/job-id.log"
|
||||
echo "Example:"
|
||||
echo " autobuild -12g -d default -p liesel -p bookthief -p polonius"
|
||||
echo " autobuild --i386 --arm64 --debian-repo default --github-page --package liesel --package bookthief --package polonius"
|
||||
|
@ -1229,21 +1228,23 @@ while true; do
|
|||
-l | --list )
|
||||
just_list_packages=true; shift ;;
|
||||
-L | --log )
|
||||
# Open the provided log file and redirect all of our output to it
|
||||
## First make sure we can actually write to the file
|
||||
# Open a log file in the given directory and redirect all of our output to it
|
||||
## First make sure we can actually write there
|
||||
provided_log_file="$2"
|
||||
|
||||
if [[ -d "$provided_log_file" ]]; then
|
||||
provided_log_file="$provided_log_file/$this_job_id.log"
|
||||
if [[ ! -d "$provided_log_file" ]]; then
|
||||
echo "Error: Argument is not a directory: '$provided_log_file'"
|
||||
graceful_exit 1
|
||||
elif [[ ! -w "$provided_log_file" ]]; then
|
||||
echo "Error: Autobuild does not have write permissions to '$provided_log_file'"
|
||||
graceful_exit 1
|
||||
fi
|
||||
|
||||
if [[ -w "$(dirname "$provided_log_file")" ]]; then
|
||||
exec >>"$provided_log_file"
|
||||
echo "PID: $$"
|
||||
echo "JOBID: $this_job_id"
|
||||
else
|
||||
echo "Error: $(whoami) user does not have write permissions to '$(dirname "$provided_log_file")'"
|
||||
fi
|
||||
provided_log_file="$provided_log_file/$this_job_id.log"
|
||||
|
||||
exec >>"$provided_log_file"
|
||||
echo "PID: $$"
|
||||
echo "JOBID: $this_job_id"
|
||||
shift 2 ;;
|
||||
-n | --no-upgrade )
|
||||
upgrading_vms=false
|
||||
|
|
|
@ -39,10 +39,9 @@ The configuration file can be found at /var/autobuild/config.toml. This file may
|
|||
|
||||
-L, \--log
|
||||
|
||||
Write output to a specified log file/directory instead of
|
||||
to the terminal.
|
||||
If the argument is a directory, create a new file with the
|
||||
name of the Job ID.
|
||||
Write output to a specified log directory instead of to the
|
||||
terminal.
|
||||
Autobuild will create a file in that directory called {JOB-ID}.log
|
||||
|
||||
-r, \--remove-old-builds
|
||||
|
||||
|
|
Loading…
Reference in a new issue