This commit is contained in:
Shihaam Abdul Rahman 2021-05-21 03:48:24 +05:00
parent 228edf4461
commit 79e6f9a4c1
3 changed files with 769 additions and 3 deletions

View File

@ -15,8 +15,8 @@ This project is currently under development and a lot of things are broken.
```
git clone https://github.com/shihaamabr/bml-cli
cd bml-cli
chmod +x bml-cli.sh
./bml-cli.sh
chmod +x bml-cli
./bml-cli
```
#### Installation - Systemwide (NOT Recommended, May not work on some distros)
```

766
bml-cli Executable file
View File

@ -0,0 +1,766 @@
#!/bin/bash
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
CONFIG=~/.config/bml-cli/config
CREDENTIALS=~/.config/bml-cli/.credentials
COOKIE=~/.cache/bml-cli/.cookie
BML_RESETPASS='https://www.bankofmaldives.com.mv/internetbanking/forgot_password'
#Setting terminal output colors
red=`tput setaf 1`
#errorred=`tput setaf 196`
#validgreen=`tput setaf 82`
green=`tput setaf 46`
brown=`tput setaf 3`
blue=`tput setaf 4`
pink=`tput setaf 5`
cyan=`tput setaf 39`
gray=`tput setaf 7`
darkgray=`tput setaf 8`
lightred=`tput setaf 9`
lightgreen=`tput setaf 10`
yellow=`tput setaf 11`
reset=`tput sgr0`
# Colors
G='\e[01;32m' # GREEN TEXT
R='\e[01;31m' # RED TEXT
Y='\e[01;33m' # YELLOW TEXT
B='\e[01;34m' # BLUE TEXT
V='\e[01;35m' # VIOLET TEXT
Bl='\e[01;30m' # BLACK TEXT
C='\e[01;36m' # CYAN TEXT
W='\e[01;37m' # WHITE TEXT
BGBL='\e[1;30;47m' # Background W Text Bl
N='\e[0m' # How to use (example): echo "${G}example${N}"
loadBar=' ' # Load UI
##Setting Up Functions
animate(){
PID=$!
h=0
anim='⠋⠙⠴⠦'
while [ -d /proc/$PID ]; do
h=$(((h + 1) % 4))
sleep 0.05
printf "\r${@} [${anim:$h:1}]"
done
}
initialize(){
echo initalizing..
mkdir -p ~/.config/bml-cli/
mkdir -p ~/.cache/bml-cli/
echo "# DO NOT EDIT THIS MANUALLY!!" > $CREDENTIALS
echo "BML_USERNAME='' # Your encrypted BML Username" >> $CREDENTIALS
echo "BML_PASSWORD='' # Your encrypted BML Password" >> $CREDENTIALS
echo "# DO NOT EDIT THIS UNLESS NECESSARY!!" > $CONFIG
echo "I_AM_HYPOCRITE='false' # This is for MacOS Users ONLY" >> $CONFIG
echo "I_AM_SODU='false' # This is for WSL Users ONLY" >> $CONFIG
echo "" >> $CONFIG
echo "BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api' # BML API URL " >> $CONFIG
}
check_connection(){
PING=$(ping -c 1 www.bankofmaldives.com.mv 2> /dev/null | grep -oE 0%)
if [ "$PING" != "0%" ]
then
echo ${red}Check your connection and try again.${reset}
exit 1
fi
DOS=$(curl -s https://www.bankofmaldives.com.mv/ | grep -oE "error code: 1020")
if [ "$DOS" = "error code: 1020" ]
then
echo ${red}Access denied${reset}
echo Try again later
exit
fi
}
os_detect(){
WSL1=$(uname -r | grep -oE Microsoft)
WSL2=$(uname -r | grep -oE microsoft)
MAC=$(uname -a | grep -oE Darwin | tail -n1)
ANDROID=$(uname -a | grep -oE Android)
if [ "$WSL1" = "Microsoft" ] || [ "$WSL2" = "microsoft" ]
then
OS=windows
if [ "$I_AM_SODU" != "true" ]
then
echo ${red}Please check $CONFIG and configure accordingly.${reset}
cexit
fi
elif [ "$MAC" = "Darwin" ]
then
OS=macos
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
if [ "$I_AM_HYPOCRITE" != "true" ]
then
echo ${red}Please check $CONFIG and configure accordingly.${reset}
cexit
fi
elif [ "$ANDROID" = "Android" ]
then
OS=android
fi
banner
}
##################################################################
display_banner(){
clear
echo "${red}"
echo "██████╗░███╗░░░███╗██╗░░░░░  ░█████╗░██╗░░░░░██╗"
echo "██╔══██╗████╗░████║██║░░░░░  ██╔══██╗██║░░░░░██║"
echo "██████╦╝██╔████╔██║██║░░░░░  ██║░░╚═╝██║░░░░░██║"
echo "██╔══██╗██║╚██╔╝██║██║░░░░░  ██║░░██╗██║░░░░░██║"
echo "██████╦╝██║░╚═╝░██║███████╗  ╚█████╔╝███████╗██║"
echo "╚═════╝░╚═╝░░░░░╚═╝╚══════╝  ░╚════╝░╚══════╝╚═╝"
echo "${reset}"
}
display_welcome(){
echo ${green}Welcome ${reset}$NAME
echo ""
}
display_name(){
echo ""
echo ${cyan}Name${reset}: $NAME
}
display_userinfo(){
echo ${cyan}Phone${reset}: $PHONE
echo ${cyan}Email${reset}: $EMAIL
echo ${cyan}Birthday${reset}: $DOB
echo ${cyan}ID Card${reset}: $IDCARD
echo ""
}
####################################################################
cexit(){
echo "Cleaning up.."
rm $COOKIE 2> /dev/null
sleep 0.2
exit
}
reset_config(){
read -p 'Are you sure: [y/N]' SURE
if [ "$SURE" = "y" ] || [ "$SURE" = "Y" ]
then
display_banner
sleep 0.5
echo Deleting Configration.... & rm -rf ~/.config/bml-cli
sleep 0.5
echo Deleting Credentials.... & rm -rf ~/.cache/bml-cli
cexit
else
display_banner && display_name && display_userinfo
settings
fi
}
readpin(){
read -s -p 'Enter Pin: ' PIN
echo ""
CHECK_PIN=$(echo ${BML_USERNAME} | openssl enc -d -des3 -base64 -pass pass:${PIN} -pbkdf2 2>&1 | grep -oE bad)
if [ "$CHECK_PIN" = "bad bad" ]
then
echo ${R}Incorrect Pin${N}
readpin
fi
#banner
BML_USERNAME_UNSAFE=$(echo ${BML_USERNAME} | openssl enc -d -des3 -base64 -pass pass:${PIN} -pbkdf2)
BML_PASSWORD_UNSAFE=$(echo ${BML_PASSWORD} | openssl enc -d -des3 -base64 -pass pass:${PIN} -pbkdf2)
#banner
login #& animate "Logging in"
}
wipe_credentials(){
sed -i "s@BML_USERNAME=.*\$@BML_USERNAME='' # Your encrypted BML Username @" $CREDENTIALS
sed -i "s@BML_PASSWORD=.*\$@BML_PASSWORD='' # Your encrypted BML Password @" $CREDENTIALS
}
urandom(){
BML_USERNAME_UNSAFE=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
BML_PASSWORD_UNSAFE=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
BML_USERNAME=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
BML_PASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
REPEAT_PIN=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
NEW_PIN=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
}
savepass(){
if [ "$BML_USERNAME" = "" ] && [ "$BML_PASSWORD" = "" ]
then
read -p 'Do you want to save login? [y/N] ' SAVE_LOGIN
if [ "$SAVE_LOGIN" = "Y" ] || [ "$SAVE_LOGIN" = "y" ]
then
read -s -p 'Enter New Pin: ' NEW_PIN
echo ""
read -s -p 'Repeat Pin: ' REPEAT_PIN
if [ "$NEW_PIN" = "$REPEAT_PIN" ]
then
echo ""
BML_USERNAME=$(echo "${BML_USERNAME_UNSAFE}" | openssl enc -e -des3 -base64 -pass pass:${NEW_PIN} -pbkdf2)
BML_PASSWORD=$(echo "${BML_PASSWORD_UNSAFE}" | openssl enc -e -des3 -base64 -pass pass:${NEW_PIN} -pbkdf2)
#encrypt_user #& initanimate "Encrypting Username"
#encrypt_pass #& initanimate "Encrypting Password"
echo "Your credentials are ${lightgreen}encrypted${reset} and saved in $CREDENTIALS"
sed -i "s@BML_USERNAME=.*\$@BML_USERNAME='${BML_USERNAME}' # Your encrypted BML Username @" $CREDENTIALS
sed -i "s@BML_PASSWORD=.*\$@BML_PASSWORD='${BML_PASSWORD}' # Your encrypted BML Password @" $CREDENTIALS
else
echo ""
echo ${R}Pin do not match${N}
savepass
fi
else
echo Password not saved.
fi
else
:
fi
urandom
select_profile #& animate "Selecting Profile" # urandom && select_profile
}
################################################################################################
################################################################################################
login(){
LOGIN=$(curl -s -c $COOKIE $BML_URL/login \
--data-raw username=$BML_USERNAME_UNSAFE \
--data-raw password=${BML_PASSWORD_UNSAFE} \
| jq -r .code)
if [ "$LOGIN" = "0" ]
then
display_banner
echo ${lightgreen}Login success${reset}
savepass
elif [ "$LOGIN" = "20" ]
then
display_banner
account_locked
sleep 1.5
display_banner
echo "${red}Account Locked!${reset}"
echo "${lightred}Please reset password and login again.${reset}"
enter_credentials
elif [ "$LOGIN" = "2" ]
then
display_banner
echo ${red}Password or Username Incorrect${reset}
wipe_credentials
enter_credentials
elif [ "$LOGIN" = "37" ]
then
echo "${red}Down for Maintenance${reset}" 1>&2
echo "Try again later"
exit
else
echo "${red}Unknown Error${reset}" 1>&2
exit
fi
}
################################################################################################
################################################################################################
account_locked(){
if [ "$OS" = "macos" ]
then
open $BML_RESETPASS
elif [ "$OS" = "windows" ]
then
cmd.exe /C START $BML_RESETPASS
elif [ "$OS" = "android" ]
then
am start -a android.intent.action.VIEW -d $BML_RESETPASS
else
xdg-open $BML_RESETPASS
fi
}
################################################################################################
################################################################################################
enter_credentials(){
#echo ""
read -p 'Username: ' BML_USERNAME_UNSAFE
read -s -p 'Password: ' BML_PASSWORD_UNSAFE
echo ""
login
}
################################################################################################
################################################################################################
select_profile(){
REQPRO=$(curl -s -b $COOKIE $BML_URL/profile)
PERSONALPROFILE=$(echo $REQPRO \
| jq -r '.payload | .profile | .[] | .profile' \
| head -n 1)
curl -s -b $COOKIE $BML_URL/profile \
--data-raw profile=$PERSONALPROFILE \
--compressed > /dev/null
}
################################################################################################
################################################################################################
userinfo(){
USERINFO=$(curl -s -b $COOKIE $BML_URL/userinfo)
SUCCESS=$(echo $USERINFO | jq -r .success)
if [ "$SUCCESS" != "true" ]
then
echo ${red}Login Required${reset}
init_login
display_banner
userinfo
fi
USERINFO=$(echo $USERINFO | jq -r '.["payload"] | .["user"]')
NAME=$(echo $USERINFO | jq -r .fullname)
PHONE=$(echo $USERINFO | jq -r .mobile_phone)
EMAIL=$(echo $USERINFO | jq -r .email)
DOB=$(echo $USERINFO | jq -r .birthdate |cut -d 'T' -f 1)
IDCARD=$(echo $USERINFO | jq -r .idcard)
}
################################################################################################
################################################################################################
accounts(){
echo $DASHBOARD \
| jq -r '["Account Name"," Account Number","Type", "Currency", "Balance"], ["===================","==============","==================","=========","========="], (.payload | .dashboard |.[] | [.alias, .account, .product, .currency, .availableBalance]) | @tsv' \
| perl -pe 's/((?<=\t)|(?<=^))\t/ \t/g;' "$@" | column -t -s $'\t' | exec less -F -S -X -K
}
################################################################################################
api_dashboard(){
DASHBOARD=$(curl -s -b $COOKIE $BML_URL/dashboard)
SUCCESS=$(echo $DASHBOARD | jq -r .success)
if [ "$SUCCESS" != "true" ]
then
echo ${red}Login Required${reset}
init_login
display_banner && display_name && display_userinfo
api_dashboard
fi
}
################################################################################################
list_contacts(){
echo $API_CONATACTS | jq -r '["ID","Account Number","Currency","Account Name","Contact Name"], ["===========","==============","========","=============================","============================="], (.["payload"] | .[] | [.id, .account, .currency, .name, .alias]) | @tsv' \
| perl -pe 's/((?<=\t)|(?<=^))\t/ \t/g;' "$@" | column -t -s $'\t' | exec less -F -S -X -K
}
################################################################################################
api_contacts(){
API_CONATACTS=$(curl -s -b $COOKIE $BML_URL/contacts)
SUCCESS=$(echo $API_CONATACTS | jq -r .code)
if [ "$SUCCESS" = "17" ]
then
echo ${red}Login Required${reset}
init_login
display_banner && display_name && display_userinfo
api_contacts
fi
}
################################################################################################
transfer(){
# banner
accounts
echo ""
echo "Select debit account"
echo "Enter credit account"
}
################################################################################################
################################################################################################
api_account(){
API_ACCOUNT=$(curl -s -b $COOKIE $BML_URL/validate/account/$ACCOUNT_NUMBER)
SUCCESS=$(echo $API_ACCOUNT | jq -r .code)
if [ "$SUCCESS" = "17" ]
then
echo ${red}Login Required${reset}
init_login
display_banner && display_name && display_userinfo
fi
}
################################################################################################
################################################################################################
add_contact(){
printf 'Account Number: '
read -r ACCOUNT_NUMBER
if [ "$ACCOUNT_NUMBER" = "x" ] || [ "$ACCOUNT_NUMBER" = "back" ]
then
display_banner && display_name && display_userinfo
contacts_menu
elif [ "$ACCOUNT_NUMBER" = "" ]
then
display_banner && display_name && display_userinfo
echo ${red}No input${reset}
echo Input account number or ${lightgreen}x${reset} to go back
add_contact
fi
api_account
VALID_NUMBER=$(echo $API_ACCOUNT | jq -r .success)
if [ "$VALID_NUMBER" = "true" ]
then
ACCOUNT_NAME=$(echo $API_ACCOUNT | jq -r '.["payload"] | .name')
CURRENCY=$(echo $API_ACCOUNT | jq -r '.["payload"] | .currency')
echo "Account Name: $ACCOUNT_NAME"
echo "Currency: $CURRENCY"
echo ""
printf 'Contact Name: '
read -r CONTACT_NAME
if [ "$CONTACT_NAME" = "" ]
then
CONTACT_NAME=$ACCOUNT_NAME
fi
CONTACT_NAME_SED=`echo "$CONTACT_NAME" | sed "s/ /%20/g"`
ADDCONTACT=$(curl -s -b $COOKIE $BML_URL/contacts \
--data-raw contact_type=IAT \
--data-raw account=$ACCOUNT_NUMBER \
--data-raw alias=$CONTACT_NAME_SED \
--compressed \
| jq -r .code)
if [ "$ADDCONTACT" = "0" ]
then
display_banner && display_name && display_userinfo
echo $ACCOUNT_NUMBER ${lightgreen}saved as ${reset} $CONTACT_NAME ${lightgreen}succesfully${reset}
elif [ "$ADDCONTACT" = "17" ]
then
echo ${red}Login Required ${reset}
init_login
add_contact
else
display_banner && display_name && display_userinfo
echo "${red}There was an error${reset}"
fi
else
echo "${red}Invalid Account${reset}" 1>&2
add_contact
fi
}
################################################################################################
################################################################################################
delete_contact(){
printf "Enter Contact ID: "
read -r CONATACT_ID
DELETESUCCESS=$(curl -s -b $COOKIE $BML_URL/contacts/$CONATACT_ID \
--data-raw _method=delete \
--compressed \
| jq -r .code)
if [ "$DELETESUCCESS" = "0" ]
then
echo Contact Deleted
contacts_menu
else
echo "${red}There was an error${reset}"
delete_contact
fi
}
#################################
api_activites(){
API_ACTIVITES=$(curl -s -b $COOKIE $BML_URL/activities)
SUCCESS=$(echo $API_ACTIVITES | jq -r .code)
if [ "$SUCCESS" = "17" ]
then
echo ${red}Login Required${reset}
init_login
display_banner && display_name && display_userinfo
api_activites
fi
PAGETOTAL=$(echo $API_ACTIVITES | jq -r '.payload | .content | .last_page')
}
################################################################################################
activities(){
echo Current Page: 1
echo $API_ACTIVITES | jq -r '["Type","Date","Time","Contact","Amount","Remarks","Status"], ["=====","==========","=====","============","=======","==================","==========="],(.payload | .content | .data | .[] | [.type, .datetime, .creditName, .formattedAmount, .message, .status]) | @tsv' \
| sed "s/+05:00//g" | perl -pe 's/((?<=\t)|(?<=^))\t/ \t/g;' "$@" | column -t -s $'\t' | exec less -F -S -X -K
while true; do
echo ""
echo Total Pages: $PAGETOTAL
read -p "Enter Page Number: " PAGENO
if [ "$PAGENO" -le "$PAGETOTAL" ]
then
display_banner && display_name && display_userinfo
echo Current Page: $PAGENO
curl -s -b $COOKIE $BML_URL/activities?page=$PAGENO \
| jq -r '["Type","Date","Time","Contact","Amount","Remarks","Status"], ["=====","==========","=====","============","=======","==================","==========="],(.payload | .content | .data | .[] | [.type, .datetime, .creditName, .formattedAmount, .message, .status]) | @tsv' \
| sed "s/+05:00//g" | perl -pe 's/((?<=\t)|(?<=^))\t/ \t/g;' "$@" | column -t -s $'\t' | exec less -F -S -X -K
elif [ "$PAGENO" -gt "$PAGETOTAL" ]
then
display_banner && display_name && display_userinfo
echo ${red}value too high${reset}
elif [ "$PAGENO" = "x" ] || [ "$PAGENO" = "0" ] || [ "$PAGENO" = "back" ]
then
display_banner && display_name && display_userinfo
main_menu
else
display_banner && display_name && display_userinfo
echo ${red}Invalid Input${reset}
echo Enter x to go back
fi
done
}
services(){
echo ""
echo "Work In Progress"
read -p "Press enter to return to main menu" BRUH
display_banner && display_name && display_userinfo
main_menu
}
################################################################################################
main_menu(){
echo "Main Menu"
echo ""
echo "1 - Accounts"
echo "2 - Transfer"
echo "3 - Contacts"
echo "4 - Activities"
echo "5 - Services"
echo "6 - Settings"
echo ""
printf 'Please Input: '
read -r MENU
if [ "$MENU" = "1" ]
then
api_dashboard # & animate "Fetching account details"
display_banner && display_name && display_userinfo
accounts
accounts_menu
elif [ "$MENU" = "2" ]
then
display_banner && display_name && display_userinfo
transfer_menu
elif [ "$MENU" = "3" ] || [ "$MENU" = "contacts" ]
then
display_banner && display_name && display_userinfo
api_contacts #& animate "Fetching contacts"
list_contacts
contacts_menu
elif [ "$MENU" = "4" ]
then
display_banner && display_name && display_userinfo
api_activites
activities
elif [ "$MENU" = "5" ]
then
display_banner && display_name && display_userinfo
services
elif [ "$MENU" = "6" ]
then
display_banner && display_name && display_userinfo
settings
elif [ "$MENU" = "exit" ] || [ "$MENU" = "x" ]
then
cexit
else
display_banner && display_name && display_userinfo
echo ${red}Invalid input:${yellow} $MENU ${reset} 1>&2
main_menu
fi
}
##############################################################################################
accounts_menu(){
echo ""
echo "Work In Progress"
read -p "Press enter to return main menu" BRUH
display_banner && display_name && display_userinfo
main_menu
}
################################################################################################
contacts_menu(){
echo "Contacts"
echo ""
echo "1 - Transfer"
echo "2 - Add New Contact"
echo "3 - Delete Contact"
echo "x - Go back"
echo ""
printf 'Please Input: '
read -r CONTACTS
if [ "$CONTACTS" = "1" ] || ["$CONTACTS" = "transfer" ]
then
display_banner && display_name && display_userinfo
transfer_menu
elif [ "$CONTACTS" = "2" ] || ["$CONTACTS" = "add new contact" ]
then
display_banner && display_name && display_userinfo
add_contact
contacts_menu
elif [ "$CONTACTS" = "3" ] || ["$CONTACTS" = "delete contact" ]
then
display_banner && display_name && display_userinfo
list_contacts
delete_contact
api_contacts
contact_menu
elif [ "$CONTACTS" = "x" ] || [ "$CONTACTS" = "back" ]
then
display_banner && display_name && display_userinfo
main_menu
elif [ "$CONTACTS" = "exit" ]
then
cexit
else
display_banner && display_name && display_userinfo
echo ${red}Invalid input:${yellow} $CONTACTS ${reset} 1>&2
contacts_menu
fi
}
transfer_menu(){
echo "Work In Progress"
read -p "Press enter to return to main menu" BRUH
display_banner && display_name && display_userinfo
main_menu
}
###########################################################################################
change_password(){
while true; do
echo "Select OTP Method:"
echo "1 - Mobile"
echo "2 - Email"
echo ""
read -p "Please input: " OTPCHANNEL
if [ "$OTPCHANNEL" = "1" ] || [ "$OTPCHANNEL" = "mobile" ]
then
OTPCHANNEL=mobile
ECHOOTPCHANNEL=$PHONE
break
elif [ "$OTPCHANNEL" = "2" ] || [ "$OTPCHANNEL" = "email" ]
then
OTPCHANNEL=email
ECHOOTPCHANNEL=$EMAIL
break
elif [ "$OTPCHANNEL" = "back" ] || [ "$OTPCHANNEL" = "x" ]
then
display_banner && display_name && display_userinfo
settings
else
display_banner && display_name && display_userinfo
echo ${red}Invalid Input${reset}
echo Enter x to back
fi
done
read -s -p 'Enter Current Password: ' OLD_PASSWORD
echo ""
while true; do
read -s -p 'Enter New Password: ' NEW_PASSWORD
echo ""
read -s -p 'Repeat New Password: ' REPEAT_NEWPASSWORD
echo ""
if [ "$NEW_PASSWORD" != "$REPEAT_NEWPASSWORD" ]
then
display_banner && display_name && display_userinfo
echo "${red}Password do not match${reset}"
echo "Try again"
else
break
fi
done
curl -s -b $COOKIE $BML_URL/user/changepassword \
--data-raw currentPassword=$OLD_PASSWORD \
--data-raw newPassword=$NEW_PASSWORD \
--data-raw newPasswordConfirmation=$REPEAT_NEWPASSWORD \
--data-raw channel=$OTPCHANNEL > /dev/null
echo ${lightgreen}OTP sent to ${yellow}${ECHOOTPCHANNEL}${reset}
read -p 'Enter OTP: ' OTP
CHANGEPASSWORD=$(curl -s -b $COOKIE $BML_URL/user/changepassword \
--data-raw currentPassword=$OLD_PASSWORD \
--data-raw newPassword=$NEW_PASSWORD \
--data-raw newPasswordConfirmation=$REPEAT_NEWPASSWORD \
--data-raw channel=$OTPCHANNEL \
--data-raw otp=$OTP \
| jq -r .code)
if [ "$CHANGEPASSWORD" = "0" ]
then
echo Password changed succesfully ${reset}
elif [ "$CHANGEPASSWORD" = "8" ]
then
display_banner && display_name && display_userinfo
echo ${red}Old Password is incorrect${reset}
echo failed to change password
change_password
elif [ "$CHANGEPASSWORD" = "24" ]
then
display_banner && display_name && display_userinfo
echo ${red}Invalid OTP${reset}
echo failed to change password
change_password
elif [ "$CHANGEPASSWORD" = "17" ]
then
echo ${red}Login Required${reset}
init_login
display_banner
change_password
else
echo unknown error
main_menu
fi
}
##############################################################################################
################################################################################################
settings(){
echo "Settings"
echo "1 - Logout"
echo "2 - Logout and reset config"
echo "3 - Change Password"
echo ""
printf 'Please Input: '
read -r SETTINGS
if [ "$SETTINGS" = "1" ]
then
display_banner
wipe_credentials
cexit
elif [ "$SETTINGS" = "2" ]
then
display_banner
reset_config
elif [ "$SETTINGS" = "3" ]
then
display_banner && display_name && display_userinfo
change_password
elif [ "$SETTINGS" = "x" ] || [ "$SETTINGS" = "back" ]
then
display_banner && display_name && display_userinfo
main_menu
else
display_banner && display_name && display_userinfo
echo ${red}Invalid input:${yellow} $SETTINGS ${reset} 1>&2
settings
fi
}
if [ ! -f $CONFIG ]
then
initialize
fi
init_login(){
if [ "$BML_USERNAME" != "" ] && [ "$BML_PASSWORD" != "" ]
then
readpin
else
enter_credentials
fi
}
display_banner && check_connection #& animate "Checking Internet Connection"
source $CONFIG
source $CREDENTIALS
display_banner && os_detect # & animate "Detecting Operating System"
display_banner && init_login
userinfo
display_banner && display_welcome && display_userinfo && main_menu

View File

@ -4,7 +4,7 @@ git clone https://github.com/shihaamabr/bml-cli.git
mkdir -p /opt/sar/bml-cli/
mv bml-cli/* /opt/sar/bml-cli/
echo "#!/bin/bash" > /usr/bin/bml-cli
echo "source /opt/sar/bml-cli/bml-cli.sh" >> /usr/bin/bml-cli
echo "source /opt/sar/bml-cli/bml-cli" >> /usr/bin/bml-cli
chmod 755 /usr/bin/bml-cli
rm -rf bml-cli/
echo "Installation Complete"