好吧,博客的编程语言里没有shell,还是把代码贴在这吧。
#!/bin/bash
#
#因为之前利用这样的简单脚本安装过程序,学习树莓派搭建mqtt使用如下脚本应该很轻松
#源码文件都放在/home/pi/Study下,分三步:
#1.mqtt安装环境需要的库安装 2.mqtt解压安装3.环境配置
#
MOSQUITTO_VERSION="mosquitto-1.4.9"
STUDY_PATH="/home/pi/Study"
#PWD_DIR=`pwd`
function func_mosquitto_env_install()
{
sudo apt-get install g++ openssl libssl-dev libc-ares-dev uuid-dev
# if [ !-f "${STUDY_PATH}${MOSQUITTO_VERSION}.tar.gz" ];then
sudo wget ${STUDY_PATH} http://mosquitto.org/files/source/${MOSQUITTO_VERSION}.tar.gz
# fi
}
function func_mosquitto_installation()
{
cd ${STUDY_PATH}
sudo tar zxvf ${MOSQUITTO_VERSION}.tar.gz
cd ${MOSQUITTO_VERSION}
sudo make || ( echo "make fail";exit 1)
sudo make install || ( echo "make install failed";exit 1)
}
function func_mosquitto_copy_conf()
{
sudo ln -s /usr/local/lib/libmosquitto.so.1 /usr/lib/libmosquitto.so.1
sudo ldconfig
}
func_mosquitto_env_install
func_mosquitto_installation
func_mosquitto_copy_conf
exit 0