自动化部署脚本文件目录:

运行主程序:./install.sh
#!/bin/bash
SCRIPTPATH=$(cd "$(dirname "$0")"; pwd)
Install_log=$SCRIPTPATH/install_log.txt
echo "***start install***" > $Install_log
echo " workspace is $SCRIPTPATH" | tee -a "$Install_log"
show_license() {
}
install_expect(){
}
install_unzip(){
}
install_killall(){
}
install_snmp(){
}
install_java(){
}
install_activemq(){
}
install_redis(){
}
install_systemdlib(){
}
install_postgres(){
}
stop_firewalld(){
}
auto_run_config(){
autostart.sh
}
#unzip simo and config simo
unzip_simo(){
}
run_simo(){
}
exit 0
init-data.sh脚本如下:
#!/usr/bin/expect
set timeout 900
set user postgres
spawn su $user
expect "bash-4.2*"
send "psql\r"
expect "postgres=#"
send "alter user postgres with password ‘postgres‘;\r"
expect "postgres=#"
send "create user uxsino with password ‘Uxs!nO10‘;\r"
expect "postgres=#"
send "create database simo_dev owner uxsino;\r"
expect "postgres=#"
send "GRANT ALL PRIVILEGES ON DATABASE simo_dev to uxsino;\r"
expect "postgres=#"
send "\\q\r"
expect "bash-4.2*"
send "exit\r"
expect eof
原文:https://www.cnblogs.com/zyy98877/p/9254451.html