shell脚本实现自动编译安装
2009-08-06 11:37
836 查看
写了个脚本实现许多安装包的自动配置,编译,安装,脚本很简单,关键是我用的时候有个小问题,所以贴出来。
脚本如下:
#!/bin/sh
#install need root user.
if [ "whoami" != "root"];then
echo "Installtion this package needs root user."
exit 1
fi
#file exist problem
if [ ! -a /opt/work/libxml2.tar.gz ];then
echo "The sources of libxml2 is not exist."
exit
fi
tar xzvf /opt/work/libxml2.tar.gz
#test tar right or not
if [ ! -d /opt/work/libxml2 ];then
echo "The tar file is not uncompressed."
exit
fi
#into the directory
cd /opt/work/libxml2
/opt/work/libxml2/configure --prefix=/usr/local
make&make install
#into the root directory
cd /
脚本已经结束,可以执行,但是执行的时候不能以./filename.sh的格式,而是必须以source filename.sh的格式来运行,否则在cd /opt/work/libxml2的时候会进不去,当然接下的脚本执行就会错误了!--这是我犯错的地方。
如果你要编译安装很多tar包,在linux下,依赖关系复杂,很常见,你可以用这种方法,自动安装,省去不少麻烦!
脚本如下:
#!/bin/sh
#install need root user.
if [ "whoami" != "root"];then
echo "Installtion this package needs root user."
exit 1
fi
#file exist problem
if [ ! -a /opt/work/libxml2.tar.gz ];then
echo "The sources of libxml2 is not exist."
exit
fi
tar xzvf /opt/work/libxml2.tar.gz
#test tar right or not
if [ ! -d /opt/work/libxml2 ];then
echo "The tar file is not uncompressed."
exit
fi
#into the directory
cd /opt/work/libxml2
/opt/work/libxml2/configure --prefix=/usr/local
make&make install
#into the root directory
cd /
脚本已经结束,可以执行,但是执行的时候不能以./filename.sh的格式,而是必须以source filename.sh的格式来运行,否则在cd /opt/work/libxml2的时候会进不去,当然接下的脚本执行就会错误了!--这是我犯错的地方。
如果你要编译安装很多tar包,在linux下,依赖关系复杂,很常见,你可以用这种方法,自动安装,省去不少麻烦!
相关文章推荐
- CentOS6.7下使用非root用户(普通用户)编译安装与配置mysql数据库并使用shell脚本定时任务方式实现mysql数据库服务随机自动启动
- SHELL实现CentOS6,Ubuntu16下自动下载,编译安装LAMP
- shell脚本实现DNS的自动安装与配置
- Shell脚本实现在Linux系统中自动安装JDK
- Shell脚本实现应用自动安装部署
- Android自动化技术之自动monkey:shell脚本实现自动创建模拟器、启动模拟器、自动安装apk并进行monkey测试
- shell脚本实现linux下自动安装Oracle10g
- RPM包安装mysql,采用shell脚本实现自动安装、配置与卸载
- 坚持#第272天~zabbix监控(安装、配置、shell脚本自动实现)
- makefile shell下实现自动编译的脚本语言!
- shell脚本实现linux下自动安装Oracle10g
- shell脚本专题之-----------全自动编译安装mysql
- shell脚本实现msyql5.7全自动安装
- Shell脚本实现自动安装zookeeper
- Shell小脚本:实现自动安装Asterisk和DAHDI
- shell脚本实现自动创建模拟器、启动模拟器、自动安装apk并进行monkey测试
- 用tarball实现liferay自动安装部署5-shell 脚本概述
- shell脚本和ansible实践MariaDB源码编译自动安装
- Shell脚本实现在Linux系统中自动安装JDK
- Shell脚本实现自动安装zookeeper