sinis_IOTT_script/iottadd.sh
2023-10-16 12:49:30 +02:00

64 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
GREEN="\033[0;32m"
RED="\033[0;31m"
PURPLE="\033[0;35m"
BLUE="\033[1;34m"
RESET="\033[0m"
usage() {
echo -e "${GREEN}Usage: iottadd.sh < -l | -r > < id > < pass >
-l for usage on local machine
-r for usage on server (remote)${RESET}"
}
getConf() {
echo -e "${GREEN}Is that ok? ${BLUE}[${GREEN}Y${BLUE}/${RED}n${BLUE}]${PURPLE}"
read -p " " confirmation
echo -en "${RESET}"
if [[ $confirmation == "n" ]]; then
exit 255
fi
}
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}"
elif [[ $1 == "-r" ]]; then
# Used on server
echo -e "${GREEN}Running with: ID=${BLUE}${2}${GREEN} and PASS=${BLUE}${3}"
getConf
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}"
exit 1
fi
RAWKEY="0x00"$(python ./rawkey-generator.py "${3}" "Sincoolka IoTT")
echo -e "${GREEN}Generated raw key (pmk): ${BLUE}${RAWKEY}${CLEAR}"
getConf
############################################################################
else
usage
fi