summaryrefslogtreecommitdiff
path: root/debian/bugscript
diff options
context:
space:
mode:
authormartin f. krafft <madduck@debian.org>2009-05-05 10:51:37 +0200
committermartin f. krafft <madduck@debian.org>2009-05-05 11:38:16 +0200
commit0bcce4d3bb7c9c2b68f937411d55aa22736f90f5 (patch)
tree27a40f3ad37ec4b41ec8fc5c7b0e22e5bc607a57 /debian/bugscript
parent93eecf12c706c1c01f1d0a8c45c20639ca8afe3f (diff)
Enhance bugscript to optionally run as root
Signed-off-by: martin f. krafft <madduck@debian.org>
Diffstat (limited to 'debian/bugscript')
-rwxr-xr-xdebian/bugscript47
1 files changed, 47 insertions, 0 deletions
diff --git a/debian/bugscript b/debian/bugscript
index 4fb920c2..7ecd2ccc 100755
--- a/debian/bugscript
+++ b/debian/bugscript
@@ -28,6 +28,53 @@ if ! command -v yesno >/dev/null; then
exec 3>&1
fi
+if [ $(id -u) != 0 ]; then
+ if [ -x "$(command -v sudo)" ]; then
+ yesno "Gather system information as root using sudo? (Y/n) " yep
+ if [ "$REPLY" = yep ]; then
+ echo running sudo "$0" "$@"...
+ sudo "$0" "$@" && exit 0
+ echo "sudo invocation failed, trying /bin/su..."
+ fi
+ fi
+
+ yesno "Gather system information as root using su? (Y/n) " yep
+ if [ "$REPLY" = yep ]; then
+ ARGS=
+ for i in "$@"; do ARGS="${ARGS:+$ARGS }'$1'"; shift; done
+ echo "running su root -s '/bin/sh -c $0 $ARGS'..."
+ su root -s /bin/sh -c "$0 $ARGS" && exit 0
+ unset ARGS
+ echo "su invocation failed."
+ fi
+
+ # arrive here only if neither sudo nor su worked:
+ yesno "Will you provide system information in the bug report yourself? (N/y) " nop
+ if [ "$REPLY" = yep ]; then
+ cat <<_eof >&3
+
+IMPORTANT:
+ please do not forget to include all relevant system information with this
+ bug report. You could run
+ /usr/share/bug/mdadm/script 3>&1
+ as root and attach or include the output.
+
+_eof
+ exit 0
+ fi
+
+ # try our best
+ cat <<_eof >&3
+
+WARNING:
+ the following output was not generated by the root user. If you can, please
+ replace the following up until "-- System Information:" with the output of
+ /usr/share/bug/mdadm/script 3>&1
+ run as root. Thanks!
+
+_eof
+fi
+
if [ ! -r /proc/mdstat ]; then
echo "The local system does not have MD (RAID) support: no drivers loaded."
echo "Without MD support, I cannot collect as much information as I'd like."