From d5aaff3bf480eb5c2a28df8bb57372d5b73d69e7 Mon Sep 17 00:00:00 2001 From: To-om Date: Mon, 8 May 2017 21:42:33 +0200 Subject: [PATCH] #193 Fix log file location in development mode rename install folder in package --- build.sbt | 28 +++++++++-------- conf/logback.xml | 2 +- {install => package}/debian/postinst | 0 {install => package}/debian/postrm | 0 {install => package}/debian/prerm | 0 {install => package}/docker/entrypoint | 0 {install => package}/empty | 0 {install => package}/etc_default_thehive | 0 package/logback.xml | 39 ++++++++++++++++++++++++ {install => package}/rpm/postun | 0 {install => package}/rpm/pre | 0 {install => package}/rpm/preun | 0 {install => package}/thehive | 0 {install => package}/thehive.conf | 0 {install => package}/thehive.conf-perso | 0 {install => package}/thehive.service | 0 16 files changed, 55 insertions(+), 14 deletions(-) rename {install => package}/debian/postinst (100%) rename {install => package}/debian/postrm (100%) rename {install => package}/debian/prerm (100%) rename {install => package}/docker/entrypoint (100%) rename {install => package}/empty (100%) rename {install => package}/etc_default_thehive (100%) create mode 100644 package/logback.xml rename {install => package}/rpm/postun (100%) rename {install => package}/rpm/pre (100%) rename {install => package}/rpm/preun (100%) rename {install => package}/thehive (100%) rename {install => package}/thehive.conf (100%) rename {install => package}/thehive.conf-perso (100%) rename {install => package}/thehive.service (100%) diff --git a/build.sbt b/build.sbt index 4504f463a3..2f39ed5727 100644 --- a/build.sbt +++ b/build.sbt @@ -42,11 +42,13 @@ mappings in Universal ~= { _.flatMap { case (file, "conf/application.conf") => Nil case (file, "conf/application.sample") => Seq(file -> "conf/application.conf") + case (file, "conf/logback.xml") => Nil case other => Seq(other) } ++ Seq( - file("install/thehive.service") -> "install/thehive.service", - file("install/thehive.conf") -> "install/thehive.conf", - file("install/thehive") -> "install/thehive" + file("package/thehive.service") -> "package/thehive.service", + file("package/thehive.conf") -> "package/thehive.conf", + file("package/thehive") -> "package/thehive", + file("package/logback.xml") -> "conf/logback.xml" ) } @@ -59,13 +61,13 @@ packageDescription := """TheHive is a scalable 3-in-1 open source and free secur defaultLinuxInstallLocation := "/opt" linuxPackageMappings ~= { _.map { pm => val mappings = pm.mappings.filterNot { - case (file, path) => path.startsWith("/opt/thehive/install") || path.startsWith("/opt/thehive/conf") + case (file, path) => path.startsWith("/opt/thehive/package") || path.startsWith("/opt/thehive/conf") } com.typesafe.sbt.packager.linux.LinuxPackageMapping(mappings, pm.fileData).withConfig() } :+ packageMapping( - file("install/thehive.service") -> "/etc/systemd/system/thehive.service", - file("install/thehive.conf") -> "/etc/init/thehive.conf", - file("install/thehive") -> "/etc/init.d/thehive", + file("package/thehive.service") -> "/etc/systemd/system/thehive.service", + file("package/thehive.conf") -> "/etc/init/thehive.conf", + file("package/thehive") -> "/etc/init.d/thehive", file("conf/application.sample") -> "/etc/thehive/application.conf", file("conf/logback.xml") -> "/etc/thehive/logback.xml" ).withConfig() @@ -80,10 +82,10 @@ packageBin := { debianPackageRecommends := Seq("elasticsearch") debianPackageDependencies += "java8-runtime-headless | java8-runtime" maintainerScripts in Debian := maintainerScriptsFromDirectory( - baseDirectory.value / "install" / "debian", + baseDirectory.value / "package" / "debian", Seq(DebianConstants.Postinst, DebianConstants.Prerm, DebianConstants.Postrm) ) -linuxEtcDefaultTemplate in Debian := (baseDirectory.value / "install" / "etc_default_thehive").asURL +linuxEtcDefaultTemplate in Debian := (baseDirectory.value / "package" / "etc_default_thehive").asURL linuxMakeStartScript in Debian := None // RPM // @@ -93,12 +95,12 @@ rpmUrl := Some("http://thehive-project.org/") rpmLicense := Some("AGPL") rpmRequirements += "java-1.8.0-openjdk-headless" maintainerScripts in Rpm := maintainerScriptsFromDirectory( - baseDirectory.value / "install" / "rpm", + baseDirectory.value / "package" / "rpm", Seq(RpmConstants.Pre, RpmConstants.Preun, RpmConstants.Postun) ) linuxPackageSymlinks in Rpm := Nil rpmPrefix := Some(defaultLinuxInstallLocation.value) -linuxEtcDefaultTemplate in Rpm := (baseDirectory.value / "install" / "etc_default_thehive").asURL +linuxEtcDefaultTemplate in Rpm := (baseDirectory.value / "package" / "etc_default_thehive").asURL // DOCKER // import com.typesafe.sbt.packager.docker.{ Cmd, ExecCmd } @@ -109,9 +111,9 @@ dockerUpdateLatest := true dockerEntrypoint := Seq("/opt/thehive/entrypoint") dockerExposedPorts := Seq(9000) mappings in Docker ++= Seq( - file("install/docker/entrypoint") -> "/opt/thehive/entrypoint", + file("package/docker/entrypoint") -> "/opt/thehive/entrypoint", file("conf/logback.xml") -> "/etc/thehive/logback.xml", - file("install/empty") -> "/var/log/thehive/application.log") + file("package/empty") -> "/var/log/thehive/application.log") mappings in Docker ~= (_.filterNot { case (_, filepath) => filepath == "/opt/thehive/conf/application.conf" }) diff --git a/conf/logback.xml b/conf/logback.xml index fc1a000d7f..864f2b5f23 100644 --- a/conf/logback.xml +++ b/conf/logback.xml @@ -5,7 +5,7 @@ converterClass="play.api.libs.logback.ColoredLevel" /> - /var/log/thehive/application.log + ${application.home:-.}/logs/application.log %date [%level] from %logger in %thread - %message%n%xException diff --git a/install/debian/postinst b/package/debian/postinst similarity index 100% rename from install/debian/postinst rename to package/debian/postinst diff --git a/install/debian/postrm b/package/debian/postrm similarity index 100% rename from install/debian/postrm rename to package/debian/postrm diff --git a/install/debian/prerm b/package/debian/prerm similarity index 100% rename from install/debian/prerm rename to package/debian/prerm diff --git a/install/docker/entrypoint b/package/docker/entrypoint similarity index 100% rename from install/docker/entrypoint rename to package/docker/entrypoint diff --git a/install/empty b/package/empty similarity index 100% rename from install/empty rename to package/empty diff --git a/install/etc_default_thehive b/package/etc_default_thehive similarity index 100% rename from install/etc_default_thehive rename to package/etc_default_thehive diff --git a/package/logback.xml b/package/logback.xml new file mode 100644 index 0000000000..fc1a000d7f --- /dev/null +++ b/package/logback.xml @@ -0,0 +1,39 @@ + + + + + + + /var/log/thehive/application.log + + %date [%level] from %logger in %thread - %message%n%xException + + + + + + %coloredLevel %logger{15} - %message%n%xException{10} + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/install/rpm/postun b/package/rpm/postun similarity index 100% rename from install/rpm/postun rename to package/rpm/postun diff --git a/install/rpm/pre b/package/rpm/pre similarity index 100% rename from install/rpm/pre rename to package/rpm/pre diff --git a/install/rpm/preun b/package/rpm/preun similarity index 100% rename from install/rpm/preun rename to package/rpm/preun diff --git a/install/thehive b/package/thehive similarity index 100% rename from install/thehive rename to package/thehive diff --git a/install/thehive.conf b/package/thehive.conf similarity index 100% rename from install/thehive.conf rename to package/thehive.conf diff --git a/install/thehive.conf-perso b/package/thehive.conf-perso similarity index 100% rename from install/thehive.conf-perso rename to package/thehive.conf-perso diff --git a/install/thehive.service b/package/thehive.service similarity index 100% rename from install/thehive.service rename to package/thehive.service