aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-12-30 01:02:30 -0200
committerSilvio Rhatto <rhatto@riseup.net>2018-12-30 01:02:30 -0200
commit67a994fa220f080aaa916ebc9b989e889b9d53b3 (patch)
treef97111d2850c658c8fcdca36c293de51420a6b91
parent05e65a9eb890b72ab0c373915fcacab1b7c574ba (diff)
downloadpuppet-airsonic-67a994fa220f080aaa916ebc9b989e889b9d53b3.tar.gz
puppet-airsonic-67a994fa220f080aaa916ebc9b989e889b9d53b3.tar.bz2
Working setup
-rwxr-xr-xfiles/airsonic-download19
-rw-r--r--files/airsonic.conf31
-rw-r--r--files/airsonic.service23
-rw-r--r--manifests/init.pp84
4 files changed, 157 insertions, 0 deletions
diff --git a/files/airsonic-download b/files/airsonic-download
new file mode 100755
index 0000000..4cce24a
--- /dev/null
+++ b/files/airsonic-download
@@ -0,0 +1,19 @@
+#!/bin/bash
+#
+# Download and check airsonic.
+#
+
+# Parameters
+DEST="/var/lib/airsonic/airsonic.war"
+HASH="738c0614a113f692d75f62d9a74efab1580e3ba8c683feb8d6bfded80240f342"
+
+# Download
+/usr/bin/wget https://github.com/airsonic/airsonic/releases/download/v10.1.2/airsonic.war --output-document=$DEST || exit 1
+
+# Check integrity
+if [ "`sha256sum $DEST`" != "$HASH $DEST"]; then
+ rm -f $DEST
+ exit 1
+else
+ chown airsonic:airsonic $DEST
+fi
diff --git a/files/airsonic.conf b/files/airsonic.conf
new file mode 100644
index 0000000..5836f2f
--- /dev/null
+++ b/files/airsonic.conf
@@ -0,0 +1,31 @@
+# Set the location of the standalone war to use
+JAVA_JAR=/var/lib/airsonic/airsonic.war
+
+# Set any java opts separated by spaces
+#JAVA_OPTS=-Xmx700m
+
+# Set a different location for airsonic home.
+# If this path is /var/libresonic or even contains "libresonic",
+# the data from a previous libresonic can be used as is (i.e. without
+# renaming libresonic.properties,db/libresonic*,etc
+AIRSONIC_HOME=/var/lib/airsonic
+
+# Change the port to listen on
+PORT=8200
+
+# Change the path that is listened on
+#CONTEXT_PATH=/airsonic
+
+# Add any java args. These are different than JAVA_OPTS in that
+# they are passed directly to the program. The default is empty:
+#JAVA_ARGS=
+
+# Note that there are several settings for spring boot, not explicitly listed
+# here, but can be used in either JAVA_OPTS or JAVA_ARGS. The full list
+# can be found here:
+# https://docs.spring.io/spring-boot/docs/1.4.5.RELEASE/reference/htmlsingle/#common-application-properties
+# For example to set debug across the board:
+#JAVA_ARGS=--debug
+
+# Or to change the ip address that is listened on:
+#JAVA_ARGS=--server.address=127.0.0.1
diff --git a/files/airsonic.service b/files/airsonic.service
new file mode 100644
index 0000000..b3f16ff
--- /dev/null
+++ b/files/airsonic.service
@@ -0,0 +1,23 @@
+[Unit]
+Description=Airsonic Media Server
+After=remote-fs.target network.target
+AssertPathExists=/var/lib/airsonic
+
+[Service]
+Type=simple
+Environment="JAVA_JAR=/var/lib/airsonic/airsonic.war"
+Environment="JAVA_OPTS=-Xmx700m"
+Environment="AIRSONIC_HOME=/var/lib/airsonic"
+Environment="PORT=8200"
+Environment="JAVA_ARGS="
+EnvironmentFile=-/etc/sysconfig/airsonic
+ExecStart=/usr/bin/java \
+ $JAVA_OPTS \
+ -Dairsonic.home=${AIRSONIC_HOME} \
+ -Dserver.port=${PORT} \
+ -jar ${JAVA_JAR} $JAVA_ARGS
+User=airsonic
+Group=airsonic
+
+[Install]
+WantedBy=multi-user.target
diff --git a/manifests/init.pp b/manifests/init.pp
index 704e90d..dfd361b 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,2 +1,86 @@
+# See https://airsonic.github.io/docs/install/war-standalone/
class airsonic {
+ package { [
+ 'default-jre',
+ ]:
+ ensure => present,
+ }
+
+ group { "airsonic":
+ ensure => present,
+ allowdupe => false,
+ }
+
+ user { "airsonic":
+ ensure => present,
+ allowdupe => false,
+ shell => '/bin/false',
+ gid => 'airsonic',
+ home => '/var/lib/airsonic',
+ require => Group['airsonic'],
+ }
+
+ file { [
+ '/var/lib/airsonic',
+ ]:
+ ensure => directory,
+ owner => 'airsonic',
+ group => 'airsonic',
+ mode => '0750',
+ require => User['airsonic'],
+ }
+
+ file { '/usr/local/sbin/airsonic-download':
+ ensure => present,
+ owner => root,
+ group => root,
+ mode => '0755',
+ source => 'puppet:///modules/airsonic/airsonic-download',
+ }
+
+ exec { 'airsonic-download':
+ #command => '/usr/bin/wget https://github.com/airsonic/airsonic/releases/download/v10.1.2/airsonic.war --output-document=/var/lib/airsonic/airsonic.war',
+ command => '/usr/local/sbin/airsonic-download',
+ creates => '/var/lib/airsonic/airsonic.war',
+ user => root,
+ require => File['/var/lib/airsonic', '/usr/local/sbin/airsonic-download'],
+ }
+
+ file { '/etc/default/airsonic':
+ ensure => present,
+ owner => 'airsonic',
+ group => 'airsonic',
+ mode => '0644',
+ source => [
+ 'puppet:///modules/site_airsonic/airsonic.conf',
+ 'puppet:///modules/airsonic/airsonic.conf',
+ ],
+ notify => Service['airsonic'],
+ }
+
+ file { '/etc/systemd/system/airsonic.service':
+ ensure => present,
+ owner => root,
+ group => root,
+ mode => '0644',
+ source => 'puppet:///modules/airsonic/airsonic.service',
+ notify => Exec['systemctl-enable-airsonic'],
+ }
+
+ exec { 'systemctl-enable-airsonic':
+ command => '/bin/systemctl daemon-reload && /bin/systemctl enable airsonic',
+ require => File['/etc/systemd/system/airsonic.service'],
+ user => root,
+ refreshonly => true,
+ }
+
+ service { 'airsonic':
+ ensure => running,
+ enable => true,
+ require => [
+ File['/var/lib/airsonic', '/etc/default/airsonic', '/etc/systemd/system/airsonic.service', ],
+ Exec['airsonic-download', 'systemctl-enable-airsonic'],
+ Package['default-jre'],
+ ],
+ }
}