57 lines
1.3 KiB
Bash
Executable File
57 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
GREEN="\033[1;32m"
|
|
RED="\033[1;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}"
|
|
}
|
|
|
|
|
|
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 -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
|
|
echo -en "${RESET}"
|
|
|
|
if [[ $confirmation == "n" ]]; then
|
|
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}"
|
|
exit 1
|
|
fi
|
|
|
|
RAWKEY="0x00"$(python ./rawkey-generator.py "${3}" "Sincoolka IoTT")
|
|
|
|
echo -e "${GREEN}Generated raw key: ${BLUE}${RAWKEY}${CLEAR}"
|
|
|
|
|
|
############################################################################
|
|
|
|
else
|
|
usage
|
|
|
|
fi
|
|
|