Implemented derivation of location from $HOSTNAME and started
implementing ssh cmd
This commit is contained in:
parent
e60fd41d2b
commit
5a1f73702e
44
iottadd.sh
44
iottadd.sh
@ -7,10 +7,7 @@ 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 < id > < pass >${RESET}"
|
||||||
|
|
||||||
-l for usage on local machine
|
|
||||||
-r for usage on server (remote)${RESET}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getConf() {
|
getConf() {
|
||||||
@ -24,7 +21,7 @@ getConf() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$3" ]; then
|
if [ -z "$2" ]; then
|
||||||
echo -e "${RED}Not enough arguments!\n${RESET}"
|
echo -e "${RED}Not enough arguments!\n${RESET}"
|
||||||
usage
|
usage
|
||||||
exit 2
|
exit 2
|
||||||
@ -33,31 +30,32 @@ fi
|
|||||||
### MAIN PROGRAM
|
### MAIN PROGRAM
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
if [[ $1 == "-l" ]]; then
|
|
||||||
# Used on local machine
|
|
||||||
echo -e "${RED}Not implemented${RESET}"
|
|
||||||
|
|
||||||
elif [[ $1 == "-r" ]]; then
|
echo -e "${GREEN}Running with: ID=${BLUE}${1}${GREEN} and PASS=${BLUE}${2}"
|
||||||
# Used on server
|
getConf
|
||||||
echo -e "${GREEN}Running with: ID=${BLUE}${2}${GREEN} and PASS=${BLUE}${3}"
|
|
||||||
getConf
|
|
||||||
|
|
||||||
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="0x00"$(python ./rawkey-generator.py "${3}" "Sincoolka IoTT")
|
RAWKEY="0x00"$(python ./rawkey-generator.py "${2}" "Sincoolka IoTT")
|
||||||
|
|
||||||
echo -e "${GREEN}Generated raw key (pmk): ${BLUE}${RAWKEY}${CLEAR}"
|
echo -e "${GREEN}Generated raw key (pmk): ${BLUE}${RAWKEY}${CLEAR}"
|
||||||
getConf
|
getConf
|
||||||
|
|
||||||
|
if [ "$HOSTNAME" == "pride" ]; then
|
||||||
|
sshCmd="lust-db"
|
||||||
|
|
||||||
|
else
|
||||||
|
echo -en "${GREEN}Enter your username on server: ${PURPLE}"
|
||||||
|
read -p "" serverUser
|
||||||
|
echo -en "${RESET}"
|
||||||
|
sshCmd="-J ${serverUser}@pride.sin.cvut.cz ${serverUser}@lust-db"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ssh $sshCmd "psql sinis_test 'INSERT INTO nic_dpsk (psk, id_nic) VALUES ('${2}', '${1}');'"
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
else
|
|
||||||
usage
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user