`
收藏列表
标题 标签 来源
获取硬件信息脚本
#!/bin/bash
#network
read -p 'Are you configuration of the network (yes/no)' aaa
if [ $aaa = yes ]
then
echo "
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback


auto eth0
allow-hotplug eth0
iface eth0 inet static
        address 192.168.2.205
        netmask 255.255.255.0
        gateway 192.168.2.1
        dns-nameservers 114.114.114.114
" > /etc/network/interfaces

echo "
nameserver 114.114.114.114">> /etc/resolv.conf
/etc/init.d/networking restart &>/dev/unll
fi

#peizhi xingxi
read -p 'Enter the machine serial number: ' bbb
echo 'NO.$bbb'
echo "######## kernel name #######" 
uname -a |cut -f2-3 -d ' '
echo "######## zhuban #######" 
dmidecode | grep 'Product Name'|tail -n1
echo "######## CPU #######" 
dmidecode -t processor |grep 'Version'
echo "######## neicun #######" 
dmidecode -t memory | grep 'Size\|Speed\|Manu'|grep -v 'No\|Un\|Dimm' 
echo "######## yingpan #######" 
cat /proc/scsi/scsi |grep 'Model\|Host' 
fdisk -l |grep sd 
echo "######## network card #######"
dmesg | grep eth
Tistone系统升级update.sh
#!/bin/bash
#update web
update_web()
{
if [ ! -f "/tmp/web.war" ];
then
echo 'Can not find /tmp/web.war'
return 1
fi

#copy web file to install folder
/home/database/web/stop_tomcat.sh
rm -rf /usr/local/tomcat6/webapps/web*
cp -f /tmp/web.war /usr/local/tomcat6/webapps/
chown database:database /usr/local/tomcat6/webapps/web.war

#restart web
cd /home/database/web
sudo -u database sh start_tomcat.sh

#Modify the configuration information
sleep 5
path='/usr/local/tomcat6/webapps/web/WEB-INF/classes'
if [ ! -x "$path" ]; 
then
echo 'Configuration file does not exist'
exit 1
fi
echo 'DO you want to use the same database and app (y/n)'
read ccc
case $ccc in
[yY])
	echo 'Please input local.address'
        read bbb
        bbb1=$bbb
        bbb2=$bbb
        bbb3=$bbb
        bbb4=$bbb
        bbb5=$bbb;;
[nN])
	echo 'Please input local.address='
	read bbb
	echo 'Please input nspms.address='
	read bbb1
	echo 'Please input demo.address='
	read bbb2	
        echo 'Please input reporter.ip='
	read bbb3
        echo 'Please input server.ip.reserved='
	read bbb4
        echo 'Please input updateC.ip='
	read bbb5
;;
	

*)
       echo "Please input {n|y}"
        return 1
        ;;
esac

#Modifying Database Scripts	
	aaa=`sed -n '/^local.address/=' $path/database.properties`
	sed -i ''$aaa's/.*/local.address='$bbb'/' $path/database.properties

	aaa=`sed -n '/^nspms.address/=' $path/database.properties`
        sed -i ''$aaa's/.*/nspms.address='$bbb1'/' $path/database.properties

	aaa=`sed -n '/^demo.address/=' $path/database.properties`
        sed -i ''$aaa's/.*/demo.address='$bbb2'/' $path/database.properties
#Modifying app Scripts
        aaa=`sed -n '/^reporter.ip/=' $path/app.properties`
        sed -i ''$aaa's/.*/reporter.ip='$bbb3'/' $path/app.properties

        aaa=`sed -n '/^server.ip.reserved/=' $path/app.properties`
        sed -i ''$aaa's/.*/server.ip.reserved='$bbb4'/' $path/app.properties

        aaa=`sed -n '/^updateC.ip/=' $path/app.properties`
        sed -i ''$aaa's/.*/updateC.ip='$bbb5'/' $path/app.properties

#restart web
/home/database/web/stop_tomcat.sh
sudo -u database sh start_tomcat.sh
return 0
}

#update icare
update_icare()
{
if [ ! -f "/tmp/icare" ];then
echo "can not find /tmp/icare"
return 1
fi

/etc/init.d/icare stop
sleep 2
ps -e|grep icare|grep -v grep
if [ $? -eq 0 ];then
echo "icare is not stop"
return 1
fi
cp /tmp/icare /icare/icare
chmod +x /icare/icare
/etc/init.d/icare start
return 0
}

#update database
update_database()
{
if [ ! -f "/tmp/tistone.sql" ];then
echo "can not find "/tmp/tistone.sql""
return 1
fi

if [ ! -f "/tmp/tistone_data.sql" ];then
echo "can not find "/tmp/tistone_data.sql""
return 1
fi
/etc/init.d/collector stop
echo "Upgrading the database ... please wait!"
mysql -uadmin -pcnSunet/1 < /tmp/tistone.sql && mysql -uadmin -pcnSunet/1 < /tmp/tistone_data.sql
/etc/init.d/collector start
}
#liebiao
while true;do
cat << EOF
********please select number for update:(1-4)****
*	(1) datebase				*
*	(2) web					*
*	(3) icare				*
*	(4) Exit Menu.				*
*************************************************
EOF
read -p "Now select the top option to: " input
case $input in
	1)update_database
	 if [ $? -eq 0 ]; then
        echo -e "\033[32;40;1mupdate database successful!\033[0m"
        else
        echo -e "\033[31;44;1mupdate database failure!\033[0m"
        fi;;	
	2)update_web
	 if [ $? -eq 0 ]; then
	echo -e "\033[32;40;1mupdate web successful!\033[0m"
	else
	echo -e "\033[31;44;1mupdate web failure!\033[0m"
	fi;;
	3)update_icare
	if [ $? -eq 0 ]; then
        echo -e "\033[32;40;1mupdate icare successful!\033[0m"
        else
        echo -e "\033[31;44;1mupdate icare failure!\033[0m"
        fi;;
	4)exit;;
	*)echo -e "\033[31;44;1mInvalid optione (1-4)\033[0m";;
esac
done
Global site tag (gtag.js) - Google Analytics