From 55de7f7d1640552913207bd7a8b8e5a6e254bd07 Mon Sep 17 00:00:00 2001 From: sobomax Date: Mon, 14 Jan 2002 17:37:30 +0000 Subject: When installing package automagically create required user/group if they don't exist. This should make it possible to do unattented installation of pre-built gdm package and gnome meta-package. Bump PORTREVISION. Submitted by: Joe Marcus Clarke --- x11/gdm/Makefile | 8 +++----- x11/gdm/pkg-install | 36 ++++++++++++++++++++++++++++++++++-- x11/gdm2/Makefile | 8 +++----- x11/gdm2/pkg-install | 36 ++++++++++++++++++++++++++++++++++-- 4 files changed, 74 insertions(+), 14 deletions(-) (limited to 'x11') diff --git a/x11/gdm/Makefile b/x11/gdm/Makefile index de0302d..c1d840f 100644 --- a/x11/gdm/Makefile +++ b/x11/gdm/Makefile @@ -7,7 +7,7 @@ PORTNAME= gdm PORTVERSION= 2.2.5.4 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= x11 gnome MASTER_SITES= ${MASTER_SITE_GNOME} MASTER_SITE_SUBDIR= stable/sources/gdm @@ -36,12 +36,10 @@ pre-patch: 's|\$\(datadir\)/gnome/|\$\(datadir\)/|g ; \ s|\$\(datadir\)/locale|\$\(prefix\)/share/locale|g' +post-install: .if !defined(BATCH) && !defined(PACKAGE_BUILDING) -pre-install: - @${SH} ${PKGREQ} ${PKGNAME} INSTALL + @${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL .endif - -post-install: @${INSTALL_SCRIPT} ${WRKSRC}/config/gnomerc ${PREFIX}/etc/gdm @${CHOWN} -R 91:91 ${PREFIX}/share/gnome/gdm ${PREFIX}/etc/gdm @${CAT} ${PKGMESSAGE} diff --git a/x11/gdm/pkg-install b/x11/gdm/pkg-install index 0b1f96f..23dd7d7 100644 --- a/x11/gdm/pkg-install +++ b/x11/gdm/pkg-install @@ -1,7 +1,39 @@ #!/bin/sh -if [ "$2" = "POST-INSTALL" -o -n "${PACKAGE_BUILDING}" ]; then - exit 0 +if [ -n "${PACKAGE_BUILDING}" ]; then + exit 0 +fi + +if [ "$2" = "POST-INSTALL" ]; then + USER=gdm + GROUP=${USER} + UID=91 + GID=${UID} + + if pw group show "${GROUP}" 2>/dev/null; then + echo "You already have a group \"${GROUP}\", so I will use it." + else + if pw groupadd ${GROUP} -g ${GID}; then + echo "Added group \"${GROUP}\"." + else + echo "Adding group \"${GROUP}\" failed..." + exit 1 + fi + fi + + if pw user show "${USER}" 2>/dev/null; then + echo "You already have a user \"${USER}\", so I will use it." + else + if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \ + -d "/nonexistent" -s /sbin/nologin -c "GNOME Display Manager" + then + echo "Added user \"${USER}\"." + else + echo "Adding user \"${USER}\" failed..." + exit 1 + fi + fi + exit 0 fi /usr/bin/dialog --yesno "GDM may contain vulnerabilities leading local root compromise, and it is reported widely with various security sites and groups. It is not recommended that this port be installed in public environment. Do you wish to accept the security risk and build GDM anyway?" 10 60 || /usr/bin/false diff --git a/x11/gdm2/Makefile b/x11/gdm2/Makefile index de0302d..c1d840f 100644 --- a/x11/gdm2/Makefile +++ b/x11/gdm2/Makefile @@ -7,7 +7,7 @@ PORTNAME= gdm PORTVERSION= 2.2.5.4 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= x11 gnome MASTER_SITES= ${MASTER_SITE_GNOME} MASTER_SITE_SUBDIR= stable/sources/gdm @@ -36,12 +36,10 @@ pre-patch: 's|\$\(datadir\)/gnome/|\$\(datadir\)/|g ; \ s|\$\(datadir\)/locale|\$\(prefix\)/share/locale|g' +post-install: .if !defined(BATCH) && !defined(PACKAGE_BUILDING) -pre-install: - @${SH} ${PKGREQ} ${PKGNAME} INSTALL + @${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL .endif - -post-install: @${INSTALL_SCRIPT} ${WRKSRC}/config/gnomerc ${PREFIX}/etc/gdm @${CHOWN} -R 91:91 ${PREFIX}/share/gnome/gdm ${PREFIX}/etc/gdm @${CAT} ${PKGMESSAGE} diff --git a/x11/gdm2/pkg-install b/x11/gdm2/pkg-install index 0b1f96f..23dd7d7 100644 --- a/x11/gdm2/pkg-install +++ b/x11/gdm2/pkg-install @@ -1,7 +1,39 @@ #!/bin/sh -if [ "$2" = "POST-INSTALL" -o -n "${PACKAGE_BUILDING}" ]; then - exit 0 +if [ -n "${PACKAGE_BUILDING}" ]; then + exit 0 +fi + +if [ "$2" = "POST-INSTALL" ]; then + USER=gdm + GROUP=${USER} + UID=91 + GID=${UID} + + if pw group show "${GROUP}" 2>/dev/null; then + echo "You already have a group \"${GROUP}\", so I will use it." + else + if pw groupadd ${GROUP} -g ${GID}; then + echo "Added group \"${GROUP}\"." + else + echo "Adding group \"${GROUP}\" failed..." + exit 1 + fi + fi + + if pw user show "${USER}" 2>/dev/null; then + echo "You already have a user \"${USER}\", so I will use it." + else + if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \ + -d "/nonexistent" -s /sbin/nologin -c "GNOME Display Manager" + then + echo "Added user \"${USER}\"." + else + echo "Adding user \"${USER}\" failed..." + exit 1 + fi + fi + exit 0 fi /usr/bin/dialog --yesno "GDM may contain vulnerabilities leading local root compromise, and it is reported widely with various security sites and groups. It is not recommended that this port be installed in public environment. Do you wish to accept the security risk and build GDM anyway?" 10 60 || /usr/bin/false -- cgit v1.1