一键解决Linux安装ArcGIS Server系统环境准备问题
2011-12-22 17:19
651 查看
英文版
中文版
#!/bin/sh #Scripts to check the prerequisites to install ArcGIS Server. author:Qintong # Make sure this is being run as root. tmp_account=`id | cut -f2 -d\( | cut -f1 -d\)` if [ "$tmp_account" != "root" ] then echo " " echo "*** ERROR: This script must be run as root." echo " " exit 1 fi #Start to check the hostname hostname=`cat /etc/sysconfig/network|grep HOSTNAME|cut -d = -f2|sed 's/ //g'` if [ $hostname == "localhost.localdomain" ] then echo -e "The host name of this machine is localhost, which is not capable of ArcGIS Server. Please enter a new name:\n" read newHostName hostname $newHostName sed -i 's/HOSTNAME=localhost.localdomain/HOSTNAME='$newHostName'/g' /etc/sysconfig/network fi #Check the network ethNum=0 ethAddrs="" ethAddrs=`ls /etc/sysconfig/network-scripts|grep ifcfg-eth|cut -c 7-` ethNum=`ls /etc/sysconfig/network-scripts|grep ifcfg-eth|wc -l` if [ $ethNum == 1 ] then ipAddr=`cat /etc/sysconfig/network-scripts/ifcfg-eth* |grep IPADDR |cut -d = -f2` if [[ $ipAddr == "" ]] then echo "IP ADDRESS IS NOT PROPERLY SET. You must assign a static IP to a ethernet card!" exit 1 else echo -e "Please enter the domain name of this machine, eg. "$hostname".localdomain, to skip this enter 'skip'" read domainName [[ $domainName == "skip" ]] && break domainFlag=`$domainName | cut -d . -f2` [[ $domainFlag != "" ]] && sed -i -e 's/^127.0.0.1/#127.0.0.1/g' -e '$a\\'$ipAddr''$domainName' '$newHostName'' /etc/hosts || ([ $domainName != "skip" ] && echo "Wrong input, check the format") fi fi [[ $ethNum == 0 ]] && echo "No ethernet card." && exit 1 [[ $ethNum > 1 ]] && echo -e "You have multiple ethernet cards:\n" && echo $ethAddrs #Start to check the rpm dependency packsRequired="compat-libf2c-34 compat-libstdc++-33 compat-libstdc++-296 compat-openldap libXp openldap openssl gmp openmotif22 xorg-x11-fonts-base chkfontpath libFS libXfont libXmu libfontenc ttmkfdir xorg-x11-font-utils xorg-x11-xfs libidn" packs32Required="compat-libf2c-34 compat-libstdc++-33 compat-libstdc++-296 compat-openldap libXp openldap openssl openmotif22" packsAbsent=`rpm -q $packsRequired | grep "not installed" | cut -f2 -d\ |cut -f1 -d\ ` [ -n "$packsAbsent" ] && echo -e "The following rpms are completely absent on this system:\n" && echo "$packsAbsent" #Go ahead to check to 32bit availability for var in $packs32Required do i386flag=`rpm -ql $var | grep /lib/` [ -z "$i386flag" ] && echo -e "The i386 edition of $var is not available on this system, please install them manually from the operating system disc.\n" || echo -e "Fine! No problem with rpm dependency of $var.\n" done #Check the status of Firewall and SELinux firewallFlag=`service iptables status | grep stopped` SELinuxFlag=`getenforce` if [ "$firewallFlag" != "" ] then echo -e "Fine! $firewallFlag\n" else echo -e "The firewall is yet to be shuted down and disabled. Would you like to perform this? (y or Y)\n" read if [ "$REPLY" != "y" ] && [ "$REPLY" != "Y" ] && [ "$REPLY" != "" ] then exit 1 else service iptables stop chkconfig iptables off fi fi if [ "$SELinuxFlag"=="Disabled" ] then echo -e "Fine! The SELinux is disabled.\n" else echo -e "The SELinux policy is started and should be disabled. Would you like to squash it? (y or Y)\n" read if [ "$REPLY" != "y" ] && [ "$REPLY" != "Y" ] && [ "$REPLY" != "" ] then exit 1 else setenforce 0 sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config fi fi #Check the users userNum=0 users="" userNum=`cat /etc/passwd | awk -F: '$3>=500 && $3<1000' | cut -f 1 -d :|wc -l` users=`cat /etc/passwd | awk -F: '$3>=500 && $3<1000' | cut -f 1 -d :` echo -e "There are $userNum defined users in current system: \n$users\n\nIt is strongly recommended to add an OS user(REQUIRED for distributed deployment and caching) manually to manange ArcGIS Server. Would you like to add it now? (y or Y)" read if [ "$REPLY" != "y" ] && [ "$REPLY" != "Y" ] && [ "$REPLY" != "" ] then exit 1 else password1=1 password2=2 echo "Please input the user name: " read username until [[ $password1 == $password2 ]] do echo "Please input the password: " stty -echo read password1 stty echo echo "Please retype your password: " stty -echo read password2 stty echo if [[ $password1 != $password2 ]] then echo "Passwords not match!" continue else break fi done useradd $username -p $password1 fi echo "Congratulations! You are ready to setup ArcGIS Server now."
中文版
#!/bin/sh #ArcGIS Server的安装先决条件检查和设置. 作者:秦桐 # 确定以root身份登录 tmp_account=`id | cut -f2 -d\( | cut -f1 -d\)` if [ "$tmp_account" != "root" ] then echo " " echo "错误: 必须以root身份运行该脚本" echo " " exit 1 fi #开始检测主机名,如果是localhost要求替换 hostname=`cat /etc/sysconfig/network|grep HOSTNAME|cut -d = -f2|sed 's/ //g'` if [ $hostname == "localhost.localdomain" ] then echo -e "主机名是localhost,请修改为其他名称:\n" read newHostName hostname $newHostName sed -i 's/HOSTNAME=localhost.localdomain/HOSTNAME='$newHostName'/g' /etc/sysconfig/network fi #检测网络状况,检查当前系统中网卡数量,如果网卡正常,要求输入域名 ethNum=0 ethAddrs="" ethAddrs=`ls /etc/sysconfig/network-scripts|grep ifcfg-eth|cut -c 7-` ethNum=`ls /etc/sysconfig/network-scripts|grep ifcfg-eth|wc -l` if [ $ethNum == 1 ] then ipAddr=`cat /etc/sysconfig/network-scripts/ifcfg-eth* |grep IPADDR |cut -d = -f2` if [[ $ipAddr == "" ]] then echo "IP地址不存在,您必须为网卡指定一个静态IP" exit 1 else echo -e "请输入本机域名,例如 "$hostname".localdomain ,要跳过此步骤,请输入“skip”" read domainName domainFlag=`echo $domainName | cut -d . -f2` [[ $domainFlag != "" ]] && sed -i -e 's/^127.0.0.1/#127.0.0.1/g' -e '$a\\'$ipAddr''$domainName' '$newHostName'' /etc/hosts || ([ $domainName != "skip" ] && echo "输入错误,注意格式!") fi fi [[ $ethNum == 0 ]] && echo "没有网卡!" && exit 1 [[ $ethNum > 1 ]] && echo -e "您拥有多块网卡\n" && echo $ethAddrs #开始检测包依赖性 packsRequired="compat-libf2c-34 compat-libstdc++-33 compat-libstdc++-296 compat-openldap libXp openldap openssl gmp openmotif22 xorg-x11-fonts-base chkfontpath libFS libXfont libXmu libfontenc ttmkfdir xorg-x11-font-utils xorg-x11-xfs libidn" packs32Required="compat-libf2c-34 compat-libstdc++-33 compat-libstdc++-296 compat-openldap libXp openldap openssl openmotif22" packsAbsent=`rpm -q $packsRequired | grep "not installed" | cut -f2 -d\ |cut -f1 -d\ ` [ -n "$packsAbsent" ] && echo -e "以下依赖包完全没有安装(64位和32位):\n" && echo "$packsAbsent" #继续检查32位包可用性 for var in $packs32Required do i386flag=`rpm -ql $var | grep /lib/` [ -z "$i386flag" ] && echo -e "i386版本的 $var 在当前系统上未安装,请手动从操作系统光盘中安装。\n" || echo -e "$var 已安装,没有问题。\n" done #检测防火墙和SELinux状况并辅助解决 firewallFlag=`service iptables status | grep 已停` SELinuxFlag=`getenforce` if [ "$firewallFlag" != "" ] then echo -e "正常 $firewallFlag\n" else echo -e "防火墙没有被禁用和关闭,是否现在禁用? (y or Y)\n" read if [ "$REPLY" != "y" ] && [ "$REPLY" != "Y" ] && [ "$REPLY" != "" ] then exit 1 else service iptables stop chkconfig iptables off fi fi if [ "$SELinuxFlag"=="Disabled" ] then echo -e "正常。SELinux已禁用\n" else echo -e "SELinux未被禁用,是否现在禁用? (y or Y)\n" read if [ "$REPLY" != "y" ] && [ "$REPLY" != "Y" ] && [ "$REPLY" != "" ] then exit 1 else setenforce 0 sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config fi fi #检测ArcGIS Server安装所有者用户 userNum=0 users="" userNum=`cat /etc/passwd | awk -F: '$3>=500 && $3<1000' | cut -f 1 -d :|wc -l` users=`cat /etc/passwd | awk -F: '$3>=500 && $3<1000' | cut -f 1 -d :` echo -e "当前系统中有 $userNum 已定义的用户: \n$users\n\n强烈建议创建操作系统级别的所有者用户(在分布式部署和创建缓存切片时是必须的),是否现在创建? (y or Y)" read if [ "$REPLY" != "y" ] && [ "$REPLY" != "Y" ] && [ "$REPLY" != "" ] then exit 1 else password1=1 password2=2 echo "请输入用户名: " read username until [[ $password1 == $password2 ]] do echo "请输入密码 " stty -echo read password1 stty echo echo "请再次输入密码 " stty -echo read password2 stty echo if [[ $password1 != $password2 ]] then echo "密码不匹配,重新输入" continue else break fi done useradd $username -p $password1 fi echo "恭喜!满足安装条件,可以安装ArcGIS Server!"
相关文章推荐
- Linux系统安装mysql出现问题解决方法
- win 10系统下安装node/npm/webstrom环境遇到的问题及解决办法
- Linux下oracle10g的安装过程中遇到的部分环境验证问题的解决【转载】
- 解决Linux系统安装后,root用户无法登录,提示“无法验证用户”的错误问题
- 在linux系统下安装oracle前的准备工作(配置oracle环境变量)
- 解决Python工程依赖包无法自动安装的问题(Linux环境下)
- 高版本Linux系统无法安装Hi3515_SDK_V1.0.4.2.c1问题解决方法
- 解决虚拟机ubuntu系统安装VM TOOLS问题(其它LINUX系统也差不多)
- titanx pascal显卡工作站安装ubuntu系统及深度学习环境(解决了显示器HDMI超出频率的黑屏问题)
- Linux搭建python环境中cx_Oracle模块安装遇到的问题与解决方法
- 解决安装上其它系统后,linux无法启动的问题!
- RedMine项目管理系统安装问题(Linux版一键安装包)
- 远程访问linux环境安装图形界面问题解决汇总
- Android --- windows下搭建Linux环境下载编译Android源代码--解决下载android系统源码错误问题
- 解决Linux系统中Bioconductor安装程序包时RCurl和XML的依赖问题
- LAMP在Linux系统下的安装中遇到的问题与解决方法
- win8下使用vagrant安装部署Linux虚拟环境出错的问题解决
- 关于Linux系统安装oracle数据库的准备工作及安装过程中所遇问题
- 解决Linux环境下安装xampp之后外部无法连接MySQL的问题
- windows 7环境硬盘安装Fedora 18 双系统之问题解决