SharkRF openSPOT API Profiles

Profile switcher menu

To switch between my profiles, i made a script 🙂

sh script code below:


password="openspot"
server="openspot.local"
token="Login first (1) !!"
while :
do
clear
echo "---------------------------"
echo " openSPOT Profile switcher "
echo " script made by PD2EMC"
echo " "
echo " Server: "$server
echo " Password:" $password
echo " Token:" $token
echo " "
echo "---------------------------"
echo "|[1] Login to openSPOT !! |"
echo "|[2] Check Authorisation |"
echo "|[3] openSPOT Profiles |"
echo "|[4] Profile 0 DMR |"
echo "|[5] Profile 1 YSF |"
echo "|[6] Profile 2 FCS |"
echo "|[7] Profile 3 C4FM->DMR |"
echo "|[8] Profile 4 DMR->C4FM |"
echo "|[9] Reboot openSPOT |"
echo "|[0] Exit Menu |"
echo "---------------------------"
echo -n "Please enter option [1-0] "
read opt
case $opt in
1) echo "Login to sharkRF Openspot";
tokenurl=`curl http://$server/gettok.cgi| sed 's/{"token":"//'|sed 's/"}//'`;
token=${tokenurl};
digest=`echo -n ${tokenurl}${password} | shasum -a 256 | sed 's/-//'`;
jwt=`curl -X POST --header "Content-Type: application/json" --data "{\"token\":\"$token\",\"digest\":\"$digest\"}" "http://$server/login.cgi" | sed 's/{"hostname":"openspot","jwt":"//'|sed 's/"}//'`;;
2) echo "Checking authorisation";
curl -H "Authorization: Bearer $jwt" http://$server/checkauth.cgi | json_pp;
echo "Press [enter] key to continue. . .";
read enterKey;;
3) echo "Getting Profile settings";
curl -H "Authorization: Bearer $jwt" http://$server/cpsettings.cgi | json_pp;
echo "Press [enter] key to continue. . .";
read enterKey;;
4) echo "Switching to Profile 0";
curl -X POST -H "Authorization: Bearer $jwt" --data "{\"active_cp\":\"0\"}" "http://$server/cpsettings.cgi";
token="Login first (1) !!";
digest="";
jwt="";
echo "Press [enter] key to continue. . .";
read enterKey;;
5) echo "Switching to Profile 1";
curl -X POST -H "Authorization: Bearer $jwt" --data "{\"active_cp\":\"1\"}" "http://$server/cpsettings.cgi";
token="Login first (1) !!";
digest="";
jwt="";
echo "Press [enter] key to continue. . .";
read enterKey;;
6) echo "Switching to Profile 2";
curl -X POST -H "Authorization: Bearer $jwt" --data "{\"active_cp\":\"2\"}" "http://$server/cpsettings.cgi";
token="Login first (1) !!";
digest="";
jwt="";
echo "Press [enter] key to continue. . .";
read enterKey;;
7) echo "Switching to Profile 3";
curl -X POST -H "Authorization: Bearer $jwt" --data "{\"active_cp\":\"3\"}" "http://$server/cpsettings.cgi";
token="Login first (1) !!";
digest="";
jwt="";
echo "Press [enter] key to continue. . .";
read enterKey;;
8) echo "Switching to Profile 4";
curl -X POST -H "Authorization: Bearer $jwt" --data "{\"active_cp\":\"4\"}" "http://$server/cpsettings.cgi";
token="Login first (1) !!";
digest="";
jwt="";
echo "Press [enter] key to continue. . .";
read enterKey;;
9) echo "Rebooting openSPOT";
curl -H "Authorization: Bearer $jwt" http://$server/reboot.cgi | json_pp
token="Login first (1) !!";
digest="";
jwt="";;
0) echo "Bye bye $USER";
exit 1;;
*) echo "$opt is an invaild option. Please select option between 1-0 only";
echo "Press [enter] key to continue. . .";
read enterKey;;
esac
done

Next i build a openSPOT Menu, check it out here