Implemented derivation of location from $HOSTNAME and started
implementing ssh cmd
This commit is contained in:
parent
e60fd41d2b
commit
5a1f73702e
30
iottadd.sh
30
iottadd.sh
@ -7,10 +7,7 @@ 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}"
|
||||
echo -e "${GREEN}Usage: iottadd.sh < id > < pass >${RESET}"
|
||||
}
|
||||
|
||||
getConf() {
|
||||
@ -24,7 +21,7 @@ getConf() {
|
||||
}
|
||||
|
||||
|
||||
if [ -z "$3" ]; then
|
||||
if [ -z "$2" ]; then
|
||||
echo -e "${RED}Not enough arguments!\n${RESET}"
|
||||
usage
|
||||
exit 2
|
||||
@ -33,13 +30,8 @@ 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}"
|
||||
echo -e "${GREEN}Running with: ID=${BLUE}${1}${GREEN} and PASS=${BLUE}${2}"
|
||||
getConf
|
||||
|
||||
if [ ! -w ./rawkey-generator.py ]; then
|
||||
@ -47,17 +39,23 @@ elif [[ $1 == "-r" ]]; then
|
||||
exit 1
|
||||
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}"
|
||||
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