Tomcat 部署:使包含的脚本可执行
我正在 Windows 7 上使用 netbeans 开发 Web 应用程序(用于 Tomcat)。为了运行 Web 应用程序,我需要运行一次 insall 脚本。
这个脚本(用于 Windows 的 *.bat 和用于 Linux 的 *.sh 包含在我的战争文件 (WEB_INF) 中。
现在,每次我部署 WAR 文件并想要在 Linux 上运行该脚本时,我都必须
chmod +x install.sh
先调用。
是否有我不想在部署后执行一些额外的命令来使脚本可执行
。 我对 Linux 并不陌生,我知道如何设置文件的可执行权限。那不是问题。我的问题是:我必须做什么,以便在 tomcat 部署我的 *.war 文件(解压它)后该脚本可以立即执行。如果我也使用 Linux 进行开发,我会尝试根据我的源代码设置权限(也许当我有更多空闲时间时我会尝试它)。但我使用的是 Windows 和 netbeans。
我可以设置任何属性来实现我的目标吗?或者是否可以使用 ant 来实现这一目标?
顺便问一下:这种方法是否存在与安全相关的问题?该脚本查找 java 可执行文件并调用基于 java 的 GUI 安装程序...
I'm devellopping a WebApplication (for Tomcat) using netbeans on Windows 7. For the Webapplication to run I need to run a insall-script once.
This script (*.bat for windows and *.sh for linux is included in my war-file (WEB_INF).
Now everytime I deploy the WAR-file and want to run the script on linux I have to call
chmod +x install.sh
first.
Is there a way that this script can be made executable by default? I don't want to have to execute some extra commands after the deploy to make the script executable.
For clarification:
I'm not new to Linux and I know how to set executable-rights on files. That's not the problem. My problem is: What do I have to do, so that this script is executable right after tomcat deployed my *.war-file (unpacked it). If I would be using Linux for development as well, I would try to set the rights according in my sources (maybe I'll try it when I have a little more spare time). But I am using Windows and netbeans.
Are there any attributes I can set to achive my goal, or is it possible to achive this using ant?
By the way: Are there security related issues with this approach? The script looks for java executable and calls a javabased GUI-installer...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在应用程序初始化期间更改权限,如下:
允许您的应用程序在使用脚本之前设置可执行权限。在 tomcat 部署您的 war 文件之后、但在您的应用程序使用它之前,它不能立即执行。
Change permissions during initialization of the application, the following:
allows your application to set executable permissions before using the script. It is not executable right after tomcat deployed your war file but just before your application uses it.
假设您每次都调用相同的“install.sh”,则只需设置执行位一次。此外,只需为用户设置可执行位(您提供的命令将为每个人设置它)。
Assuming you are invoking the same "install.sh" everytime, you need to set the execute bit only once. Also, the executable bit need to be set only for the user (the command you have provided will set it for everyone).