save
Showing
34 changed files
with
212 additions
and
93 deletions
| ... | @@ -136,7 +136,7 @@ | ... | @@ -136,7 +136,7 @@ |
| 136 | <dependency> | 136 | <dependency> |
| 137 | <groupId>org.emercit</groupId> | 137 | <groupId>org.emercit</groupId> |
| 138 | <artifactId>utilstools</artifactId> | 138 | <artifactId>utilstools</artifactId> |
| 139 | <version>1.0</version> | 139 | <version>1.2</version> |
| 140 | </dependency> | 140 | </dependency> |
| 141 | 141 | ||
| 142 | </dependencies> | 142 | </dependencies> | ... | ... |
No preview for this file type
| 1 | 16117fd6379ed57fe0046bb0de18f258 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 03ad0f7dfd1c45c0bfabd9c6e6c206beb59ade83 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 4 | <modelVersion>4.0.0</modelVersion> | ||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>utilstools</artifactId> | ||
| 7 | <version>1.1</version> | ||
| 8 | </project> |
| 1 | 1bb9f90634c777d837381876fea9bb9b | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 4f195a8499993e1608ea8cab6e16687c20c0b8dd | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
No preview for this file type
| 1 | c81e13b606304cd62e0b9f43381a9221 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 55ce6c05f1d2023c2069fab505ca16dec6fb4266 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 4 | <modelVersion>4.0.0</modelVersion> | ||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>utilstools</artifactId> | ||
| 7 | <version>1.2</version> | ||
| 8 | </project> |
| 1 | 79193d5fe0cbd1646a94084ff100e35f | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 88dcd98566f7be34a2427cc4d4a876f540c9c836 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -3,10 +3,12 @@ | ... | @@ -3,10 +3,12 @@ |
| 3 | <groupId>org.emercit</groupId> | 3 | <groupId>org.emercit</groupId> |
| 4 | <artifactId>utilstools</artifactId> | 4 | <artifactId>utilstools</artifactId> |
| 5 | <versioning> | 5 | <versioning> |
| 6 | <release>1.0</release> | 6 | <release>1.2</release> |
| 7 | <versions> | 7 | <versions> |
| 8 | <version>1.0</version> | 8 | <version>1.0</version> |
| 9 | <version>1.1</version> | ||
| 10 | <version>1.2</version> | ||
| 9 | </versions> | 11 | </versions> |
| 10 | <lastUpdated>20150729072820</lastUpdated> | 12 | <lastUpdated>20150729141622</lastUpdated> |
| 11 | </versioning> | 13 | </versioning> |
| 12 | </metadata> | 14 | </metadata> | ... | ... |
| ... | @@ -43,57 +43,31 @@ public class DevControlController { | ... | @@ -43,57 +43,31 @@ public class DevControlController { |
| 43 | @RequestMapping(value="devcontrol/ntp" , method = RequestMethod.POST) | 43 | @RequestMapping(value="devcontrol/ntp" , method = RequestMethod.POST) |
| 44 | public @ResponseBody boolean changeNtp(@RequestBody DateInfo m) { | 44 | public @ResponseBody boolean changeNtp(@RequestBody DateInfo m) { |
| 45 | 45 | ||
| 46 | return DevControlService.INSTANCE.ChangeNtp(m.ntp); | 46 | return DevControlService.INSTANCE.ChangeNtp(m.getNtp()); |
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | } | 47 | } |
| 51 | 48 | ||
| 52 | |||
| 53 | @RequestMapping(value = "devcontrol/dateinfo", method = RequestMethod.GET) | 49 | @RequestMapping(value = "devcontrol/dateinfo", method = RequestMethod.GET) |
| 54 | public @ResponseBody DateInfo getDi() { | 50 | public @ResponseBody DateInfo getDi() { |
| 55 | 51 | ||
| 56 | 52 | return DevControlService.INSTANCE.getDateInfo(); | |
| 57 | return DevControlService.INSTANCE.getDateInfo(); | ||
| 58 | |||
| 59 | } | 53 | } |
| 60 | 54 | ||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | |||
| 65 | @RequestMapping(value = "devcontrol/reboot", method = RequestMethod.GET) | 55 | @RequestMapping(value = "devcontrol/reboot", method = RequestMethod.GET) |
| 66 | public @ResponseBody boolean DevReboot() { | 56 | public @ResponseBody boolean DevReboot() { |
| 67 | |||
| 68 | 57 | ||
| 69 | DevControlService.INSTANCE.Reboot(); | 58 | DevControlService.INSTANCE.Reboot(); |
| 70 | 59 | ||
| 71 | return true; | 60 | return true; |
| 72 | |||
| 73 | } | 61 | } |
| 74 | 62 | ||
| 75 | |||
| 76 | |||
| 77 | @RequestMapping(value = "devcontrol/calibration", method = RequestMethod.GET) | 63 | @RequestMapping(value = "devcontrol/calibration", method = RequestMethod.GET) |
| 78 | public @ResponseBody boolean DvCalibration() { | 64 | public @ResponseBody boolean DvCalibration() { |
| 79 | 65 | ||
| 80 | 66 | DevControlService.INSTANCE.Calibration(); | |
| 81 | DevControlService.INSTANCE.Calibration(); | ||
| 82 | 67 | ||
| 83 | return true; | 68 | return true; |
| 84 | |||
| 85 | } | 69 | } |
| 86 | |||
| 87 | |||
| 88 | |||
| 89 | |||
| 90 | 70 | ||
| 91 | } | 71 | } |
| 92 | 72 | ||
| 93 | 73 | ||
| 94 | /* | ||
| 95 | url: 'api/devcontrol/ntp', | ||
| 96 | url: 'api/devcontrol/reboot', | ||
| 97 | url: 'api/devcontrol/off', | ||
| 98 | url: 'api/devcontrol/dateinfo', | ||
| 99 | */ | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -32,7 +32,7 @@ import java.util.Vector; | ... | @@ -32,7 +32,7 @@ import java.util.Vector; |
| 32 | import org.emercit.devtools.service.EthService; | 32 | import org.emercit.devtools.service.EthService; |
| 33 | import org.emercit.devtools.service.RemoteServerManager; | 33 | import org.emercit.devtools.service.RemoteServerManager; |
| 34 | import org.emercit.ethmanager.model.EthBean; | 34 | import org.emercit.ethmanager.model.EthBean; |
| 35 | import org.emercit.remoteservers.model.RemoteServerBean; | 35 | import org.emercit.servers.model.ServerBean; |
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | 38 | ||
| ... | @@ -44,7 +44,7 @@ public class RemoteServerController { | ... | @@ -44,7 +44,7 @@ public class RemoteServerController { |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | @RequestMapping(value = "remoteserver/bytype/{type}", method = RequestMethod.GET) | 46 | @RequestMapping(value = "remoteserver/bytype/{type}", method = RequestMethod.GET) |
| 47 | public @ResponseBody RemoteServerBean getRemoteServerByType(@PathVariable String type) { | 47 | public @ResponseBody ServerBean getRemoteServerByType(@PathVariable String type) { |
| 48 | 48 | ||
| 49 | return RemoteServerManager.INSTANCE.getByType(type); | 49 | return RemoteServerManager.INSTANCE.getByType(type); |
| 50 | 50 | ||
| ... | @@ -54,7 +54,7 @@ public class RemoteServerController { | ... | @@ -54,7 +54,7 @@ public class RemoteServerController { |
| 54 | 54 | ||
| 55 | 55 | ||
| 56 | @RequestMapping(value="remoteserver/update" , method = RequestMethod.POST) | 56 | @RequestMapping(value="remoteserver/update" , method = RequestMethod.POST) |
| 57 | public @ResponseBody boolean update(@RequestBody RemoteServerBean b) { | 57 | public @ResponseBody boolean update(@RequestBody ServerBean b) { |
| 58 | 58 | ||
| 59 | return RemoteServerManager.INSTANCE.Update(b); | 59 | return RemoteServerManager.INSTANCE.Update(b); |
| 60 | 60 | ... | ... |
| ... | @@ -27,7 +27,7 @@ public enum DevControlService { | ... | @@ -27,7 +27,7 @@ public enum DevControlService { |
| 27 | DateInfo dateinfo=new DateInfo(); | 27 | DateInfo dateinfo=new DateInfo(); |
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | dateinfo.ntp=ntplinux.getUseNtpServer(); | 30 | dateinfo.setNtp(ntplinux.getUseNtpServer()); |
| 31 | 31 | ||
| 32 | Calendar calendar = Calendar.getInstance(); | 32 | Calendar calendar = Calendar.getInstance(); |
| 33 | 33 | ||
| ... | @@ -37,7 +37,7 @@ public enum DevControlService { | ... | @@ -37,7 +37,7 @@ public enum DevControlService { |
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | Date date=calendar.getTime(); | 39 | Date date=calendar.getTime(); |
| 40 | dateinfo.dt = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date()); | 40 | dateinfo.setDt(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date())); |
| 41 | 41 | ||
| 42 | return dateinfo; | 42 | return dateinfo; |
| 43 | } | 43 | } | ... | ... |
| ... | @@ -6,7 +6,7 @@ import org.emercit.model.IPAddressValidator; | ... | @@ -6,7 +6,7 @@ import org.emercit.model.IPAddressValidator; |
| 6 | 6 | ||
| 7 | import org.emercit.devinfo.model.DevInfoBean; | 7 | import org.emercit.devinfo.model.DevInfoBean; |
| 8 | 8 | ||
| 9 | import org.emercit.devinfo.service.DevInfoImpl; | 9 | import org.emercit.devinfo.service.DevInfo; |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | 12 | ||
| ... | @@ -14,17 +14,16 @@ public enum DevInfoService { | ... | @@ -14,17 +14,16 @@ public enum DevInfoService { |
| 14 | 14 | ||
| 15 | INSTANCE; | 15 | INSTANCE; |
| 16 | 16 | ||
| 17 | private DevInfoImpl devinfo= new DevInfoImpl(); | 17 | private DevInfo devinfo= new DevInfo(); |
| 18 | |||
| 19 | 18 | ||
| 20 | public DevInfoBean get() { | 19 | public DevInfoBean get() { |
| 21 | 20 | ||
| 22 | return devinfo.Get(); | 21 | return devinfo.get(); |
| 23 | } | 22 | } |
| 24 | 23 | ||
| 25 | public boolean set(DevInfoBean m) { | 24 | public boolean set(DevInfoBean m) { |
| 26 | 25 | ||
| 27 | return devinfo.Set(m); | 26 | return devinfo.set(m); |
| 28 | } | 27 | } |
| 29 | 28 | ||
| 30 | } | 29 | } | ... | ... |
| ... | @@ -7,31 +7,27 @@ import org.emercit.model.IPAddressValidator; | ... | @@ -7,31 +7,27 @@ import org.emercit.model.IPAddressValidator; |
| 7 | import java.util.Vector; | 7 | import java.util.Vector; |
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | import org.emercit.remoteservers.model.RemoteServerBean; | 10 | import org.emercit.servers.model.ServerBean; |
| 11 | import org.emercit.remoteserver.service.RemSrv; | 11 | import org.emercit.servers.service.Servers; |
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | public enum RemoteServerManager { | 12 | public enum RemoteServerManager { |
| 16 | 13 | ||
| 17 | INSTANCE; | 14 | INSTANCE; |
| 18 | 15 | ||
| 19 | private RemSrv store=new RemSrv(); | 16 | private Servers store=new Servers(); |
| 20 | 17 | ||
| 21 | private Vector<RemoteServerBean> beans; | 18 | private Vector<ServerBean> beans; |
| 22 | 19 | ||
| 23 | 20 | ||
| 24 | public Vector<RemoteServerBean> getAll() { | 21 | public Vector<ServerBean> getAll() { |
| 25 | return store.get(); | 22 | return store.get(); |
| 26 | 23 | ||
| 27 | } | 24 | } |
| 28 | 25 | ||
| 29 | 26 | public ServerBean getByType(String type) { | |
| 30 | public RemoteServerBean getByType(String type) { | ||
| 31 | 27 | ||
| 32 | beans=store.get(); | 28 | beans=store.get(); |
| 33 | 29 | ||
| 34 | for (RemoteServerBean b:beans) { | 30 | for (ServerBean b:beans) { |
| 35 | 31 | ||
| 36 | if (b.getType().equals(type)) { | 32 | if (b.getType().equals(type)) { |
| 37 | return b; | 33 | return b; |
| ... | @@ -42,11 +38,11 @@ public enum RemoteServerManager { | ... | @@ -42,11 +38,11 @@ public enum RemoteServerManager { |
| 42 | } | 38 | } |
| 43 | 39 | ||
| 44 | 40 | ||
| 45 | public boolean Update(RemoteServerBean b) { | 41 | public boolean Update(ServerBean b) { |
| 46 | 42 | ||
| 47 | beans=store.get(); | 43 | beans=store.get(); |
| 48 | 44 | ||
| 49 | for (RemoteServerBean bean:beans) { | 45 | for (ServerBean bean:beans) { |
| 50 | 46 | ||
| 51 | 47 | ||
| 52 | if (bean.getId()==b.getId()) { | 48 | if (bean.getId()==b.getId()) { | ... | ... |
DevTools/src/main/resources/log4j.xml
100755 → 100644
| ... | @@ -10,26 +10,53 @@ | ... | @@ -10,26 +10,53 @@ |
| 10 | </layout> | 10 | </layout> |
| 11 | </appender> | 11 | </appender> |
| 12 | 12 | ||
| 13 | <appender name="file" class="org.apache.log4j.FileAppender"> | ||
| 14 | <param name="File" value="/var/log/devtools.log" /> | ||
| 15 | <layout class="org.apache.log4j.PatternLayout"> | ||
| 16 | <param name="ConversionPattern" value="%-7p %d [%t] %c %x - %m%n"/> | ||
| 17 | </layout> | ||
| 18 | </appender> | ||
| 19 | |||
| 20 | |||
| 13 | <!-- Application Loggers --> | 21 | <!-- Application Loggers --> |
| 14 | <logger name="org.emercit.app"> | 22 | <logger name="org.emercit.app"> |
| 23 | |||
| 24 | <level value="info" /> | ||
| 25 | <appender-ref ref="console" /> | ||
| 26 | <appender-ref ref="file" /> | ||
| 27 | </logger> | ||
| 28 | |||
| 29 | |||
| 30 | <logger name="org.emercit"> | ||
| 15 | <level value="info" /> | 31 | <level value="info" /> |
| 32 | <appender-ref ref="console" /> | ||
| 33 | <appender-ref ref="file" /> | ||
| 16 | </logger> | 34 | </logger> |
| 17 | 35 | ||
| 18 | <!-- 3rdparty Loggers --> | 36 | |
| 37 | <!-- rdparty Loggers --> | ||
| 19 | <logger name="org.springframework.core"> | 38 | <logger name="org.springframework.core"> |
| 20 | <level value="info" /> | 39 | <level value="info" /> |
| 40 | <appender-ref ref="console" /> | ||
| 41 | <appender-ref ref="file" /> | ||
| 21 | </logger> | 42 | </logger> |
| 22 | 43 | ||
| 23 | <logger name="org.springframework.beans"> | 44 | <logger name="org.springframework.beans"> |
| 24 | <level value="info" /> | 45 | <level value="info" /> |
| 46 | <appender-ref ref="console" /> | ||
| 47 | <appender-ref ref="file" /> | ||
| 25 | </logger> | 48 | </logger> |
| 26 | 49 | ||
| 27 | <logger name="org.springframework.context"> | 50 | <logger name="org.springframework.context"> |
| 28 | <level value="info" /> | 51 | <level value="info" /> |
| 52 | <appender-ref ref="console" /> | ||
| 53 | <appender-ref ref="file" /> | ||
| 29 | </logger> | 54 | </logger> |
| 30 | 55 | ||
| 31 | <logger name="org.springframework.web"> | 56 | <logger name="org.springframework.web"> |
| 32 | <level value="info" /> | 57 | <level value="info" /> |
| 58 | <appender-ref ref="console" /> | ||
| 59 | <appender-ref ref="file" /> | ||
| 33 | </logger> | 60 | </logger> |
| 34 | 61 | ||
| 35 | <!-- Root Logger --> | 62 | <!-- Root Logger --> |
| ... | @@ -38,4 +65,4 @@ | ... | @@ -38,4 +65,4 @@ |
| 38 | <appender-ref ref="console" /> | 65 | <appender-ref ref="console" /> |
| 39 | </root> | 66 | </root> |
| 40 | 67 | ||
| 41 | </log4j:configuration> | 68 | </log4j:configuration> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -12,6 +12,7 @@ | ... | @@ -12,6 +12,7 @@ |
| 12 | <attribute name="maven.pomderived" value="true"/> | 12 | <attribute name="maven.pomderived" value="true"/> |
| 13 | </attributes> | 13 | </attributes> |
| 14 | </classpathentry> | 14 | </classpathentry> |
| 15 | <classpathentry including="**/*.java" kind="src" path="src/main/resources"/> | ||
| 15 | <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | 16 | <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> |
| 16 | <attributes> | 17 | <attributes> |
| 17 | <attribute name="maven.pomderived" value="true"/> | 18 | <attribute name="maven.pomderived" value="true"/> | ... | ... |
| ... | @@ -49,10 +49,12 @@ | ... | @@ -49,10 +49,12 @@ |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | <dependency> | 51 | <dependency> |
| 52 | <groupId>log4j</groupId> | 52 | <groupId>log4j</groupId> |
| 53 | <artifactId>log4j</artifactId> | 53 | <artifactId>log4j</artifactId> |
| 54 | <version>1.2.17</version> | 54 | <version>1.2.14</version> |
| 55 | </dependency> | 55 | <type>jar</type> |
| 56 | <scope>compile</scope> | ||
| 57 | </dependency> | ||
| 56 | 58 | ||
| 57 | 59 | ||
| 58 | <dependency> | 60 | <dependency> | ... | ... |
| ... | @@ -6,13 +6,16 @@ import java.io.InputStreamReader; | ... | @@ -6,13 +6,16 @@ import java.io.InputStreamReader; |
| 6 | import java.util.List; | 6 | import java.util.List; |
| 7 | import java.util.ArrayList; | 7 | import java.util.ArrayList; |
| 8 | import java.util.Random; | 8 | import java.util.Random; |
| 9 | |||
| 10 | import java.util.Vector; | 9 | import java.util.Vector; |
| 11 | 10 | ||
| 11 | import org.apache.log4j.Logger; | ||
| 12 | import org.emercit.devinfo.service.DevInfo; | ||
| 13 | |||
| 12 | 14 | ||
| 13 | 15 | ||
| 14 | public class CmdExec { | 16 | public class CmdExec { |
| 15 | 17 | ||
| 18 | private static final Logger log = Logger.getLogger(CmdExec.class); | ||
| 16 | 19 | ||
| 17 | public Vector<String> Run(String cmd) throws Exception { | 20 | public Vector<String> Run(String cmd) throws Exception { |
| 18 | 21 | ||
| ... | @@ -24,7 +27,10 @@ public class CmdExec { | ... | @@ -24,7 +27,10 @@ public class CmdExec { |
| 24 | proc.waitFor(); | 27 | proc.waitFor(); |
| 25 | BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream())); | 28 | BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream())); |
| 26 | while(br.ready()) { | 29 | while(br.ready()) { |
| 27 | v.add(br.readLine()); | 30 | |
| 31 | String message=br.readLine(); | ||
| 32 | v.add(message); | ||
| 33 | log.info(message); | ||
| 28 | } | 34 | } |
| 29 | 35 | ||
| 30 | return v; | 36 | return v; | ... | ... |
| ... | @@ -2,12 +2,9 @@ package org.emercit.projecttools.constants; | ... | @@ -2,12 +2,9 @@ package org.emercit.projecttools.constants; |
| 2 | 2 | ||
| 3 | public class Paths { | 3 | public class Paths { |
| 4 | 4 | ||
| 5 | 5 | public static final String dirBeans="/opt/apps/beans/"; | |
| 6 | 6 | public static final String dirScripts="/opt/apps/scripts/"; | |
| 7 | private static final String dirBeans="/opt/apps/beans/"; | 7 | public static final String dirInit_d="/etc/init.d"; |
| 8 | private static final String dirScripts="/opt/apps/scripts/"; | ||
| 9 | private static final String dirInit_d="/etc/init.d"; | ||
| 10 | |||
| 11 | 8 | ||
| 12 | //BEANS | 9 | //BEANS |
| 13 | public static final String BEAN_GSM=dirBeans+"GSMBean.xml"; | 10 | public static final String BEAN_GSM=dirBeans+"GSMBean.xml"; |
| ... | @@ -23,12 +20,7 @@ public class Paths { | ... | @@ -23,12 +20,7 @@ public class Paths { |
| 23 | public static final String FINDPROCESS_SCRIPT=dirScripts+"findprocess.sh"; | 20 | public static final String FINDPROCESS_SCRIPT=dirScripts+"findprocess.sh"; |
| 24 | 21 | ||
| 25 | //PROCESS | 22 | //PROCESS |
| 26 | public static final String PROC_JETTY=dirInit_d+"jetty"; | 23 | public static final String JETTY="jetty"; |
| 27 | public static final String PROC_CTRLPNL=dirInit_d+"ctrlpnl"; | 24 | public static final String CTRLPNL="ctrlpnl"; |
| 28 | public static final String PROC_SNMPAGENT=dirInit_d+"snmpagent"; | ||
| 29 | public static final String PROC_SNMPCLIENT=dirInit_d+"snmpclient"; | ||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | 25 | ||
| 34 | } | 26 | } | ... | ... |
| ... | @@ -32,6 +32,14 @@ private static final long serialVersionUID = 1L; | ... | @@ -32,6 +32,14 @@ private static final long serialVersionUID = 1L; |
| 32 | this.id=value; | 32 | this.id=value; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | public void setProcess(String value) { | ||
| 36 | this.process=value; | ||
| 37 | } | ||
| 38 | |||
| 39 | public String getProcess() { | ||
| 40 | return process; | ||
| 41 | } | ||
| 42 | |||
| 35 | public boolean getAutostart() { | 43 | public boolean getAutostart() { |
| 36 | return autostart; | 44 | return autostart; |
| 37 | } | 45 | } | ... | ... |
| ... | @@ -6,10 +6,19 @@ import org.emercit.svmanager.model.SvBean; | ... | @@ -6,10 +6,19 @@ import org.emercit.svmanager.model.SvBean; |
| 6 | import org.emercit.xmldbmanager.service.Db; | 6 | import org.emercit.xmldbmanager.service.Db; |
| 7 | import org.emercit.projecttools.constants.Paths; | 7 | import org.emercit.projecttools.constants.Paths; |
| 8 | 8 | ||
| 9 | import org.emercit.svmanager.service.SvControl; | ||
| 10 | |||
| 11 | |||
| 9 | public class Sv { | 12 | public class Sv { |
| 10 | 13 | ||
| 11 | public Db db=new Db(Paths.BEAN_SV); | 14 | public Db db=new Db(Paths.BEAN_SV); |
| 12 | 15 | ||
| 16 | private SvBean svbean; | ||
| 17 | |||
| 18 | private Vector<SvBean> svbeans; | ||
| 19 | |||
| 20 | private SvControl svcontrol; | ||
| 21 | |||
| 13 | public void set(Vector<SvBean> m) { | 22 | public void set(Vector<SvBean> m) { |
| 14 | 23 | ||
| 15 | db.create(m); | 24 | db.create(m); |
| ... | @@ -19,5 +28,38 @@ public class Sv { | ... | @@ -19,5 +28,38 @@ public class Sv { |
| 19 | 28 | ||
| 20 | return (Vector<SvBean>)db.select(); | 29 | return (Vector<SvBean>)db.select(); |
| 21 | } | 30 | } |
| 22 | 31 | ||
| 32 | public void init() { | ||
| 33 | |||
| 34 | svbeans=new Vector<SvBean>(); | ||
| 35 | |||
| 36 | // jetty | ||
| 37 | svbean=new SvBean(); | ||
| 38 | svbean.setId(0); | ||
| 39 | svbean.setProcess(Paths.JETTY); | ||
| 40 | svbean.setAutostart(true); | ||
| 41 | svbean.setIsrun(true); | ||
| 42 | svbeans.add(svbean); | ||
| 43 | |||
| 44 | // ctrlpnl | ||
| 45 | svbean=new SvBean(); | ||
| 46 | svbean.setId(1); | ||
| 47 | svbean.setProcess(Paths.CTRLPNL); | ||
| 48 | svbean.setAutostart(true); | ||
| 49 | svbean.setIsrun(true); | ||
| 50 | svbeans.add(svbean); | ||
| 51 | |||
| 52 | set(svbeans); | ||
| 53 | |||
| 54 | for (SvBean sv:svbeans ) { | ||
| 55 | |||
| 56 | svcontrol=new SvControl(sv.getProcess()); | ||
| 57 | |||
| 58 | if (sv.getAutostart()) { | ||
| 59 | svcontrol.addAutoRun(); | ||
| 60 | }else { | ||
| 61 | svcontrol.delAutoRun(); | ||
| 62 | } | ||
| 63 | } | ||
| 64 | } | ||
| 23 | } | 65 | } | ... | ... |
| ... | @@ -3,36 +3,56 @@ package org.emercit.svmanager.service; | ... | @@ -3,36 +3,56 @@ package org.emercit.svmanager.service; |
| 3 | 3 | ||
| 4 | import org.emercit.pckutils.cmd.CmdExec; | 4 | import org.emercit.pckutils.cmd.CmdExec; |
| 5 | 5 | ||
| 6 | import org.emercit.projecttools.constants.Paths; | ||
| 7 | |||
| 6 | public class SvControl implements ISvControl { | 8 | public class SvControl implements ISvControl { |
| 7 | 9 | ||
| 8 | private CmdExec cmdexec=new CmdExec(); | 10 | private CmdExec cmdexec=new CmdExec(); |
| 9 | 11 | ||
| 10 | private String process; | 12 | private String process; |
| 11 | 13 | ||
| 12 | public SvControl(String value) { | 14 | public SvControl(String process) { |
| 13 | 15 | ||
| 14 | this.process=value; | 16 | this.process=process; |
| 15 | } | 17 | } |
| 16 | 18 | ||
| 17 | public boolean stop() { | 19 | public boolean stop() { |
| 18 | 20 | ||
| 19 | try { cmdexec.Run(process+" "+"stop"); }catch(Exception e) { return false; }; | 21 | try { cmdexec.Run(Paths.dirInit_d+" "+process+" "+"stop"); }catch(Exception e) { return false; }; |
| 20 | 22 | ||
| 21 | return true; | 23 | return true; |
| 22 | } | 24 | } |
| 23 | 25 | ||
| 24 | public boolean start() { | 26 | public boolean start() { |
| 25 | 27 | ||
| 26 | try { cmdexec.Run(process+" "+"start"); }catch(Exception e) { return false; }; | 28 | try { cmdexec.Run(Paths.dirInit_d+process+" "+"start"); }catch(Exception e) { return false; }; |
| 27 | 29 | ||
| 28 | return true; | 30 | return true; |
| 29 | } | 31 | } |
| 30 | 32 | ||
| 31 | public boolean restart() { | 33 | public boolean restart() { |
| 32 | 34 | ||
| 33 | try { cmdexec.Run(process+" "+"restart"); }catch(Exception e) { return false; }; | 35 | try { cmdexec.Run(Paths.dirInit_d+process+" "+"restart"); }catch(Exception e) { return false; }; |
| 36 | |||
| 37 | return true; | ||
| 38 | } | ||
| 39 | |||
| 40 | public boolean addAutoRun() { | ||
| 41 | |||
| 42 | try { cmdexec.Run("update-rc.d "+process+" default"); }catch(Exception e) { return false; }; | ||
| 34 | 43 | ||
| 35 | return true; | 44 | return true; |
| 36 | } | 45 | } |
| 46 | |||
| 47 | public boolean delAutoRun() { | ||
| 48 | |||
| 49 | try { cmdexec.Run("update-rc.d -f "+process+" remove"); }catch(Exception e) { return false; }; | ||
| 50 | |||
| 51 | return true; | ||
| 52 | } | ||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | |||
| 37 | 57 | ||
| 38 | } | 58 | } | ... | ... |
| 1 | package org.emercit.utilstools; | 1 | package org.emercit.utilstools; |
| 2 | 2 | ||
| 3 | import org.emercit.utilstools.model.SettingsBean; | 3 | import org.emercit.devinfo.service.DevInfo; |
| 4 | import org.emercit.utilstools.service.Settings; | 4 | import org.emercit.svmanager.model.SvBean; |
| 5 | 5 | import org.emercit.svmanager.service.SvControl; | |
| 6 | import org.emercit.devinfo.model.DevInfoBean; | 6 | import org.emercit.svmanager.service.Sv; |
| 7 | 7 | ||
| 8 | import org.apache.log4j.Logger; | ||
| 8 | 9 | ||
| 9 | public class App | 10 | public class App |
| 10 | { | 11 | { |
| 11 | 12 | private static final Logger log = Logger.getLogger(App.class); | |
| 12 | 13 | ||
| 13 | public static void main( String[] args ) | 14 | public static void main( String[] args ) |
| 14 | { | 15 | { |
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | |||
| 20 | |||
| 15 | System.out.println( "UtilsTools!" ); | 21 | System.out.println( "UtilsTools!" ); |
| 16 | 22 | ||
| 17 | Settings settings=new Settings(); | 23 | Sv sv=new Sv(); |
| 24 | |||
| 25 | // Процесс инит | ||
| 18 | 26 | ||
| 19 | settings.init(); | 27 | sv.init(); |
| 20 | 28 | ||
| 21 | 29 | ||
| 22 | 30 | ... | ... |
| 1 | log4j.debug=TRUE | ||
| 2 | log4j.rootLogger=INFO, R | ||
| 3 | |||
| 4 | log4j.appender.R=org.apache.log4j.RollingFileAppender | ||
| 5 | log4j.appender.R.File=/var/log/UtilsTools.log | ||
| 6 | log4j.appender.R.MaxFileSize=100KB | ||
| 7 | log4j.appender.R.MaxBackupIndex=5 | ||
| 8 | log4j.appender.R.layout=org.apache.log4j.PatternLayout | ||
| 9 | log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSSS} %p %t %c \u2013 %m%n | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment