diff options
-rw-r--r-- | .SRCINFO | 18 | ||||
-rw-r--r-- | 10-mugensudo | 3 | ||||
-rw-r--r-- | PKGBUILD | 43 | ||||
-rwxr-xr-x | install.sh | 35 | ||||
-rw-r--r-- | karaokemugen.desktop | 2 | ||||
-rw-r--r-- | karaokemugen.install | 8 | ||||
-rw-r--r-- | payload.sh | 17 | ||||
-rwxr-xr-x | run.sh | 29 |
8 files changed, 118 insertions, 37 deletions
@@ -1,11 +1,10 @@ pkgbase = karaokemugen-git pkgdesc = Karaoke playlist manager/player app used in parties or events. - pkgver = 3.2.0.rc1.r15.g1a01c9c8 - pkgrel = 2 + pkgver = 3.2.0.r0.g9ecde13e + pkgrel = 1 url = https://mugen.karaokes.moe/ install = karaokemugen.install - arch = x86_64 - arch = i686 + arch = any license = MIT makedepends = git makedepends = npm @@ -16,6 +15,7 @@ pkgbase = karaokemugen-git depends = ffmpeg depends = postgresql depends = electron + optdepends = sudo: for using karaokemugen-install script provides = karaokemugen conflicts = karaokemugen source = karaokemugen::git+https://lab.shelter.moe/karaokemugen/karaokemugen-app.git @@ -26,14 +26,18 @@ pkgbase = karaokemugen-git source = database.json source = icon256.png source = karaokemugen.desktop + source = 10-mugensudo + source = payload.sh md5sums = SKIP md5sums = SKIP - md5sums = 9bdad543ad67a669cd21cae2450d7fbc - md5sums = 6efac0086021d7a7abcf637aae17cc99 + md5sums = 7640e20425422b5cd146acbb51110ea6 + md5sums = 7f27a04c232e38ad6e070e742b0a2dda md5sums = c1807f76ea2d800999910fe66e56fe73 md5sums = 0f887855e641ec949ce7c6b69d79ad1e md5sums = 5e9a33a42fef7572b7e0fa504c586f32 - md5sums = dc5bfb40322b4f7ee1d0fb54c64aa71a + md5sums = 10561eed906a5efeed427f90501b4f49 + md5sums = 7304bcf403613a276dba896ba2d2a918 + md5sums = 6a0c5042def68d0eaffc2cc87cd11462 pkgname = karaokemugen-git diff --git a/10-mugensudo b/10-mugensudo new file mode 100644 index 000000000000..e2f06c2e1cb2 --- /dev/null +++ b/10-mugensudo @@ -0,0 +1,3 @@ +# The users added to the karaokemugen group can launch karaokemugen using electron runtime in system +Defaults!/usr/bin/electron,/opt/karaokemugen/exec.sh env_keep+="XAUTHORIZATION XAUTHORITY XAUTHPAYLOAD TZ PS2 PS1 PATH LS_COLORS KRB5CCNAME HOSTNAME DISPLAY COLORS" +%karaokemugen ALL=(karaokemugen) NOPASSWD: /usr/bin/electron,/opt/karaokemugen/exec.sh @@ -1,14 +1,15 @@ # Maintainer: leonekmi <usingarchbtw@leonekmi.fr> pkgname=karaokemugen-git -pkgver=3.2.0.rc1.r15.g1a01c9c8 -pkgrel=2 +pkgver=3.2.0.r0.g9ecde13e +pkgrel=1 pkgdesc="Karaoke playlist manager/player app used in parties or events." -arch=(x86_64 i686) +arch=('any') url="https://mugen.karaokes.moe/" license=('MIT') groups=() depends=('mpv' 'ffmpeg' 'postgresql' 'electron') makedepends=('git' 'npm' 'typescript' 'yarn' 'nodejs>=12') +optdepends=('sudo: for using karaokemugen-install script') provides=("${pkgname%-git}") conflicts=("${pkgname%-git}") replaces=() @@ -22,16 +23,20 @@ source=('karaokemugen::git+https://lab.shelter.moe/karaokemugen/karaokemugen-app 'database-tweak.diff' 'database.json' 'icon256.png' - 'karaokemugen.desktop') + 'karaokemugen.desktop' + '10-mugensudo' + 'payload.sh') noextract=() md5sums=('SKIP' - 'SKIP' - '9bdad543ad67a669cd21cae2450d7fbc' - '6efac0086021d7a7abcf637aae17cc99' - 'c1807f76ea2d800999910fe66e56fe73' - '0f887855e641ec949ce7c6b69d79ad1e' - '5e9a33a42fef7572b7e0fa504c586f32' - 'dc5bfb40322b4f7ee1d0fb54c64aa71a') + 'SKIP' + '7640e20425422b5cd146acbb51110ea6' + '7f27a04c232e38ad6e070e742b0a2dda' + 'c1807f76ea2d800999910fe66e56fe73' + '0f887855e641ec949ce7c6b69d79ad1e' + '5e9a33a42fef7572b7e0fa504c586f32' + '10561eed906a5efeed427f90501b4f49' + '7304bcf403613a276dba896ba2d2a918' + '6a0c5042def68d0eaffc2cc87cd11462') # Please refer to the 'USING VCS SOURCES' section of the PKGBUILD man page for # a description of each element in the source array. @@ -64,10 +69,12 @@ build() { yarn installSystemPanel # Build and package with electron-builder export NODE_ENV='production' + electronDist=$(dirname $(realpath $(which electron))) + electronVer=$(electron --version | tail -c +2) yarn build yarn buildFrontend yarn buildSystemPanel - "$(yarn global dir)/node_modules/.bin/electron-builder" --dir + "$(yarn global dir)/node_modules/.bin/electron-builder" --linux --x64 -c.electronDist=$electronDist -c.electronVersion=$electronVer --dir } package() { @@ -89,13 +96,17 @@ package() { # License install -dm755 "$pkgdir/usr/share/licenses/${pkgname%-git}" - cp --no-preserve=ownership,mode LICENSE.md "$pkgdir/usr/share/licenses/${pkgname%-git}/LICENSE" + install -m644 LICENSE.md "$pkgdir/usr/share/licenses/${pkgname%-git}/LICENSE" + + # sudo rule + install -dm750 "$pkgdir/etc/sudoers.d" + install -m440 "$srcdir/10-mugensudo" "$pkgdir/etc/sudoers.d/10-mugensudo" # Runtimes install -dm755 "$pkgdir/usr/bin/" - cp "$srcdir/run.sh" "$pkgdir/usr/bin/karaokemugen" - cp "$srcdir/install.sh" "$pkgdir/usr/bin/karaokemugen-install" - chmod 755 "$pkgdir/usr/bin/karaokemugen" "$pkgdir/usr/bin/karaokemugen-install" + install -m755 "$srcdir/run.sh" "$pkgdir/usr/bin/karaokemugen" + install -m755 "$srcdir/install.sh" "$pkgdir/usr/bin/karaokemugen-install" + install -m755 "$srcdir/payload.sh" "$pkgdir/opt/karaokemugen/exec.sh" # .desktop entry install -dm755 "$pkgdir/usr/share/pixmaps/" diff --git a/install.sh b/install.sh index 283906872a8b..852d2d28fd0d 100755 --- a/install.sh +++ b/install.sh @@ -44,7 +44,7 @@ setup_postgres() { select dbch in "Keep data" "Reset database"; do case $dbch in "Keep data" ) echo -e "${_COL_GREEN_}karaokemugen_app database will be used." ; return 0;; # TODO : maybe do some integrity checks - "Reset database" ) sudo -u postgres -g postgres -H -- psql -c "DROP DATABASE karaokemugen_app; DROP ROLE IF EXISTS karaokemugen_app;";; + "Reset database" ) sudo -u postgres -g postgres -H -- psql -c "DROP DATABASE karaokemugen_app;"; sudo -u postgres -g postgres -H -- psql -c "DROP ROLE IF EXISTS karaokemugen_app;";; esac done fi @@ -67,12 +67,16 @@ System: EOT } -create_system_group() { - if grep -q "^karaokemugen:" /etc/group; then - echo -e "${_BEGIN_}Using the existing ${_COL_YELLOW_}karaokemugen${_COL_BBLUE_} system group..." +create_system_user() { + if grep -q "^karaokemugen:" /etc/passwd; then + echo -e "${_BEGIN_}Using the existing ${_COL_YELLOW_}karaokemugen${_COL_BBLUE_} system user..." else - echo -e "${_BEGIN_}Creating ${_COL_YELLOW_}karaokemugen${_COL_BBLUE_} system group..." - sudo groupadd karaokemugen + echo -e "${_BEGIN_}Creating ${_COL_YELLOW_}karaokemugen${_COL_BBLUE_} system user..." + if grep -q "^karaokemugen:" /etc/groups; then + sudo useradd -g karaokemugen -M -d /opt/karaokemugen karaokemugen + else + sudo useradd -G audio -U -M -d /opt/karaokemugen karaokemugen + fi fi } @@ -87,6 +91,21 @@ add_user_to_group() { fi } +setup_pulsesocket() { + echo -e "${_BEGIN_}Creating a PulseAudio socket for sound..." + if grep -q "load-module module-native-protocol-unix auth-anonymous=1 socket=/tmp/pulseaudio" /etc/pulse/default.pa; then + # Already insalled + echo -e "${_COL_YELLOW_}PulseAudio socket is already exsiting. Skipping" + else + sudo tee -a /etc/pulse/default.pa > /dev/null <<EOF + +# Karaoke Mugen AUR Package workaround +load-module module-native-protocol-unix auth-anonymous=1 socket=/tmp/pulseaudio +EOF + echo -e "${_COL_GREEN_}PulseAudio socket created." + fi +} + # use colors only if we have them if [[ $(which tput > /dev/null 2>&1 && tput -T "${TERM}" colors || echo -n '0') -ge 8 ]] ; then _COL_YELLOW_='\e[0;33m' @@ -129,9 +148,9 @@ check_mugen setup_postgres -create_system_group +create_system_user add_user_to_group -sudo chown -R root:karaokemugen /opt/karaokemugen +sudo chown -R karaokemugen:karaokemugen /opt/karaokemugen apply_config diff --git a/karaokemugen.desktop b/karaokemugen.desktop index 28a92145ee31..4aaa3d3da360 100644 --- a/karaokemugen.desktop +++ b/karaokemugen.desktop @@ -5,6 +5,6 @@ Name=Karaoke Mugen Comment=Karaoke playlist manager/player app used in parties or events. Exec=karaokemugen Icon=karaokemugen -Terminal=true +Terminal=false Type=Application Categories=AudioVideo;Video
\ No newline at end of file diff --git a/karaokemugen.install b/karaokemugen.install index d1aefa87b931..31cc4dd65d97 100644 --- a/karaokemugen.install +++ b/karaokemugen.install @@ -4,7 +4,11 @@ post_install() { echo "- karaokemugen launches the app with Electron UI." } +post_upgrade() { + echo "You may need to run karaokemugen-install again. Keep that in mind." +} + post_remove() { - # Eventually make the user think of resources directories - echo + echo "The media files downloaded are still in the directory you set (/opt/karaokemugen/app by default)." + echo "Delete them to free space if you want." }
\ No newline at end of file diff --git a/payload.sh b/payload.sh new file mode 100644 index 000000000000..f2211160e086 --- /dev/null +++ b/payload.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Sudo payload for Mugen + +# Workaround for letting karaokemugen to access display +export XAUTHORITY="/tmp/mugenXauthority" +export HOME="/opt/karaokemugen" +touch $XAUTHORITY +xauth add $XAUTHPAYLOAD +# Workaround for letting karaokemugen to access audio +mkdir -p ~/.config/pulse/ +tee ~/.config/pulse/client.conf > /dev/null <<EOT +autospawn = no +default-server = unix:/tmp/pulseaudio +EOT + +electron /opt/karaokemugen/resources/app.asar "$@" +exit 0
\ No newline at end of file @@ -9,6 +9,30 @@ # This script runs Karaoke Mugen app (with some check to avoid some disasters) # From AUR package karaokemugen-git +launch_mugen() { + cd /opt/karaokemugen/ + + terms=" + x-terminal-emulator + konsole + gnome-terminal + xfce4-terminal + koi8rxterm + lxterm + uxterm + xterm" + + for term in $terms; do + export XAUTHPAYLOAD=$(xauth list|tail -1) + $term -e "sudo -u karaokemugen -- /opt/karaokemugen/exec.sh \"$@\"" + if [ $? -eq 0 ]; then + exit 0; + fi + done + + exit 1 +} + # use colors only if we have them if [[ $(which tput > /dev/null 2>&1 && tput -T "${TERM}" colors || echo -n '0') -ge 8 ]] ; then _COL_YELLOW_='\e[0;33m' @@ -22,14 +46,13 @@ fi # Check if the user is in the karaokemugen group if groups | grep -q '\bkaraokemugen\b'; then # Check if postgres is running - if lsof -Pi :5432 -sTCP:LISTEN -t >/dev/null ; then + if lsof -Pi :5432 -sTCP:LISTEN -t >/dev/null ; then # FIXME: this command is not working as normal user echo "Starting Karaoke Mugen..." else echo -e "${_COL_YELLOW_}Postgres seems down... Trying to start Karaoke Mugen anyway." fi # Launch Karaoke Mugen - cd /opt/karaokemugen/ - PORTABLE_EXECUTABLE_DIR=/opt/karaokemugen /opt/karaokemugen/karaokemugen + launch_mugen else echo -e "${_COL_BRED_}->${_COL_DEFAULT_} ${_COL_YELLOW_}WARNING:${_COL_DEFAULT_} You don't have the rights to access the Karaoke Mugen app" echo -e "${_COL_BBLUE_}You can grant yourself the access to Karaoke Mugen by executing the ${_COL_YELLOW_}\`karaokemugen-install -g\`${_COL_BBLUE_} command" |