aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2019-05-08 17:58:09 +0200
committerMarvin Borner2019-05-08 17:58:09 +0200
commit7e3ef275f870737b853fda3e007e74de2112a7d5 (patch)
tree07c1b8f37fcb399f2cbffd23168604bc37299b3c
parentbd89369b508f30fc987b27cf6b34a22fbc8e5d97 (diff)
Added install script
Co-authored-by: LarsVomMars <lars@kroenner.eu>
-rw-r--r--Makefile27
-rw-r--r--README.md11
-rw-r--r--src/main/kotlin/App.kt3
-rw-r--r--src/main/kotlin/DatabaseController.kt3
4 files changed, 37 insertions, 7 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..bfb8b58
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,27 @@
+.PHONY: all
+
+all: clean build
+
+clean:
+ $(RM) -rv build/ out/ *.class
+
+build:
+ gradle build
+ @echo Success! The .jar file should be in build/libs/. You may want to use \'sudo make install\' now.
+
+install:
+ifdef OS
+ @echo Kloud can't be installed on Windows currently, please execute the jar file manually
+else
+ ifeq ($(shell uname), Linux)
+ mkdir -p /usr/share/kloud/
+ userdel kloud || true
+ useradd -r -d /usr/share/kloud kloud || true
+ chown -R kloud /usr/share/kloud
+ cp build/libs/kloud-*-all.jar /usr/share/kloud/
+ echo -e "#!/bin/sh\nsudo -u kloud java -jar /usr/share/kloud/kloud-*-all.jar \$$@" > /usr/bin/kloud
+ chmod +x /usr/bin/kloud
+ else
+ @echo This OS doesn't support out automatic installation, please execute the jar file manually
+ endif
+endif
diff --git a/README.md b/README.md
index 8c424e6..84ed98a 100644
--- a/README.md
+++ b/README.md
@@ -20,14 +20,15 @@
## Installation
To install and run Kloud, you can either download the latest release on GitHub or use the "Development setup" instructions
below to build an executable yourself.
-After that you can easily start the server via `java -jar kloud-VERSION-all.jar`
+After that you can easily start the server via `java -jar build/libs/kloud-*-all.jar`
-## Development setup
-* Setup Java JDK and JRE Environment
+## Manual setup
+* Setup a Java JDK and JRE Environment
* Install Gradle
* Clone repository
-* `gradle run`
-* For building, use: `gradle build`
+* For development use: `gradle run`
+* For building use: `make` or `gradle build`
+* To install and add the jar to the PATH (most useful on Linux), use `make && sudo make install`
## Help us with a small donation :)
<p align="center">
diff --git a/src/main/kotlin/App.kt b/src/main/kotlin/App.kt
index c403b5a..0bd15b2 100644
--- a/src/main/kotlin/App.kt
+++ b/src/main/kotlin/App.kt
@@ -13,7 +13,8 @@ import java.net.*
import java.util.logging.*
import kotlin.system.*
-const val fileHome = "files"
+// TODO: Add abstract and secure file home support for windows/BSD/macOS
+val fileHome = if (System.getProperty("os.name") != "Linux") "files" else "/usr/share/kloud/files"
val databaseController = DatabaseController()
val userHandler = UserHandler()
val fileController = FileController()
diff --git a/src/main/kotlin/DatabaseController.kt b/src/main/kotlin/DatabaseController.kt
index 541bd06..8d48008 100644
--- a/src/main/kotlin/DatabaseController.kt
+++ b/src/main/kotlin/DatabaseController.kt
@@ -9,7 +9,8 @@ import org.joda.time.*
import java.sql.*
import java.util.logging.*
-class DatabaseController(dbFileLocation: String = "main.db") {
+class DatabaseController {
+ private val dbFileLocation = if (System.getProperty("os.name") != "Linux") "main.db" else "/usr/share/kloud/main.db"
val db: Database = Database.connect("jdbc:sqlite:$dbFileLocation", "org.sqlite.JDBC")
private val log = Logger.getLogger(this.javaClass.name)