Linux中kettle自动化部署脚本

时间:2024-08-27 14:37:44

自己写的一个自动化在Linux中部署kettle的脚本,包括一些遇到的问题在脚本中都有涉及。

kettle是官网最新版本pdi-ce-6.1.0.1-196.zip

目前最新版本下载地址:https://sourceforge.net/projects/pentaho/files/latest/download?source=top3_dlp_t5

脚本:

 #!/bin/bash
#Record the current directory!
mulu=`pwd`
#The output of JAVA_HOME number of bytes
c=`echo $JAVA_HOME|wc -c`
echo "Tips:Install JDK!Configuration JAVA_HOME"
#Please install JDK if JAVA_HOME bytes is equal to 1 if [ $c -eq 1 ];then
echo "Please install JDK!"
#If Already configured JAVA_HOME,continue!Otherwise, the exit!
elif [ $? != 0 ];then
echo "Already configured JAVA_HOME!"
cd ~/.kettle/
#If there is a file .spoonrc,continue! if [ -f .spoonrc ];then
echo "Exist .spoonrc file!"
aa=`cat ~/.kettle/.spoonrc |grep ShowWelcomePageOnStartup |awk -F '=' '{print $2}'`
#If the ShowWelcomePageOnStartup command file is empty,continue! if [ ! $aa ];then
echo "Without ShowWelcomePageOnStartup=N, appended to the file!"
echo "ShowWelcomePageOnStartup=N" >> ~/.kettle/.spoonrc
#If the file in this command ShowWelcomePageOnStartup is not equal to N,continue!
elif [ $aa != "N" ];then
echo "ShowWelcomePageOnStartup is not equal to N, to modify ShowWelcomePageOnStartup is equal to N!"
sed -i "s/$aa/N/g" ~/.kettle/.spoonrc
fi #If there is no file .spoonrc
else
echo "There is no file .spoonrc,Created .spoonrc file and add command!"
echo "ShowWelcomePageOnStartup=N" > ~/.kettle/.spoonrc
fi
#Switch to the original directory!
cd $mulu
#If there is a directory "data-integration", enter the directory, otherwise unzip the package!
if [ -d "data-integration" ];then
echo "Directory exists, into the directory!"
cd data-integration
else
echo "Directory does not exist, unzip the package!"
unzip pdi-ce-6.1.0.1-196.zip
cd data-integration
fi
#Install graphical interface
yum -y groupinstall "X Window System"
#Open the graphical interface!
echo "Open the graphical interface!"
sh spoon.sh
fi

注:脚本和pdi-ce-6.1.0.1-196.zip压缩包放到同一目录下。直接sh这个脚本。此脚本直接启动图形化界面。