Refactoring

This commit is contained in:
David Houdek 2023-10-10 22:11:31 +02:00
parent cfb2da563e
commit c837aab523

View File

@ -7,44 +7,44 @@ BLUE="\033[1;34m"
RESET="\033[0m" RESET="\033[0m"
usage() { 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 -l for usage on local machine
-r for usage on server (remote)"$RESET -r for usage on server (remote)${RESET}"
} }
if [ -z $3 ]; then if [ -z "$3" ]; then
echo -e $RED"Not enough arguments!\n"$RESET echo -e "${RED}Not enough arguments!\n${RESET}"
usage usage
exit 2 exit 2
fi fi
### MAIN PROGRAM
############################################################################# #############################################################################
if [[ $1 == "-l" ]]; then if [[ $1 == "-l" ]]; then
# Used on local machine # Used on local machine
echo -e $RED"Not implemented"$RESET echo -e "${RED}Not implemented${RESET}"
elif [[ $1 == "-r" ]]; then elif [[ $1 == "-r" ]]; then
# Used on server # 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 read -p " " confirmation
printf $RESET echo -en "${RESET}"
if [[ $confirmation == "n" ]]; then if [[ $confirmation == "n" ]]; then
exit 666 exit 255
fi fi
if [ ! -w ./rawkey-generator.py ]; then 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 exit 1
fi 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}"
############################################################################ ############################################################################