Updated hint
[linux_from_scratch_hints.git] / MAINTAINER / submitHint
blob92a45e9730fc38bb574ae8943e4dca42fba9c32f
1 #!/bin/bash -x
3 # Script to verify hint format and to submit it via local mail command.
4 # Needs checkHint script available from the Hints website.
5 #
6 # Script depends on the presences of the following executables that
7 # are not included in a standard LFS installation.
8 # mail
9 # which
11 # Script created by Jim Gifford
12 # Based on script by Oliver Pérès
13 # Modified by Tushar Teredesai
15 ## Configuration params
16 # Your name
17 submitter=""
18 # Your e-mail address
19 email=""
20 # Whether to submit the hint
21 SUBMIT_HINT="disabled"
22 # Whether to compress hint before submission
23 COMPRESS="disabled"
24 # Hints submission address
25 hints="hints@linuxfromscratch.org"
26 # Mail program to use
27 mailprog="mail"
28 compressprog="bzip2"
29 compressext="bz2"
31 # Sanity checks
32 HINT_FILE="$1"
33 if [ "$HINT_FILE" == "" ]
34 then
35 echo "`basename $0` hint-file"
36 exit 1
38 if [ "$submitter" = "" ] || [ "$email" = "" ]
39 then
40 echo "Please edit $0 before executing"
41 exit 1
44 MAIL_FILE="`mktemp`"
45 mailbin="`which $mailprog 2>/dev/null`"
46 compressbin="`which $compressprog 2>/dev/null`"
48 ERROR=""
50 # Subroutines
52 YESNO ()
54 INPUT="$1"
55 echo -n "$INPUT -=>"
56 RETURN="0"
57 read input
58 if [ "$input" == "YES" ] || [ "$input" == "yes" ] || [ "$input" == "Y" ] || [ "$input" == "y" ]
59 then
60 OK="YES"
61 RETURN="1"
63 if [ "$input" == "NO" ] || [ "$input" == "no" ] || [ "$input" == "N" ] || [ "$input" == "n" ]
64 then
65 OK="NO"
66 RETURN="1"
68 if [ "$RETURN" == "0" ]
69 then
70 YESNO "$INPUT"
74 checkHint $HINT_FILE || ERROR="true"
76 if [ "$ERROR" == "" ] && [ "$SUBMIT_HINT" == "enabled" ] && [ "$mailbin" != "" ]
77 then
78 YESNO "Are you sure you want to send $HINT_FILE to $hints (yes/no)"
79 if [ "$OK" == "YES" ]
80 then
81 if [ "$COMPRESS" == "enabled" ] && [ "$compressbin" != "" ]
82 then
83 echo "Compressing $HINT_FILE..."
84 $compressbin $HINT_FILE
85 attachment="$HINT_FILE.$compressext"
86 else
87 attachment="$HINT_FILE"
89 echo "Hint Submission: $HINT_FILE" > $MAIL_FILE
90 echo "Sending email to $hints..."
91 $mailbin -B -s "Hint Submission for $HINT_FILE" -a $attachment -r $email $hints < $MAIL_FILE
94 rm -f $MAIL_FILE