diff options
author | Superpiffer | 2017-08-09 16:43:00 +0200 |
---|---|---|
committer | Superpiffer | 2017-08-09 16:43:00 +0200 |
commit | 799c7878d784b2e6ea4b0c09c1294ca4ae8ce066 (patch) | |
tree | fa60fe164399b7679393991c4b88d2589df96ce8 | |
download | aur-799c7878d784b2e6ea4b0c09c1294ca4ae8ce066.tar.gz |
Initial release
-rw-r--r-- | .SRCINFO | 25 | ||||
-rw-r--r-- | PKGBUILD | 34 | ||||
-rw-r--r-- | airsonic.install | 55 | ||||
-rw-r--r-- | airsonic.service | 12 | ||||
-rw-r--r-- | airsonic.sh | 127 |
5 files changed, 253 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..8bc1c687433a --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,25 @@ +pkgbase = airsonic + pkgdesc = A free, web-based media streamer and jukebox. + pkgver = 10.0.0 + pkgrel = 1 + url = https://github.com/Airsonic/airsonic/ + install = airsonic.install + arch = any + license = GPL3 + depends = java-runtime-headless + conflicts = subsonic + conflicts = subsonic-kang + conflicts = subsonic-kang-git + conflicts = subsonic-beta + conflicts = libresonic + noextract = airsonic-jdbc-extra.war + backup = var/lib/airsonic/airsonic.sh + source = https://github.com/airsonic/airsonic/releases/download/v10.0.0/airsonic-jdbc-extra.war + source = airsonic.sh + source = airsonic.service + sha256sums = 613f459906eff22466aaa1711964ea14f82d9acd0287b1a801ef9e55e62f086d + sha256sums = c80475ea59cfb02fd667fafcfc5367513a5d31d98878e2317ef98d47689b7e25 + sha256sums = 5ba2274f536fb7d16f6c0266500419a0c3834f6acdeeca81ba9b83264e839a1a + +pkgname = airsonic + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..633acd3f0aab --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,34 @@ +# Maintainer: Federico Giuliani <federico.giuliani86@gmail.com> + +pkgname=airsonic +pkgver=10.0.0 +pkgrel=1 +pkgdesc="A free, web-based media streamer and jukebox." +arch=('any') +url="https://github.com/Airsonic/airsonic/" +license=('GPL3') +depends=('java-runtime-headless') +conflicts=('subsonic' 'subsonic-kang' 'subsonic-kang-git' 'subsonic-beta' 'libresonic') +backup=('var/lib/airsonic/airsonic.sh') +noextract=(airsonic-jdbc-extra.war) +install=$pkgname.install +source=(https://github.com/airsonic/airsonic/releases/download/v${pkgver}/airsonic-jdbc-extra.war + 'airsonic.sh' + 'airsonic.service') + +package() { + cd ${srcdir} + mkdir -p $pkgdir/var/lib/airsonic + mkdir -p $pkgdir/var/lib/airsonic/playlists + mkdir -p $pkgdir/usr/lib/systemd/system + mkdir -p $pkgdir/etc/ + mv airsonic-jdbc-extra.war airsonic.war + cp * $pkgdir/var/lib/airsonic + ln -fs /var/lib/airsonic/airsonic.sh $pkgdir/etc/airsonic.conf + cp $srcdir/airsonic.service $pkgdir/usr/lib/systemd/system + chmod +x $pkgdir/var/lib/airsonic/airsonic.sh +} + +sha256sums=('613f459906eff22466aaa1711964ea14f82d9acd0287b1a801ef9e55e62f086d' + 'c80475ea59cfb02fd667fafcfc5367513a5d31d98878e2317ef98d47689b7e25' + '5ba2274f536fb7d16f6c0266500419a0c3834f6acdeeca81ba9b83264e839a1a') diff --git a/airsonic.install b/airsonic.install new file mode 100644 index 000000000000..480c1df21cac --- /dev/null +++ b/airsonic.install @@ -0,0 +1,55 @@ +_homedir=/var/lib/airsonic +_playlistdir=${_homedir}/playlists + +post_install() { + + getent group airsonic &>/dev/null || groupadd --system airsonic > /dev/null + getent passwd airsonic &>/dev/null || useradd --system \ + --home-dir /var/lib/airsonic \ + --shell /usr/bin/nologin \ + --gid airsonic \ + --groups audio \ + --comment "Airsonic user" \ + airsonic > /dev/null + passwd --lock airsonic &> /dev/null + + fix_permissions + echo "*************************************************" + echo "* Edit /etc/airsonic.conf to configure airsonic *" + echo "*************************************************" + + systemctl daemon-reload +} + +pre_remove() { + if [[ `systemctl is-active airsonic` == 'active' ]]; then + systemctl stop airsonic + fi +} + +post_remove() { + getent passwd airsonic &>/dev/null && userdel airsonic &>/dev/null +} + +fix_permissions() { + chown -R airsonic:airsonic ${_homedir} + chown airsonic:airsonic ${_playlistdir} +} + +pre_upgrade() { + rm -f /tmp/airsonic-was-active + if [[ `systemctl is-active airsonic` == 'active' ]]; then + touch /tmp/airsonic-was-active + echo "Stopping airsonic" + systemctl stop airsonic + fi +} + +post_upgrade() { + post_install + if [ -e /tmp/airsonic-was-active ]; then + echo "Starting airsonic" + systemctl start airsonic + rm /tmp/airsonic-was-active + fi +} diff --git a/airsonic.service b/airsonic.service new file mode 100644 index 000000000000..e54fb1b96956 --- /dev/null +++ b/airsonic.service @@ -0,0 +1,12 @@ +[Unit] +Description=Airsonic +After=network.target + +[Service] +User=airsonic +ExecStart=/var/lib/airsonic/airsonic.sh +ExecStop=/bin/kill -15 $MAINPID +Type=forking + +[Install] +WantedBy=multi-user.target diff --git a/airsonic.sh b/airsonic.sh new file mode 100644 index 000000000000..e971cc8d184d --- /dev/null +++ b/airsonic.sh @@ -0,0 +1,127 @@ +#!/bin/sh + +AIRSONIC_HOME=/var/lib/airsonic +AIRSONIC_HOST=0.0.0.0 +AIRSONIC_PORT=8080 +AIRSONIC_HTTPS_PORT=0 +AIRSONIC_CONTEXT_PATH=/ +AIRSONIC_MAX_MEMORY=256 +AIRSONIC_PIDFILE=airsonic.pid +AIRSONIC_DEFAULT_MUSIC_FOLDER=/var/lib/airsonic/music +AIRSONIC_DEFAULT_PODCAST_FOLDER=/var/lib/airsonic/podcast +AIRSONIC_DEFAULT_PLAYLIST_FOLDER=/var/lib/airsonic/playlists + +quiet=0 + +usage() { + echo "Usage: airsonic.sh [options]" + echo " --help This small usage guide." + echo " --home=DIR The directory where Airsonic will create files." + echo " Make sure it is writable. Default: /var/lib/airsonic" + echo " --host=HOST The host name or IP address on which to bind Airsonic." + echo " Only relevant if you have multiple network interfaces and want" + echo " to make Airsonic available on only one of them. The default value" + echo " will bind Airsonic to all available network interfaces. Default: 0.0.0.0" + echo " --port=PORT The port on which Airsonic will listen for" + echo " incoming HTTP traffic. Default: 8080" + echo " --https-port=PORT The port on which Airsonic will listen for" + echo " incoming HTTPS traffic. Default: 0 (disabled)" + echo " --context-path=PATH The context path, i.e., the last part of the Airsonic" + echo " URL. Typically '/' or '/airsonic'. Default '/'" + echo " --max-memory=MB The memory limit (max Java heap size) in megabytes." + echo " Default: 100" + echo " --pidfile=PIDFILE Write PID to this file. Default not created." + echo " --quiet Don't print anything to standard out. Default false." + echo " --default-music-folder=DIR Configure Airsonic to use this folder for music. This option " + echo " only has effect the first time Airsonic is started. Default '/var/lib/airsonic/music'" + echo " --default-podcast-folder=DIR Configure Airsonic to use this folder for Podcasts. This option " + echo " only has effect the first time Airsonic is started. Default '/var/lib/airsonic/podcast'" + echo " --default-playlist-folder=DIR Configure Airsonic to use this folder for playlists. This option " + echo " only has effect the first time Airsonic is started. Default '/var/lib/airsonic/playlists'" + exit 1 +} + +# Parse arguments. +while [ $# -ge 1 ]; do + case $1 in + --help) + usage + ;; + --home=?*) + AIRSONIC_HOME=${1#--home=} + ;; + --host=?*) + AIRSONIC_HOST=${1#--host=} + ;; + --port=?*) + AIRSONIC_PORT=${1#--port=} + ;; + --https-port=?*) + AIRSONIC_HTTPS_PORT=${1#--https-port=} + ;; + --context-path=?*) + AIRSONIC_CONTEXT_PATH=${1#--context-path=} + ;; + --max-memory=?*) + AIRSONIC_MAX_MEMORY=${1#--max-memory=} + ;; + --pidfile=?*) + AIRSONIC_PIDFILE=${1#--pidfile=} + ;; + --quiet) + quiet=1 + ;; + --default-music-folder=?*) + AIRSONIC_DEFAULT_MUSIC_FOLDER=${1#--default-music-folder=} + ;; + --default-podcast-folder=?*) + AIRSONIC_DEFAULT_PODCAST_FOLDER=${1#--default-podcast-folder=} + ;; + --default-playlist-folder=?*) + AIRSONIC_DEFAULT_PLAYLIST_FOLDER=${1#--default-playlist-folder=} + ;; + *) + usage + ;; + esac + shift +done + +# Use JAVA_HOME if set, otherwise assume java is in the path. +JAVA=java +if [ -e "${JAVA_HOME}" ] + then + JAVA=${JAVA_HOME}/bin/java +fi + +# Create Airsonic home directory. +mkdir -p ${AIRSONIC_HOME} +LOG=${AIRSONIC_HOME}/airsonic_sh.log +rm -f ${LOG} + +cd $(dirname $0) +if [ -L $0 ] && ([ -e /bin/readlink ] || [ -e /usr/bin/readlink ]); then + cd $(dirname $(readlink $0)) +fi + +${JAVA} -Xmx${AIRSONIC_MAX_MEMORY}m \ + -Dserver.address=${AIRSONIC_HOST} \ + -Dserver.port=${AIRSONIC_PORT} \ + -Dserver.httpsPort=${AIRSONIC_HTTPS_PORT} \ + -Dserver.contextPath=${AIRSONIC_CONTEXT_PATH} \ + -Dairsonic.home=${AIRSONIC_HOME} \ + -Dairsonic.defaultMusicFolder=${AIRSONIC_DEFAULT_MUSIC_FOLDER} \ + -Dairsonic.defaultPodcastFolder=${AIRSONIC_DEFAULT_PODCAST_FOLDER} \ + -Dairsonic.defaultPlaylistFolder=${AIRSONIC_DEFAULT_PLAYLIST_FOLDER} \ + -Djava.awt.headless=true \ + -jar airsonic.war > ${LOG} 2>&1 & + +# Write pid to pidfile if it is defined. +if [ $AIRSONIC_PIDFILE ]; then + echo $! > ${AIRSONIC_PIDFILE} +fi + +if [ $quiet = 0 ]; then + echo Started Airsonic [PID $!, ${LOG}] +fi + |