bash 脚本编程十七 NFS client自动部署
来源:互联网 发布:mac桌面文件不显示桌面 编辑:程序博客网 时间:2024/06/03 15:36
1.自动检测并安装nfs-common,
2.自动创建目录并mount
3.同时检查/etc/fstab文件中是否有配置,没有则加入。确保下次开机能自动mount。
install.sh脚本:
#!/bin/bash source ../../common/tool.shnfsClient="nfs-common"nfsServerFolder=10.112.18.158:/opt/sharenfsClientFolder=~/test_nfs_dirhasDpkg $nfsClientr=$?if [ $r -eq 1 ]then echo "$nfsClient was installed"else echo "$nfsClient was not installed" apt-get install $nfsClientfi#config /opt/share as nfs foldercreateFolder $nfsClientFoldermount -t nfs4 $nfsServerFolder $nfsClientFoldermountString="$nfsServerFolder $nfsClientFolder nfs rsize=8192,wsize=8192,timeo=14,intr"searchString="$nfsServerFolder"mountConfigFile="/etc/fstab"findStringInFile $searchString $mountConfigFilem=$?if [ $m -eq 1 ]then echo "auto mount was configured"else echo "auto mount was not configured, configuring..." echo $mountString >> $mountConfigFilefi
这里用了一个新函数: findStringInFile
这个新函数放在tool.sh脚本中:
#$1 search string#$2 file path#return 1 if found#return 0 if not foundfunction findStringInFile { h=`grep "$1" $2` echo "h: $h" if [ -n "$h" ] thenreturn 1 elsereturn 0 fi}
- bash 脚本编程十七 NFS client自动部署
- bash 脚本编程十六 NFS server自动部署
- bash 脚本编程十一 JDK自动部署
- bash 脚本编程十四 maven自动部署
- bash 脚本编程十五 MySQL自动部署
- bash 脚本编程十八 Keepalived自动部署
- bash 脚本编程十九 Nginx自动部署
- bash 脚本编程十一 JDK自动部署
- bash 脚本编程二十 GlassFishV3自动部署
- bash 脚本编程二十一 MongoDB自动部署
- BASH脚本编程
- BASH脚本编程
- Bash脚本编程基础
- bash 脚本编程
- Linux-bash脚本编程
- bash 脚本编程
- 高级Bash脚本编程
- bash脚本自动部署war包到tomcat和切换nginx代理
- HBA卡
- Android之旅--HelloWorld进阶,代码分析
- 关于bos 分录添加附件的相关知识点
- SQL语句如何更改数据库名,表名,列名
- Android Log图文详解(Log.v,Log.d,Log.i,Log.w,Log.e)! .
- bash 脚本编程十七 NFS client自动部署
- java测试ping通源码
- 在IE下的JS编程需注意的内存释放问题 [转]
- sizeof strlen 比较
- 各个版本的Xcode/IOS SDK官网下载
- 羌笛声声胡笳怨,此心长寄天涯远
- 性能调优攻略
- Java 集合框架
- HTML5开发 Local Storage 本地存储