Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Chakra-helper v1.1
- # ---------------------------------------------------------------------------- #
- # "THE BEER-WARE LICENSE" (Revision 42): #
- # konwhald@hotmail.fr wrote this file. As long as you retain this notice you #
- # can do whatever you want with this stuff. If we meet some day, and you think #
- # this stuff is worth it, you can buy me a beer in return. Konwhald #
- # ---------------------------------------------------------------------------- #
- # This script is intended to help the users of Chakra to help each other
- # It just collect needed informations for support and the output of a command
- # No terminal needed here, just kdialog
- ### Defaults ###
- TITLE="Chakra report helper" # Title of kdialog windows
- TMPFILE=$(mktemp) # Temporary file
- LC_ALL=C # Ouput of commands in english
- PACMANCONF=/etc/pacman.conf # Pacman file
- ICON="/usr/share/icons/oxygen/scalable/places/start-here-branding.svg"
- ### Functions ###
- main()
- {
- # Get buggy command from user
- COMMAND="$( \
- kdialog \
- --title "$TITLE" \
- --inputbox "Command to run ?" "" \
- --icon "$ICON" \
- )" #End of COMMAND
- # Start TMPFILE with a little nice text
- cat << EOF >> $TMPFILE
- ================================================================
- This text contains the ouput of "$COMMAND". Copy-paste it to http://paste.chakra-project.org/
- Do not forget to explain precisely your problem on a new subject on the forum ;)
- ================================================================
- System informations:
- EOF
- # Collect content of uname -a
- uname -a >> $TMPFILE
- # Check if user has testing enabled
- # If there is a commented line with testing in it, OR if there is no testing. Then it's disabled.
- # Else, testing is there. You can easily troll the script, i know.
- if (cat $PACMANCONF | grep "^#" | grep "testing" >/dev/null) \
- || ! ( cat $PACMANCONF | grep "testing" >/dev/null)
- then TESTING=disabled
- else TESTING=enabled
- fi
- # Check if user has unstable enabled
- # Same shit as before
- if (cat $PACMANCONF | grep "^#" | grep "unstable" >/dev/null) \
- || ! ( cat $PACMANCONF | grep "unstable" >/dev/null)
- then UNSTABLE=disabled
- else UNSTABLE=enabled
- fi
- # Unstable repo is unstable.
- echo "Testing repo is $TESTING" >> $TMPFILE
- echo "Unstable repo is $UNSTABLE" >> $TMPFILE
- # Get possible package name and repo
- #echo "Package name from the command:" >> $TMPFILE
- #pacman -Ss "${COMMAND%%" "*}" >> $TMPFILE
- # Run the given buggy command
- echo "================================================================" >> $TMPFILE
- echo "\$ \"$COMMAND\" #(may be huge):" >> $TMPFILE
- eval $COMMAND >> $TMPFILE 2>> $TMPFILE
- # End the textbox nicely
- echo "
- Well, that was a huge output.
- ================================================================" >> $TMPFILE
- # If the tool "chakra-paste" is installed
- if which chakra-paste
- then
- # Then use it to paste the report directly
- URL="$(chakra-paste "$TMPFILE")"
- kdialog \
- --title "$TITLE" \
- --msgbox "The report is at the following URL: $URL (And a copy here: $TMPFILE).
- Create a new subject on the forum, explain your problem, and paste this URL there" \
- --icon "$ICON"
- echo "Closed the window too fast? The URL is here: $URL" >> $TMPFILE
- else
- # Else warn chakra-paste is not installed
- kdialog \
- --title "$TITLE" \
- --error "\"chakra-paste\" is not installed on your system.
- You'll have to paste the report on paste.chakra-project.org" \
- --icon "$ICON"
- # Display the whole report
- kdialog \
- --title "$TITLE" \
- --textbox "$TMPFILE" 590 330 \
- --icon "$ICON"
- fi
- } #End of main function
- ### Run! ###
- if [ "$1" = --help ] || [ "$1" = -h ]
- then
- echo " Chakra-helper, v1.1"
- echo "Automagically generate a report for support purpose"
- echo "Made by Konwhald for the Chakra Project"
- else main $*
- fi
- # Shit, i lost my credit card number somewhere in the code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement