]> gitweb.fluxo.info Git - puppet-airsonic.git/commitdiff
Working setup
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 30 Dec 2018 03:02:30 +0000 (01:02 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 30 Dec 2018 03:02:30 +0000 (01:02 -0200)
files/airsonic-download [new file with mode: 0755]
files/airsonic.conf [new file with mode: 0644]
files/airsonic.service [new file with mode: 0644]
manifests/init.pp

diff --git a/files/airsonic-download b/files/airsonic-download
new file mode 100755 (executable)
index 0000000..4cce24a
--- /dev/null
@@ -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 (file)
index 0000000..5836f2f
--- /dev/null
@@ -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 (file)
index 0000000..b3f16ff
--- /dev/null
@@ -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
index 704e90d75595a3c07ef9bf1ec3b7d7d3208a9021..dfd361b388a481afa1e7760602e580a85ac8295d 100644 (file)
@@ -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'],
+    ],
+  }
 }