diff --git a/resources/WebContent/css/main.css b/resources/WebContent/css/main.css index 1f3c40b..91887c6 100644 --- a/resources/WebContent/css/main.css +++ b/resources/WebContent/css/main.css @@ -6,6 +6,9 @@ body{ margin-top: 40px; /* to offset top-bar */ /*margin-bottom: 30px; /* Margin bottom by footer height */ } +table{ + font-size: 100%; +} #top-bar{ height: 41px; diff --git a/resources/WebContent/page/ServicePage.tmpl b/resources/WebContent/page/ServicePage.tmpl index 1ff0073..0b13f50 100644 --- a/resources/WebContent/page/ServicePage.tmpl +++ b/resources/WebContent/page/ServicePage.tmpl @@ -1,133 +1,5 @@ -
-
Cpu Status
-
-
-
-
-
-
Memory
-
-
-
- - - - - - -
UsedFree
Memory
Swap
-
-
-
-
Process List
-
- - - - - - - - - - - -
PIDUserCPUCpuTimeMemory(MB)Proc
-
-
- diff --git a/src/wa/server/WAConstants.java b/src/wa/server/WAConstants.java index d55b93e..05e9273 100644 --- a/src/wa/server/WAConstants.java +++ b/src/wa/server/WAConstants.java @@ -2,12 +2,15 @@ package wa.server; import java.io.File; +import zutil.db.DBConnection; import zutil.osal.OSAbstractionLayer; import zutil.osal.OSAbstractionLayer.OSType; public class WAConstants { + + public static final String DB_FILE_NAME = "webadmin.db"; public static final String DB_TABLE_PREFIX = "wa"; - + public static DBConnection db; public static final String WA_ROOT_PATH_LINUX = "/"; public static final String WA_ROOT_PATH_WINDOWS = "C:\\webadmin\\"; @@ -22,7 +25,7 @@ public class WAConstants { static{ OSAbstractionLayer os = OSAbstractionLayer.getInstance(); - + if(os.getOSType() == OSType.Linux){ configPath = new File(WA_ROOT_PATH_LINUX + WA_BASE_CONFIG_PATH); } @@ -32,10 +35,23 @@ public class WAConstants { else { configPath = null; } + + if(configPath != null){ + try { + db = new DBConnection(DBConnection.DBMS.SQLite, configPath.getAbsolutePath() + DB_FILE_NAME); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + } } public static File getConfigFile(String name){ return new File(configPath, name); } + + public static DBConnection getDB(){ + return db; + } } diff --git a/src/wa/server/page/ServicePage.java b/src/wa/server/page/ServicePage.java index 4f2a7f7..3571af3 100644 --- a/src/wa/server/page/ServicePage.java +++ b/src/wa/server/page/ServicePage.java @@ -24,9 +24,8 @@ package wa.server.page; import wa.server.WAContext; import wa.server.page.struct.WANavigation; -import wa.server.plugin.WAConfiguration; +import wa.server.plugin.WAServiceConfig; import wa.server.plugin.WAService; -import wa.server.plugin.WAServiceStatus; import zutil.io.file.FileUtil; import zutil.log.LogUtil; import zutil.net.http.HttpHeaderParser; @@ -59,7 +58,7 @@ public class ServicePage implements WAPage { for(WAService plugin : services) { statuses.add(new ServiceStatusPage(plugin.getStatus())); nav.addSubNav(new WANavigation(plugin.getName(), plugin)); - for(WAConfiguration conf : plugin.getConfigurations()){ + for(WAServiceConfig conf : plugin.getConfigurations()){ } } diff --git a/src/wa/server/plugin/WAConfiguration.java b/src/wa/server/plugin/WAConfiguration.java deleted file mode 100644 index 70d2c2f..0000000 --- a/src/wa/server/plugin/WAConfiguration.java +++ /dev/null @@ -1,11 +0,0 @@ -package wa.server.plugin; - -import java.io.IOException; -import java.sql.SQLException; - -import zutil.db.DBConnection; - -public interface WAConfiguration { - public void read(DBConnection db) throws SQLException; - public void save(DBConnection db) throws IOException; -} diff --git a/src/wa/server/plugin/WAInstaller.java b/src/wa/server/plugin/WAInstaller.java index b3793a5..72bec36 100644 --- a/src/wa/server/plugin/WAInstaller.java +++ b/src/wa/server/plugin/WAInstaller.java @@ -26,6 +26,7 @@ package wa.server.plugin; * Created by Ziver on 2014-11-09. */ public interface WAInstaller { + public boolean isInstalled(); public void install(); public void uninstall(); } diff --git a/src/wa/server/plugin/WAService.java b/src/wa/server/plugin/WAService.java index ce71221..73a7717 100644 --- a/src/wa/server/plugin/WAService.java +++ b/src/wa/server/plugin/WAService.java @@ -17,5 +17,5 @@ public interface WAService { /** * @return a array of configuration objects */ - public WAConfiguration[] getConfigurations(); + public WAServiceConfig[] getConfigurations(); } diff --git a/src/wa/server/plugin/WAServiceConfig.java b/src/wa/server/plugin/WAServiceConfig.java new file mode 100644 index 0000000..2b3d074 --- /dev/null +++ b/src/wa/server/plugin/WAServiceConfig.java @@ -0,0 +1,11 @@ +package wa.server.plugin; + +import java.io.IOException; +import java.sql.SQLException; + +import zutil.db.DBConnection; + +public interface WAServiceConfig { + public void read() throws SQLException; + public void save() throws IOException; +} diff --git a/src/wa/server/plugin/apache/ApacheConfiguration.java b/src/wa/server/plugin/apache/ApacheConfig.java similarity index 86% rename from src/wa/server/plugin/apache/ApacheConfiguration.java rename to src/wa/server/plugin/apache/ApacheConfig.java index e39b075..a1d1c23 100644 --- a/src/wa/server/plugin/apache/ApacheConfiguration.java +++ b/src/wa/server/plugin/apache/ApacheConfig.java @@ -8,12 +8,12 @@ import java.util.LinkedList; import java.util.List; import wa.server.WAConstants; -import wa.server.plugin.WAConfiguration; +import wa.server.plugin.WAServiceConfig; import wa.server.util.ConfigFileUtil; import zutil.db.DBConnection; import zutil.io.file.FileUtil; -public class ApacheConfiguration implements WAConfiguration { +public class ApacheConfig implements WAServiceConfig { private static final String APACHE_CONF_FILE = "wa_apache_vhost.conf"; private static final String APACHE_MAIN_CONFIG_FILE = "/etc/apache2/apache2.conf"; private static final String STATIC_PRE_CONF = "wa/server/plugin/apache/apache_default.config"; @@ -22,20 +22,21 @@ public class ApacheConfiguration implements WAConfiguration { List vhosts; - public ApacheConfiguration(){ + public ApacheConfig(){ vhosts = new LinkedList(); } @Override - public void read(DBConnection db) throws SQLException { + public void read() throws SQLException { + DBConnection db = WAConstants.getDB(); vhosts = ApacheConfigVirtualHost.load(db, ApacheConfigVirtualHost.class); } @Override - public void save(DBConnection db) throws IOException { + public void save() throws IOException { File file = WAConstants.getConfigFile(APACHE_CONF_FILE); - // Update Man configuration file + // Update main configuration file ConfigFileUtil.writeBetweenBoundary( new File(APACHE_MAIN_CONFIG_FILE), "#", @@ -48,9 +49,7 @@ public class ApacheConfiguration implements WAConfiguration { out.println("######################################"); out.println("# vhost.php"); for(ApacheConfigVirtualHost vhost : vhosts){ - if(vhost.isTomcatApp()) - writeTomcatVhost(out, vhost); - else if(vhost.isSSL()) + if(vhost.isSSL()) writeSSLVhost(out, vhost); else writeVhost(out, vhost); diff --git a/src/wa/server/plugin/apache/ApacheConfigVirtualHost.java b/src/wa/server/plugin/apache/ApacheConfigVirtualHost.java index 8789d62..29d7dbb 100644 --- a/src/wa/server/plugin/apache/ApacheConfigVirtualHost.java +++ b/src/wa/server/plugin/apache/ApacheConfigVirtualHost.java @@ -9,7 +9,6 @@ public class ApacheConfigVirtualHost extends DBBean{ protected String domain; protected String path; protected boolean ssl; - protected boolean tomcat; @@ -31,10 +30,4 @@ public class ApacheConfigVirtualHost extends DBBean{ public void setSSL(boolean ssl) { this.ssl = ssl; } - public boolean isTomcatApp() { - return tomcat; - } - public void setTomcatApp(boolean tomcat) { - this.tomcat = tomcat; - } } diff --git a/src/wa/server/plugin/apache/ApacheInstaller.java b/src/wa/server/plugin/apache/ApacheInstaller.java index 0c9e80d..3ecf93b 100644 --- a/src/wa/server/plugin/apache/ApacheInstaller.java +++ b/src/wa/server/plugin/apache/ApacheInstaller.java @@ -31,6 +31,17 @@ import zutil.osal.app.linux.AptGet; public class ApacheInstaller implements WAInstaller { private static final String PACKAGES = "apache php5 php5-mcrypt php5-gd imagemagick"; + @Override + public boolean isInstalled() { + String[] tmp = PACKAGES.split(" "); + for(String pkgName : tmp){ + AptGet.Package pkg = AptGet.getPackage(PACKAGES); + if( pkg == null || pkg.getCurrentState() != AptGet.Package.PackageState.Installed) + return false; + } + return true; + } + @Override public void install() { AptGet.install(PACKAGES); diff --git a/src/wa/server/plugin/apache/ApacheService.java b/src/wa/server/plugin/apache/ApacheService.java index e0e09f9..d8dc089 100644 --- a/src/wa/server/plugin/apache/ApacheService.java +++ b/src/wa/server/plugin/apache/ApacheService.java @@ -22,7 +22,7 @@ package wa.server.plugin.apache; -import wa.server.plugin.WAConfiguration; +import wa.server.plugin.WAServiceConfig; import wa.server.plugin.WAInstaller; import wa.server.plugin.WAService; import wa.server.plugin.WAServiceStatus; @@ -60,7 +60,7 @@ public class ApacheService implements WAService { } @Override - public WAConfiguration[] getConfigurations() { - return new WAConfiguration[0]; + public WAServiceConfig[] getConfigurations() { + return new WAServiceConfig[0]; } } diff --git a/src/wa/server/plugin/hwstatus/HwStatus.tmpl b/src/wa/server/plugin/hwstatus/HwStatus.tmpl index 1ff0073..c848361 100644 --- a/src/wa/server/plugin/hwstatus/HwStatus.tmpl +++ b/src/wa/server/plugin/hwstatus/HwStatus.tmpl @@ -9,7 +9,7 @@

- +
UsedFree
Memory