From 67a994fa220f080aaa916ebc9b989e889b9d53b3 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 30 Dec 2018 01:02:30 -0200 Subject: Working setup --- files/airsonic-download | 19 +++++++++++ files/airsonic.conf | 31 ++++++++++++++++++ files/airsonic.service | 23 ++++++++++++++ manifests/init.pp | 84 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 157 insertions(+) create mode 100755 files/airsonic-download create mode 100644 files/airsonic.conf create mode 100644 files/airsonic.service 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'], + ], + } } -- cgit v1.2.3