Added feature: gather a devkey at compile time.
This commit is contained in:
parent
9c253ee0eb
commit
ef9e298919
2 changed files with 39 additions and 7 deletions
19
Makefile
19
Makefile
|
@ -1,6 +1,6 @@
|
|||
# Makefile for pastebincl (command-line pastebin) by BASTIAN Théophile (aka Tobast)
|
||||
|
||||
ENC_KEY=`./genkey.py`
|
||||
ENC_KEY=`python genkey.py`
|
||||
|
||||
CXX=g++
|
||||
CXXFLAGS=-Wall -Werror -O2
|
||||
|
@ -8,15 +8,20 @@ CXXLIBS=-lcurl
|
|||
TARGET=pastebincl
|
||||
OBJS=CurlPost.o func.o main.o ParameterRead.o ConfigRead.o
|
||||
|
||||
all: checkdevcode $(TARGET)
|
||||
all: inputdevcode checkdevcode $(TARGET)
|
||||
cp $(TARGET) ../
|
||||
|
||||
#checkdevcode:
|
||||
# @if [[ ! -f data_devcode.h ]]; then echo -e "\nERROR: No 'data_devcode.h' file (common error). Please read \"COMPILE.txt\" for more help.\n" ; false ; fi
|
||||
# @if (( `cat data_devcode.h | grep -c '#define DEVELOPPER_CODE ""'` != 0 )); then echo -e "\nERROR: 'DEVELOPPER_CODE' undefined (common error). Please read \"COMPILE.txt\" for more help.\n" ; false ; fi
|
||||
inputdevcode:
|
||||
@if [[ ! -f data_devcode.h ]]; then cp data_devcode_default.h data_devcode.h; fi
|
||||
@if (( `cat data_devcode.h | grep -c '#define DEVELOPPER_CODE ""'` != 0 )); then echo -e "\n" ; bash input_devcode.sh; fi
|
||||
|
||||
checkdevcode:
|
||||
@if [[ ! -f data_devcode.h ]]; then echo -e "\nERROR: No 'data_devcode.h' file (common error). Please read \"COMPILE.txt\" for more help.\n" ; false ; fi
|
||||
@if (( `cat data_devcode.h | grep -c '#define DEVELOPPER_CODE ""'` != 0 )); then echo -e "\nERROR: 'DEVELOPPER_CODE' undefined (common error). Please read \"COMPILE.txt\" for more help.\n" ; false ; fi
|
||||
|
||||
#### Useful while developping. To enable it, uncomment and add it as a dependence of 'all' ####
|
||||
makeuser:
|
||||
./pastebincl --usergen < userinput &> /dev/null
|
||||
#makeuser:
|
||||
# ./pastebincl --usergen < userinput &> /dev/null
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CXX) $(CXXLIBS) $^ $(CXXFLAGS) -o $@
|
||||
|
|
27
input_devcode.sh
Executable file
27
input_devcode.sh
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
while true; do
|
||||
|
||||
echo "Enter your Pastebin Developper API Key (see http://pastebin.com/api), or leave blank to use the default one (may not work):"
|
||||
read input
|
||||
|
||||
if [ -z $input ] ; then
|
||||
input=`wget -qO - http://tobast.fr/ressources/pastebin_devkey`
|
||||
|
||||
if (( ! `echo $input | grep -ce "[0-9a-f]\{32\}"` > 0 )) ; then
|
||||
echo -e "\nERROR: Cannot obtain the default Developper API Key ! Please re-try with your API key.\n"
|
||||
else
|
||||
break
|
||||
fi
|
||||
else
|
||||
if (( ! `echo $input | grep -ce "[0-9a-f]\{32\}"` > 0 )) ; then
|
||||
echo -e "\nERROR: Wrong API key, please re-try.\n"
|
||||
else
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
sed -ire "49s/\"\".*$/\"${input}\"/" data_devcode.h
|
||||
echo "Success!"
|
||||
|
Loading…
Reference in a new issue