Skip to content

Commit

Permalink
Merge pull request #2847 from actiontech/fix_sqle_jdk
Browse files Browse the repository at this point in the history
SQLE安装包中集成Java
  • Loading branch information
iwanghc authored Jan 3, 2025
2 parents 8d070e7 + 1bc97ec commit 1749f87
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
18 changes: 18 additions & 0 deletions build/sqled.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Source0: %{name}.tar.gz
License: Commercial
Group: Actiontech
Prefix: /usr/local/sqle
AutoReq: no

%description
Acitontech Sqle
Expand Down Expand Up @@ -39,13 +40,15 @@ rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/local/sqle/bin
mkdir -p %{_builddir}/%{buildsubdir}/sqle/plugins
mkdir -p $RPM_BUILD_ROOT/usr/local/sqle/scripts
mkdir -p $RPM_BUILD_ROOT/usr/local/%{name}/jdk
cp %{_builddir}/%{buildsubdir}/sqle/bin/sqled $RPM_BUILD_ROOT/usr/local/sqle/bin/sqled
cp %{_builddir}/%{buildsubdir}/sqle/bin/scannerd $RPM_BUILD_ROOT/usr/local/sqle/bin/scannerd
cp -R %{_builddir}/%{buildsubdir}/sqle/plugins $RPM_BUILD_ROOT/usr/local/sqle/plugins
cp %{_builddir}/%{buildsubdir}/sqle/scripts/sqled.systemd $RPM_BUILD_ROOT/usr/local/sqle/scripts/sqled.systemd
cp %{_builddir}/%{buildsubdir}/sqle/scripts/sqled.initd $RPM_BUILD_ROOT/usr/local/sqle/scripts/sqled.initd
cp %{_builddir}/%{buildsubdir}/sqle/scripts/pt-online-schema-change.template $RPM_BUILD_ROOT/usr/local/sqle/scripts/pt-online-schema-change.template
# cp -R %{_builddir}/%{buildsubdir}/sqle/ui $RPM_BUILD_ROOT/usr/local/sqle/ui
cp -R %{_builddir}/%{buildsubdir}/%{name}/jdk/* $RPM_BUILD_ROOT/usr/local/%{name}/jdk

##########

Expand Down Expand Up @@ -146,12 +149,26 @@ max_lag_millis=1500
heartbeat_interval_millis=100
EOF

# 检查 .bashrc 文件是否存在
if [ -f ~/.bashrc ]; then
if grep -q "^export SQLE_JAVA_HOME=" ~/.bashrc; then
# 如果 SQLE_JAVA_HOME 已经存在,则更新其值
sed -i "s|^export SQLE_JAVA_HOME=.*|export SQLE_JAVA_HOME=$RPM_INSTALL_PREFIX/jdk|" ~/.bashrc
else
echo "export SQLE_JAVA_HOME=$RPM_INSTALL_PREFIX/jdk" >> ~/.bashrc
fi
else
echo "warn: .bashrc file not found."
fi
source ~/.bashrc

#chown
chown -R %{user_name}: $RPM_INSTALL_PREFIX

#chmod
find $RPM_INSTALL_PREFIX -type d -exec chmod 0750 {} \;
find $RPM_INSTALL_PREFIX -type f -exec chmod 0640 {} \;
find $RPM_INSTALL_PREFIX/jdk/bin -type f -exec chmod 0755 {} \;
chmod 0750 $RPM_INSTALL_PREFIX/bin/*
find $RPM_INSTALL_PREFIX/plugins -type f -exec chmod 0750 {} \;
chmod 0770 $RPM_INSTALL_PREFIX/etc
Expand Down Expand Up @@ -223,3 +240,4 @@ fi
/usr/local/sqle/scripts/sqled.initd
/usr/local/sqle/scripts/pt-online-schema-change.template
# /usr/local/sqle/ui/*
/usr/local/sqle/jdk/*
19 changes: 18 additions & 1 deletion build/sqled_with_dms.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Source0: %{name}.tar.gz
License: Commercial
Group: Actiontech
Prefix: /usr/local/%{name}
AutoReq: no

%description
Acitontech Sqle
Expand Down Expand Up @@ -40,6 +41,7 @@ rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/local/%{name}/bin
mkdir -p $RPM_BUILD_ROOT/usr/local/%{name}/etc
mkdir -p %{_builddir}/%{buildsubdir}/%{name}/plugins
mkdir -p $RPM_BUILD_ROOT/usr/local/%{name}/jdk
if [ %{edition} == 'trial' ]; then
cp %{_builddir}/%{buildsubdir}/dms/config_trial.yaml $RPM_BUILD_ROOT/usr/local/%{name}/etc/config.yaml
else
Expand All @@ -54,7 +56,7 @@ cp -R %{_builddir}/%{buildsubdir}/%{name}/plugins $RPM_BUILD_ROOT/usr/local/%{na
cp -R %{_builddir}/%{buildsubdir}/%{name}/scripts $RPM_BUILD_ROOT/usr/local/%{name}/scripts
cp %{_builddir}/%{buildsubdir}/dms/build/service-file-template/dms.systemd $RPM_BUILD_ROOT/usr/local/%{name}/scripts/dms.systemd
cp -R %{_builddir}/%{buildsubdir}/%{name}/static/* $RPM_BUILD_ROOT/usr/local/%{name}/static/

cp -R %{_builddir}/%{buildsubdir}/%{name}/jdk/* $RPM_BUILD_ROOT/usr/local/%{name}/jdk/

##########

Expand Down Expand Up @@ -158,12 +160,26 @@ max_lag_millis=1500
heartbeat_interval_millis=100
EOF

# 检查 .bashrc 文件是否存在
if [ -f ~/.bashrc ]; then
if grep -q "^export SQLE_JAVA_HOME=" ~/.bashrc; then
# 如果 SQLE_JAVA_HOME 已经存在,则更新其值
sed -i "s|^export SQLE_JAVA_HOME=.*|export SQLE_JAVA_HOME=$RPM_INSTALL_PREFIX/jdk|" ~/.bashrc
else
echo "export SQLE_JAVA_HOME=$RPM_INSTALL_PREFIX/jdk" >> ~/.bashrc
fi
else
echo "warn: .bashrc file not found."
fi
source ~/.bashrc

#chown
chown -R %{user_name}: $RPM_INSTALL_PREFIX

#chmod
find $RPM_INSTALL_PREFIX -type d -exec chmod 0750 {} \;
find $RPM_INSTALL_PREFIX -type f -exec chmod 0640 {} \;
find $RPM_INSTALL_PREFIX/jdk/bin -type f -exec chmod 0755 {} \;
chmod 0750 $RPM_INSTALL_PREFIX/bin/*
find $RPM_INSTALL_PREFIX/plugins -type f -exec chmod 0750 {} \;
chmod 0770 $RPM_INSTALL_PREFIX/etc
Expand Down Expand Up @@ -264,6 +280,7 @@ fi
/usr/local/%{name}/scripts/*
/usr/local/%{name}/static/*
/usr/local/%{name}/etc/config.yaml
/usr/local/%{name}/jdk/*


%config /usr/local/%{name}/etc/config.yaml
15 changes: 4 additions & 11 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,6 @@ check_env() {
return 1
fi
;;
sqle-db2-plugin.jar | sqle-oracle-plugin.jar|sqle-dm-plugin.jar|sqle-ob-for-oracle-plugin.jar) # todo 确认达梦和oboracle是否需要java1.8还是其他版本也可以
if check_java8; then
return 0
else
return 1
fi
;;
esac
return 0
}
Expand Down Expand Up @@ -294,15 +287,15 @@ install_plugin() {
if ! install_plugin_to_config "Oracle" "/logo/oracle.svg" "[\n {\n \"key\":\"service_name\",\n \"value\":\"XE\",\n \"desc\":\"service name\",\n \"type\":\"string\"\n }\n ]" ;then
return 1
fi
if ! install_plugin_to_plugin_config "sqle-oracle-plugin.jar" "java -jar $plugins_dir/sqle-oracle-plugin.jar" ;then
if ! install_plugin_to_plugin_config "sqle-oracle-plugin.jar" "$SQLE_JAVA_HOME/bin/java -jar $plugins_dir/sqle-oracle-plugin.jar" ;then
return 1
fi
;;
sqle-db2-plugin.jar)
if ! install_plugin_to_config "DB2" "/logo/db2.jpeg" "[\n {\n \"key\":\"database_name\",\n \"value\":\"\",\n \"desc\":\"数据库名\",\n \"type\":\"string\"\n }\n ]" ;then
return 1
fi
if ! install_plugin_to_plugin_config "sqle-db2-plugin.jar" "java -jar $plugins_dir/sqle-db2-plugin.jar" ;then
if ! install_plugin_to_plugin_config "sqle-db2-plugin.jar" "$SQLE_JAVA_HOME/bin/java -jar $plugins_dir/sqle-db2-plugin.jar" ;then
return 1
fi
;;
Expand Down Expand Up @@ -330,15 +323,15 @@ install_plugin() {
if ! install_plugin_to_config "DM" "/logo/dameng_db.png" "" ;then
return 1
fi
if ! install_plugin_to_plugin_config "sqle-dm-plugin.jar" "java -jar $plugins_dir/sqle-dm-plugin.jar" ;then
if ! install_plugin_to_plugin_config "sqle-dm-plugin.jar" "$SQLE_JAVA_HOME/bin/java -jar $plugins_dir/sqle-dm-plugin.jar" ;then
return 1
fi
;;
sqle-ob-for-oracle-plugin.jar)
if ! install_plugin_to_config "OceanBase For Oracle" "/logo/ob_for_oracle.png" "[\n {\n \"key\":\"service_name\",\n \"value\":\"SYS\",\n \"desc\":\"service name\",\n \"type\":\"string\"\n }\n ]" ;then
return 1
fi
if ! install_plugin_to_plugin_config "sqle-ob-for-oracle-plugin.jar" "java -jar $plugins_dir/sqle-ob-for-oracle-plugin.jar" ;then
if ! install_plugin_to_plugin_config "sqle-ob-for-oracle-plugin.jar" "$SQLE_JAVA_HOME/bin/java -jar $plugins_dir/sqle-ob-for-oracle-plugin.jar" ;then
return 1
fi
;;
Expand Down
2 changes: 1 addition & 1 deletion sqle/driver/plugin_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (pm *pluginManager) Start(pluginDir string, pluginConfigList []config.Plugi
}

if len(cmdArgs) == 0 && strings.HasSuffix(p.Name(), ".jar") {
javaPluginCmd := fmt.Sprintf("java -jar %s", cmdBase)
javaPluginCmd := fmt.Sprintf("$SQLE_JAVA_HOME/bin/java -jar %s", cmdBase)
cmdBase = "sh"
cmdArgs = append(cmdArgs, "-c", javaPluginCmd)
}
Expand Down

0 comments on commit 1749f87

Please sign in to comment.