Refactoring
This commit is contained in:
parent
cfb2da563e
commit
c837aab523
24
iottadd.sh
24
iottadd.sh
@ -7,44 +7,44 @@ BLUE="\033[1;34m"
|
||||
RESET="\033[0m"
|
||||
|
||||
usage() {
|
||||
echo -e $GREEN"Usage: iottadd.sh < -l | -r > < id > < pass >
|
||||
echo -e "${GREEN}Usage: iottadd.sh < -l | -r > < id > < pass >
|
||||
|
||||
-l for usage on local machine
|
||||
-r for usage on server (remote)"$RESET
|
||||
-r for usage on server (remote)${RESET}"
|
||||
}
|
||||
|
||||
|
||||
if [ -z $3 ]; then
|
||||
echo -e $RED"Not enough arguments!\n"$RESET
|
||||
if [ -z "$3" ]; then
|
||||
echo -e "${RED}Not enough arguments!\n${RESET}"
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
### MAIN PROGRAM
|
||||
#############################################################################
|
||||
|
||||
if [[ $1 == "-l" ]]; then
|
||||
# Used on local machine
|
||||
echo -e $RED"Not implemented"$RESET
|
||||
echo -e "${RED}Not implemented${RESET}"
|
||||
|
||||
elif [[ $1 == "-r" ]]; then
|
||||
# Used on server
|
||||
echo -en $GREEN"Running with: ID="$BLUE$2$GREEN" and PASS="$BLUE$3"\nIs that ok? ["$GREEN"Y"$BLUE"/"$RED"n"$BLUE"]"$PURPLE
|
||||
echo -en "${GREEN}Running with: ID=${BLUE}${2}${GREEN} and PASS=${BLUE}${3}\nIs that ok? [${GREEN}Y${BLUE}/${RED}n${BLUE}]${PURPLE}"
|
||||
read -p " " confirmation
|
||||
printf $RESET
|
||||
echo -en "${RESET}"
|
||||
|
||||
if [[ $confirmation == "n" ]]; then
|
||||
exit 666
|
||||
exit 255
|
||||
fi
|
||||
|
||||
if [ ! -w ./rawkey-generator.py ]; then
|
||||
echo -e $RED"You don't have rawkey-generator.py in the same folder or don't have execute permitions"$CLEAR
|
||||
echo -e "${RED}You don't have rawkey-generator.py in the same folder or don't have execute permitions${CLEAR}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RAWKEY=$(python ./rawkey-generator.py $3 "Sincoolka IoTT")
|
||||
RAWKEY="0x00"$(python ./rawkey-generator.py "${3}" "Sincoolka IoTT")
|
||||
|
||||
echo -e $GREEN"Generated raw key: "$BLUE$RAWKEY$CLEAR
|
||||
echo -e "${GREEN}Generated raw key: ${BLUE}${RAWKEY}${CLEAR}"
|
||||
|
||||
|
||||
############################################################################
|
||||
|
Loading…
Reference in New Issue
Block a user