2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> sudo-logs.sh"
13 set -eu -o pipefail -o noglob
15 # Copy/Generate 'sudo' log and copy to archive directory
19 fedora|centos|redhat|ubuntu|debian)
20 if ! sudo cp $sudo_log /tmp; then
21 echo "Unable to archive 'sudo' logs ($sudo_log)"
26 # Do I need 'sudo' to run 'journalctl'?
27 journalctl | grep sudo > $sudo_log
29 *) echo "Unexpected 'operatingsystem': $os"
33 sudo_log=$(basename $sudo_log)
34 sudo chown jenkins:jenkins /tmp/$sudo_log
35 chmod 0644 /tmp/$sudo_log
36 mkdir -p $WORKSPACE/archives/sudo
37 mv /tmp/$sudo_log $WORKSPACE/archives/sudo/$sudo_log
41 echo "Archiving 'sudo' log.."
42 os=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
44 fedora|centos|redhat) sudo_log=/var/log/secure ;;
45 ubuntu|debian) sudo_log=/var/log/auth.log ;;
46 suse) sudo_log=/tmp/sudo.log ;;
47 *) echo "Unexpected 'operatingsystem': $os"