SHARE
TWEET

Chakra-helper-1.1

Konwhald Jan 8th, 2014 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # Chakra-helper v1.1
  3.  
  4. # ----------------------------------------------------------------------------  #
  5. # "THE BEER-WARE LICENSE" (Revision 42):                                        #
  6. # konwhald@hotmail.fr wrote this file. As long as you retain this notice you    #
  7. # can do whatever you want with this stuff. If we meet some day, and you think  #
  8. # this stuff is worth it, you can buy me a beer in return. Konwhald             #
  9. # ----------------------------------------------------------------------------  #
  10.  
  11.  
  12. # This script is intended to help the users of Chakra to help each other
  13. # It just collect needed informations for support and the output of a command
  14. # No terminal needed here, just kdialog
  15.  
  16.  
  17.  
  18. ### Defaults ###
  19.  
  20. TITLE="Chakra report helper"    # Title of kdialog windows
  21. TMPFILE=$(mktemp)               # Temporary file
  22. LC_ALL=C                        # Ouput of commands in english
  23. PACMANCONF=/etc/pacman.conf     # Pacman file
  24.  
  25. ICON="/usr/share/icons/oxygen/scalable/places/start-here-branding.svg"
  26.  
  27.  
  28.  
  29.  
  30. ### Functions ###
  31.  
  32. main()
  33. {
  34.  
  35. # Get buggy command from user
  36. COMMAND="$( \
  37. kdialog \
  38.         --title "$TITLE" \
  39.         --inputbox "Command to run ?" "" \
  40.         --icon "$ICON" \
  41. )" #End of COMMAND
  42.  
  43.  
  44.  
  45. # Start TMPFILE with a little nice text
  46. cat << EOF >> $TMPFILE
  47. ================================================================
  48.  This text contains the ouput of "$COMMAND". Copy-paste it to http://paste.chakra-project.org/
  49. Do not forget to explain precisely your problem on a new subject on the forum ;)
  50. ================================================================
  51. System informations:
  52. EOF
  53.  
  54.  
  55.  
  56. # Collect content of uname -a
  57. uname -a >> $TMPFILE
  58.  
  59.  
  60.  
  61. # Check if user has testing enabled
  62. # If there is a commented line with testing in it, OR if there is no testing. Then it's disabled.
  63. # Else, testing is there. You can easily troll the script, i know.
  64. if (cat $PACMANCONF | grep "^#" | grep "testing" >/dev/null) \
  65. || ! ( cat $PACMANCONF | grep "testing" >/dev/null)
  66. then TESTING=disabled
  67. else TESTING=enabled
  68. fi
  69.  
  70.  
  71.  
  72. # Check if user has unstable enabled
  73. # Same shit as before
  74. if (cat $PACMANCONF | grep "^#" | grep "unstable" >/dev/null) \
  75. || ! ( cat $PACMANCONF | grep "unstable" >/dev/null)
  76. then UNSTABLE=disabled
  77. else UNSTABLE=enabled
  78. fi
  79.  
  80.  
  81.  
  82. # Unstable repo is unstable.
  83. echo "Testing repo is $TESTING" >> $TMPFILE
  84. echo "Unstable repo is $UNSTABLE" >> $TMPFILE
  85.  
  86.  
  87.  
  88. # Get possible package name and repo
  89. #echo "Package name from the command:" >> $TMPFILE
  90. #pacman -Ss "${COMMAND%%" "*}" >> $TMPFILE
  91.  
  92.  
  93.  
  94. # Run the given buggy command
  95. echo "================================================================" >> $TMPFILE
  96. echo "\$ \"$COMMAND\" #(may be huge):" >> $TMPFILE
  97. eval $COMMAND >> $TMPFILE 2>> $TMPFILE
  98.  
  99.  
  100.  
  101. # End the textbox nicely
  102. echo "
  103. Well, that was a huge output.
  104. ================================================================" >> $TMPFILE
  105.  
  106.  
  107.  
  108. # If the tool "chakra-paste" is installed
  109. if which chakra-paste
  110. then
  111.  
  112. # Then use it to paste the report directly
  113. URL="$(chakra-paste "$TMPFILE")"
  114.  
  115. kdialog \
  116.         --title "$TITLE" \
  117.         --msgbox "The report is at the following URL: $URL (And a copy here: $TMPFILE).
  118. Create a new subject on the forum, explain your problem, and paste this URL there" \
  119.         --icon "$ICON"
  120.  
  121. echo "Closed the window too fast? The URL is here: $URL" >> $TMPFILE
  122.  
  123.  
  124.  
  125. else
  126. # Else warn chakra-paste is not installed
  127. kdialog \
  128.         --title "$TITLE" \
  129.         --error "\"chakra-paste\" is not installed on your system.
  130. You'll have to paste the report on paste.chakra-project.org" \
  131.         --icon "$ICON"
  132.  
  133. # Display the whole report
  134. kdialog \
  135.         --title "$TITLE" \
  136.         --textbox "$TMPFILE" 590 330 \
  137.         --icon "$ICON"
  138.  
  139.  
  140. fi
  141. } #End of main function
  142.  
  143.  
  144.  
  145.  
  146. ### Run! ###
  147.  
  148. if [ "$1" = --help ] || [ "$1" = -h ]
  149. then
  150.         echo " Chakra-helper, v1.1"
  151.         echo "Automagically generate a report for support purpose"
  152.         echo "Made by Konwhald for the Chakra Project"
  153.  
  154. else main $*
  155. fi
  156.  
  157.  
  158.  
  159. # Shit, i lost my credit card number somewhere in the code
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top