在制作云环境的镜像时,有时候我们可能使用某个镜像创建几十个实例,如果镜像有某一个环节没有考虑周全,可能就会加大很多工作量,例如我们制作一个iserver的Ubuntu环境的镜像,前面博客已经介绍了怎么在该环境下进行安装,但是关于iserver的服务和许可是需要我们手动启动的,但是在实际云环境中,不可能让人工对几十个iserver实例都进行重复操作,所以就需要将iserver的开机自启动功能实现。
关于许可问题,这里面所谓的许可其实是一个试用许可,如果真正购买了iserver的正版许可可能不存在该问题,即便是使用临时许可,在镜像的许可设置完毕之后,新建实例的许可还需要重新设置,所以对于许可的开机自启动也需要考虑这个功能。
1、关于iserver的服务启动
只需要在简单部署包的bin目录下,找到startup.sh文件启动即可
sm@ubuntu2:~$ cd SuperMapiServer7C/bin/ sm@ubuntu2:~/SuperMapiServer7C/bin$ ls bootstrap.jar catalina-tasks.xml configtest.bat digest.bat iserver-info.jar passwordreset.sh setclasspath.sh shutdown.bat startup.bat tomcat-native.tar.gz version.bat catalina.bat commons-daemon.jar configtest.sh digest.sh iserver.sh service.bat setenv.bat shutdown.sh startup.sh tool-wrapper.bat version.sh catalina.sh commons-daemon-native.tar.gz daemon.sh iserver.bat passwordreset.bat setclasspath.bat setenv.sh sqlnet.log tomcat-juli.jar tool-wrapper.sh sm@ubuntu2:~/SuperMapiServer7C/bin$ ./startup.sh Using ISERVER_HOME: /home/sm/SuperMapiServer7C/webapps/iserver Using ISERVER_CONFIG: /home/sm/SuperMapiServer7C/webapps/iserver/WEB-INF Using UGO_HOME: /home/sm/SuperMapiServer7C/support/objectsjava/bin Using CATALINA_BASE: /home/sm/SuperMapiServer7C Using CATALINA_HOME: /home/sm/SuperMapiServer7C Using CATALINA_TMPDIR: /home/sm/SuperMapiServer7C/temp Using JRE_HOME: /home/sm/SuperMapiServer7C/support/jre Using CLASSPATH: /home/sm/SuperMapiServer7C/bin/bootstrap.jar:/home/sm/SuperMapiServer7C/bin/tomcat-juli.jar Tomcat started. sm@ubuntu2:~/SuperMapiServer7C/bin$ pwd /home/sm/SuperMapiServer7C/bin
2、关于iserver的许可重新注册
我们需要找到相关路径,使用root权限先执行dunst反注册许可,再执行dinst注册许可即可
sm@ubuntu2:~/SuperMapiServer7C/support/SuperMap_License/Support/aksusbd-2.4.1-i386$ pwd /home/sm/SuperMapiServer7C/support/SuperMap_License/Support/aksusbd-2.4.1-i386 sm@ubuntu2:~/SuperMapiServer7C/support/SuperMap_License/Support/aksusbd-2.4.1-i386$ ls aksusbd aksusbd.rc dinst dunst hasplmd hasp.rules hasp_update haspvlib_99235.so SuperMap Trial License .v2c winehasp sm@ubuntu2:~/SuperMapiServer7C/support/SuperMap_License/Support/aksusbd-2.4.1-i386$ sudo ./dunst [sudo] password for sm: dpkg-query: no packages found matching aksusbd Stopping HASP SRM RTE ... Stopping HASPLM daemon: . Stopping WINEHASP daemon: . Stopping AKSUSB daemon: . Removing files ... Done sm@ubuntu2:~/SuperMapiServer7C/support/SuperMap_License/Support/aksusbd-2.4.1-i386$ ./dinst Installer must be run as root Aborting... sm@ubuntu2:~/SuperMapiServer7C/support/SuperMap_License/Support/aksusbd-2.4.1-i386$ sudo ./dinst dpkg-query: no packages found matching aksusbd Copy AKSUSB daemon to /usr/sbin ... Copy WINEHASP daemon to /usr/sbin ... Copy HASPLMD daemon to /usr/sbin ... Copy start-up script to /etc/init.d ... Link HASP SRM runtime environment startup script to system startup folder Starting HASP SRM runtime environment... Starting AKSUSB daemon: . Starting WINEHASP daemon: . Starting HASPLM daemon: . Coping VLIB... Installing v2c... hasp_update failed with status 65 Done
设置开机自启动
其实开机自启动的也就是在/etc/init.d/文件夹里面设置相关的文件即可
1、为了保证创建文件的读写权限与默认一致,我们只需要cp一个默认的启动文件即可
sudo cp single iserver
2、删除iserver里面的所有信息
提示:直接执行“:1,$d”
然后添加如下信息即可,注意根据你自己的环境变量进行相关的修改
#!/bin/bash # #chkconfig:345 99 10 #description: StartupScriptforSupermapiServer export ISERVER_HOME=/home/sm/SuperMapiServer7C export LIC_HOME=/home/sm/SuperMapiServer7C/support/SuperMap_License/Support/aksusbd-2.4.1-i386 case "$1" in start) echo "-----startup iserver-----" echo "-----------------dunst lic-------------" cd $LIC_HOME sudo ./dunst echo "----------------dinst lic---------------" cd $LIC_HOME sudo ./dinst
<pre name="code" class="html">sh $ISERVER_HOME/bin/startup.shecho "-----startup iserver successful-----";;stop)echo "-----shutdown iserver-----"sh $ISERVER_HOME/bin/shutdown.shecho "-----shutdown iserver successful-----";;restart)echo "-----restart iserver-----"sh $ISERVER_HOME/bin/shutdown.shsh $ISERVER_HOME/bin/startup.shecho "-----restart iserver successful-----";;*) echo 'Usage:iserver start|stop|restart' ;;esacexit 0
3、把/etc/init.d/iserver设置成可执行
sm@ubuntu2:/etc/init.d$ sudo chmod +x /etc/init.d/iserver
sm@ubuntu2:/etc/init.d$ sudo update-rc.d iserver defaults
5、重启机器,测试是否可以
如果设置成功,用户也可以在ubuntu的启动信息可以查看到相关的执行信息