From bbf5814ec32ac78552bec7a9033d76277245472e Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Fri, 27 Jan 2017 23:13:30 +0000
Subject: tigervnc: add .install to create vncsvc user

add vncsvc sudo rules. refs #1007
---
 abs/extra/tigervnc/PKGBUILD      | 23 ++++++++++++++++-------
 abs/extra/tigervnc/__changelog   |  2 ++
 abs/extra/tigervnc/tiger.install | 21 +++++++++++++++++++++
 abs/extra/tigervnc/vncsvc.rules  |  3 +++
 4 files changed, 42 insertions(+), 7 deletions(-)
 create mode 100644 abs/extra/tigervnc/__changelog
 create mode 100644 abs/extra/tigervnc/tiger.install
 create mode 100644 abs/extra/tigervnc/vncsvc.rules

diff --git a/abs/extra/tigervnc/PKGBUILD b/abs/extra/tigervnc/PKGBUILD
index 6d5da40..db327ef 100644
--- a/abs/extra/tigervnc/PKGBUILD
+++ b/abs/extra/tigervnc/PKGBUILD
@@ -3,7 +3,7 @@
 
 pkgname=tigervnc
 pkgver=1.6.0
-pkgrel=1
+pkgrel=2
 _xorgver=1.18.0
 pkgdesc="Suite of VNC servers and clients. Based on the VNC 4 branch of TightVNC."
 arch=('i686' 'x86_64')
@@ -19,18 +19,14 @@ makedepends=('cmake' 'nasm' 'xorg-font-util' 'xorg-util-macros' 'bigreqsproto'
 	     'mesa' 'imagemagick')
 optdepends=('mesa: for OpenGL functionality in Xvnc')
 conflicts=('tightvnc')
+install=tiger.install
 source=($pkgname-$pkgver.tar.gz::https://github.com/TigerVNC/tigervnc/archive/v${pkgver}.tar.gz
 	ftp://ftp.freedesktop.org/pub/xorg/individual/xserver/xorg-server-${_xorgver}.tar.bz2
 	vncserver.service
 	vncviewer.desktop
+    vncsvc.rules
 	gethomedir.patch
 	xorg118.patch)
-md5sums=('78b736445781d86c48e942465a391ccc'
-         '3c1c1057d3ad27380d8dd87ffcc182cd'
-         '1aad8f06504b3e29a24ccfbaab617973'
-         'b200d83c60e80c6f9693ea19a2d9f5b0'
-         '22f1523a0eca56ad79cfabd0db6e2cf6'
-         '2fd32181679077eb7f7ca06cf25f443f')
 
 prepare() {
   cd ${srcdir}/${pkgname}-${pkgver}
@@ -71,4 +67,17 @@ package() {
     $pkgdir/usr/lib/systemd/user/vncserver@.service
   install -Dm0644 $srcdir/vncserver.service $pkgdir/usr/lib/systemd/system/vncserver.service
   install -Dm0644 $srcdir/vncviewer.desktop $pkgdir/usr/share/applications/vncviewer.desktop
+
+  #LinHES sudo rules
+  mkdir -p $pkgdir/etc/sudoers.d/
+  chmod 750 $pkgdir/etc/sudoers.d/
+  chown -R root:root $pkgdir/etc/sudoers.d
+  install -o root -g root -m 0750 $srcdir/vncsvc.rules $pkgdir/etc/sudoers.d/vncsvc-tigervnc
 }
+md5sums=('78b736445781d86c48e942465a391ccc'
+         '3c1c1057d3ad27380d8dd87ffcc182cd'
+         '1aad8f06504b3e29a24ccfbaab617973'
+         'b200d83c60e80c6f9693ea19a2d9f5b0'
+         'f333a228ddbefffc6ce945754bc9c5c5'
+         '22f1523a0eca56ad79cfabd0db6e2cf6'
+         '2fd32181679077eb7f7ca06cf25f443f')
diff --git a/abs/extra/tigervnc/__changelog b/abs/extra/tigervnc/__changelog
new file mode 100644
index 0000000..d7903f8
--- /dev/null
+++ b/abs/extra/tigervnc/__changelog
@@ -0,0 +1,2 @@
+PKGBUILD: tiger.install: keep so the vncsvc user gets created
+PKGBUILD: vncsvc.rules: install sudo rules
diff --git a/abs/extra/tigervnc/tiger.install b/abs/extra/tigervnc/tiger.install
new file mode 100644
index 0000000..f04c011
--- /dev/null
+++ b/abs/extra/tigervnc/tiger.install
@@ -0,0 +1,21 @@
+post_install(){
+  groupadd -g 78 vncsvc &>/dev/null
+  useradd -u 78 -m -g vncsvc -d /home/vncsvc -s /bin/bash vncsvc &>/dev/null
+  usermod -a -G mythtv vncsvc
+  chown -R vncsvc:vncsvc /home/vncsvc &>/dev/null
+}
+
+post_upgrade(){
+  getent group vncsvc >/dev/null 2>&1 || groupadd -g 78 vncsvc &>/dev/null
+  getent passwd vncsvc >/dev/null 2>&1 || useradd -u 78 -g vncsvc -m -d /home/vncsvc -s /bin/bash vncsvc &>/dev/null
+  usermod -a -G mythtv vncsvc
+}
+
+post_remove(){
+  if getent passwd vncsvc >/dev/null 2>&1; then
+    userdel vncsvc
+  fi
+  if getent group vncsvc >/dev/null 2>&1; then
+    groupdel vncsvc
+  fi
+}
diff --git a/abs/extra/tigervnc/vncsvc.rules b/abs/extra/tigervnc/vncsvc.rules
new file mode 100644
index 0000000..49dd3ad
--- /dev/null
+++ b/abs/extra/tigervnc/vncsvc.rules
@@ -0,0 +1,3 @@
+vncsvc ALL=(ALL) NOPASSWD: /usr/MythVantage/bin/mythinstall -s *
+vncsvc ALL=(ALL) NOPASSWD: /usr/MythVantage/bin/MythVantage -s *
+vncsvc ALL=(ALL) NOPASSWD: /usr/MythVantage/bin/systemconfig.py
-- 
cgit v0.12

