Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users.Root constant added. #113

Merged
merged 1 commit into from
Dec 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN_CMD="-cp ${{app_classpath}} ${{app_main_class}} $RUN_OPTS"

start_daemon() {
log_daemon_msg "Starting" "${{app_name}}"
start-stop-daemon --background --chuid "$DAEMON_USER" --make-pidfile --pidfile "$PIDFILE" --exec "$JAVA_CMD" --start -- $RUN_CMD
start-stop-daemon --background --chdir ${{chdir}} --chuid "$DAEMON_USER" --make-pidfile --pidfile "$PIDFILE" --exec "$JAVA_CMD" --start -- $RUN_CMD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is sweet. The default logging configuration files always rely on this, what makes uninstalling rather messy.

log_end_msg $?
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ trait GenericPackageSettings
with rpm.RpmPlugin
with windows.WindowsPlugin
with universal.UniversalPlugin {


import linux.LinuxPlugin.Users

// This method wires a lot of hand-coded generalities about how to map directories
// into linux, and the conventions we expect.
// It is by no means 100% accurate, but should be ok for the simplest cases.
Expand Down Expand Up @@ -52,10 +54,10 @@ trait GenericPackageSettings
}

Seq(
packageMappingWithRename((binaries ++ directories):_*) withUser "root" withGroup "root" withPerms "0755",
packageMappingWithRename(compressedManPages:_*).gzipped withUser "root" withGroup "root" withPerms "0644",
packageMappingWithRename(configFiles:_*) withConfig() withUser "root" withGroup "root" withPerms "0644",
packageMappingWithRename(remaining:_*) withUser "root" withGroup "root" withPerms "0644"
packageMappingWithRename((binaries ++ directories):_*) withUser Users.Root withGroup Users.Root withPerms "0755",
packageMappingWithRename(compressedManPages:_*).gzipped withUser Users.Root withGroup Users.Root withPerms "0644",
packageMappingWithRename(configFiles:_*) withConfig() withUser Users.Root withGroup Users.Root withPerms "0644",
packageMappingWithRename(remaining:_*) withUser Users.Root withGroup Users.Root withPerms "0644"
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Keys._
import sbt._
import sbt.Keys.{ target, mainClass, normalizedName }
import SbtNativePackager._
import com.typesafe.sbt.packager.linux.{ LinuxFileMetaData, LinuxPackageMapping, LinuxSymlink }
import com.typesafe.sbt.packager.linux.{ LinuxFileMetaData, LinuxPackageMapping, LinuxSymlink, LinuxPlugin }

/**
* This class contains the default settings for creating and deploying an archetypical Java application.
Expand All @@ -19,14 +19,15 @@ import com.typesafe.sbt.packager.linux.{ LinuxFileMetaData, LinuxPackageMapping,
*/
object JavaServerAppPackaging {
import ServerLoader._
import LinuxPlugin.Users

def settings: Seq[Setting[_]] = JavaAppPackaging.settings ++ debianSettings
protected def etcDefaultTemplateSource: java.net.URL = getClass.getResource("etc-default-template")

def debianSettings: Seq[Setting[_]] =
Seq(
serverLoading := Upstart,
daemonUser := "root",
daemonUser := Users.Root,
debianStartScriptReplacements <<= (
maintainer in Debian, packageSummary in Debian, serverLoading in Debian, daemonUser in Debian, normalizedName,
sbt.Keys.version, defaultLinuxInstallLocation, mainClass in Compile, scriptClasspath)
Expand Down Expand Up @@ -68,7 +69,7 @@ object JavaServerAppPackaging {
// create empty var/log directory
val d = target / logsDir
d.mkdirs()
LinuxPackageMapping(Seq(d -> s"$logsDir/$name"), LinuxFileMetaData(user, user))
LinuxPackageMapping(Seq(d -> (logsDir + "/" + name)), LinuxFileMetaData(user, user))
},
linuxPackageSymlinks in Debian <+= (normalizedName, defaultLinuxInstallLocation) map {
(name, install) => LinuxSymlink(install + "/" + name + "/logs", "/var/log/" + name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ trait DebianPlugin extends Plugin with linux.LinuxPlugin {

import com.typesafe.sbt.packager.universal.Archives
import DebianPlugin.Names
import linux.LinuxPlugin.Users

private[this] final def copyAndFixPerms(from: File, to: File, perms: LinuxFileMetaData, zipped: Boolean = false): Unit = {
if (zipped) {
Expand Down Expand Up @@ -157,7 +158,7 @@ trait DebianPlugin extends Plugin with linux.LinuxPlugin {
// Check for non root user/group and append to postinst / postrm
// filter all root mappings, map to (user,group) key, group by, append everything
mappings filter {
case LinuxPackageMapping(_, LinuxFileMetaData("root", "root", _, _, _), _) => false
case LinuxPackageMapping(_, LinuxFileMetaData(Users.Root, Users.Root, _, _, _), _) => false
case _ => true
} map {
case LinuxPackageMapping(paths, LinuxFileMetaData(user, group, _, _, _), _) => (user, group) -> paths
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package packager
package linux

import sbt._
import LinuxPlugin.Users

case class LinuxFileMetaData(
user: String = "root",
group: String = "root",
user: String = Users.Root,
group: String = Users.Root,
permissions: String = "755",
config: String = "false",
docs: Boolean = false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@ trait LinuxPlugin extends Plugin {
/** Create a ascii friendly string for a man page. */
final def makeMan(file: File): String =
Process("groff -man -Tascii " + file.getAbsolutePath).!!
}

object LinuxPlugin {
object Users {
val Root = "root"
}
}