A Bash API for Free Mobile notification service
freemobile-smsapi is a Bash library which allows to use Free Mobile SMS notification service.
To be able to use Free Mobile SMS notification service, you must have:
-
Subscribed a mobile line with Free Mobile operator.
It's on this line SMS will be sent.
-
Enable SMS notification service.
This will give you an authentication key.
With your Free Mobile login and the authentication key you have all information to use this library.
This library is composed of two files:
-
/etc/freemobile-smsapi/freemobile-smsapi.conf.src
The configuration file
-
/usr/lib/freemobile-smsapi/freemobile-smsapi.bash.src
The library
Both are located inside the directory freemobile-smsapi which allows to build a Debian package.
Configuration file: /etc/freemobile-smsapi/freemobile-smsapi.conf.src
is in fact a file which is sourced by the Bash library.
Thus syntax is the Bash one and is composed of the following variables:
Name | Meaning |
---|---|
USER | Free Mobile login |
PASS | Authentication key associated to login |
Example:
# Free Mobile login
USER="12345678"
# Authentication key associated to login
PASS="1a2B3c4D5e6F7g"
To use the library there are only two steps:
- Source the library:
. /usr/lib/freemobile-smsapi/freemobile-smsapi.bash.src
- Call the function to send a SMS:
callFreeMobileSmsApi "My first SMS"
In this example My first SMS will be sent to the phone number associated with the Free Mobile account defined in the configuration file.
Exit code will be 0
in case of success, 1
otherwise.
You can create the Debian package with the following commands:
# Move to the repository directory
cd /github/freemobile-smsapi/repository/path
# Generate the Debian package
sudo dpkg-deb --build freemobile-smsapi
# Update the package name following Debian convention
VERSION=$(grep "Version" freemobile-smsapi/DEBIAN/control | cut -d ' ' -f 2)
ARCH=$(grep "Architecture" freemobile-smsapi/DEBIAN/control | cut -d ' ' -f 2)
mv freemobile-smsapi.deb freemobile-smsapi_${VERSION}_${ARCH}.deb