From badc83477806938f63e5ca4148aa28390be55edf Mon Sep 17 00:00:00 2001 From: Sergey Matveychuk Date: Thu, 21 Apr 2005 07:02:05 +0000 Subject: - Fix removing logic for user config [1] - Remove useless empty dirs - Fix package - Makefile refactoring - Utilize SUB_FILES magic - Update pkg-message Reported by: kris (via pointyhat) [1] --- net-mgmt/cacti/Makefile | 28 ++++++++------------- net-mgmt/cacti/files/pkg-install.in | 50 +++++++++++++++++++++++++++++++++++++ net-mgmt/cacti/files/pkg-message.in | 21 ++++++++++++++++ net-mgmt/cacti/pkg-install | 46 ---------------------------------- net-mgmt/cacti/pkg-message | 18 ------------- net-mgmt/cacti/pkg-plist | 4 +-- 6 files changed, 83 insertions(+), 84 deletions(-) create mode 100644 net-mgmt/cacti/files/pkg-install.in create mode 100644 net-mgmt/cacti/files/pkg-message.in delete mode 100644 net-mgmt/cacti/pkg-install delete mode 100644 net-mgmt/cacti/pkg-message (limited to 'net-mgmt') diff --git a/net-mgmt/cacti/Makefile b/net-mgmt/cacti/Makefile index e8247a057587..e703f216f50f 100644 --- a/net-mgmt/cacti/Makefile +++ b/net-mgmt/cacti/Makefile @@ -7,7 +7,7 @@ PORTNAME= cacti PORTVERSION= 0.8.6c -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= net www MASTER_SITES= http://www.cacti.net/downloads/ @@ -35,32 +35,27 @@ USE_PHP= mysql pcre session xml WANT_PHP_WEB= yes NO_BUILD= yes PKGMESSAGE= ${WRKDIR}/pkg-message +PKGINSTALL= ${WRKDIR}/pkg-install +SUB_FILES= pkg-message pkg-install CACTIDIR?= share/cacti CACTIUSER?= cacti CACTIGROUP?= ${CACTIUSER} PLIST_SUB+= CACTIDIR=${CACTIDIR} - -post-extract: - @${RM} -rf ${WRKSRC}/cactid/.deps +SUB_LIST+= CACTIDIR=${CACTIDIR} CACTIUSER=${CACTIUSER} \ + CACTIGROUP=${CACTIGROUP} post-patch: - @${CAT} pkg-message | ${SED} -e 's|%%PREFIX%%|${PREFIX}| ; \ - s|%%LOCALBASE%%|${LOCALBASE}| ; \ - s|%%CACTIDIR%%|${CACTIDIR}| ; \ - s|%%CACTIUSER%%|${CACTIUSER}|' > ${PKGMESSAGE} + @${FIND} ${WRKSRC} -name \*.orig -delete; \ + ${MV} ${WRKSRC}/include/config.php ${WRKSRC}/include/config.php.orig; \ + ${RM} -d ${WRKSRC}/include/lang/en ${WRKSRC}/include/lang -# Create cacti user/group and clean *.orig files pre-install: - @PREFIX=${PREFIX} CACTIDIR=${CACTIDIR} CACTIUSER=${CACTIUSER} \ - CACTIGROUP=${CACTIGROUP} ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL; \ - cd ${WRKSRC}; \ - ${FIND} . -name \*.orig -delete + @${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL; \ do-install: @${MKDIR} ${PREFIX}/${CACTIDIR}; \ - ${MV} ${WRKSRC}/include/config.php ${WRKSRC}/include/config.php.orig; \ - ${CP} -R ${WRKSRC}/* ${PREFIX}/${CACTIDIR}/ + ${CP} -R ${WRKSRC}/* ${PREFIX}/${CACTIDIR}/; \ if [ ! -f ${PREFIX}/${CACTIDIR}/include/config.php ]; then \ ${CP} ${PREFIX}/${CACTIDIR}/include/config.php.orig \ ${PREFIX}/${CACTIDIR}/include/config.php; \ @@ -68,8 +63,7 @@ do-install: # Fix permissions post-install: - @PREFIX=${PREFIX} CACTIDIR=${CACTIDIR} CACTIUSER=${CACTIUSER} \ - CACTIGROUP=${CACTIGROUP} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL + @${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL @${CAT} ${PKGMESSAGE} .include diff --git a/net-mgmt/cacti/files/pkg-install.in b/net-mgmt/cacti/files/pkg-install.in new file mode 100644 index 000000000000..da76801ae6b9 --- /dev/null +++ b/net-mgmt/cacti/files/pkg-install.in @@ -0,0 +1,50 @@ +#!/bin/sh + +PW=/usr/sbin/pw +UID=107 +GID=${UID} +CACTIUSER=%%CACTIUSER%% +CACTIGROUP=%%CACTIGROUP%% +CACTIDIR=%%CACTIDIR%% +PREFIX=%%PREFIX%% + +case $2 in + +PRE-INSTALL) + + if ${PW} group show "${CACTIGROUP}" 2>/dev/null; then + echo "You already have a group \"${CACTIGROUP}\", so I will use it." + else + if ${PW} groupadd ${CACTIGROUP} -g ${GID}; then + echo "Added group \"${CACTIGROUP}\"." + else + echo "Adding group \"${CACTIGROUP}\" failed..." + exit 1 + fi + fi + + if ${PW} user show "${CACTIUSER}" 2>/dev/null; then + echo "You already have a user \"${CACTIUSER}\", so I will use it." + else + if ${PW} useradd ${CACTIUSER} -u ${UID} -g ${CACTIGROUP} -h - \ + -d "/nonexistent" -s /sbin/nologin -c "Cacti Sandbox" + then + echo "Added user \"${CACTIUSER}\"." + else + echo "Adding user \"${CACTIUSER}\" failed..." + exit 1 + fi + fi + ;; + +POST-INSTALL) + + chown ${CACTIUSER}:${CACTIGROUP} ${PREFIX}/${CACTIDIR}/log/ + chown ${CACTIUSER}:${CACTIGROUP} ${PREFIX}/${CACTIDIR}/log/* + chown ${CACTIUSER}:${CACTIGROUP} ${PREFIX}/${CACTIDIR}/rra/ + ;; +*) + exit 1 +;; +esac +exit diff --git a/net-mgmt/cacti/files/pkg-message.in b/net-mgmt/cacti/files/pkg-message.in new file mode 100644 index 000000000000..f2df9ffd151e --- /dev/null +++ b/net-mgmt/cacti/files/pkg-message.in @@ -0,0 +1,21 @@ +================================================================== +Cacti is now installed. You may have to follow this steps +to make it work correctly. + +1: Create the MySQL database +# mysqladmin --user=root create cacti +2: Create a mysql user/password for cacti +(change user and/or password if requered) +# echo "GRANT ALL ON cacti.* TO cactiuser at localhost IDENTIFIED BY 'cactiuser'; FLUSH PRIVILEGES;" | mysql && +3: Import the default cacti database +# mysql cacti < %%PREFIX%%/%%CACTIDIR%%/cacti.sql +4: Edit include/config.php +Specify the MySQL user, password and database for your cacti configuration. +5: Add a line to your /etc/crontab file similar to: +*/5 * * * * %%CACTIUSER%% %%LOCALBASE%%/bin/php %%PREFIX%%/%%CACTIDIR%%/poller.php > /dev/null 2>&1 +6: Add alias in apache config for the cacti dir +Alias /cacti "%%PREFIX%%/%%CACTIDIR%%/" +7: Open cacti login page in your web browser and login with admin/admin + +Have fun! +================================================================== diff --git a/net-mgmt/cacti/pkg-install b/net-mgmt/cacti/pkg-install deleted file mode 100644 index 86d8f0d137ed..000000000000 --- a/net-mgmt/cacti/pkg-install +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -PW=/usr/sbin/pw -UID=107 -GID=${UID} - -case $2 in - -PRE-INSTALL) - - if ${PW} group show "${CACTIGROUP}" 2>/dev/null; then - echo "You already have a group \"${CACTIGROUP}\", so I will use it." - else - if ${PW} groupadd ${CACTIGROUP} -g ${GID}; then - echo "Added group \"${CACTIGROUP}\"." - else - echo "Adding group \"${CACTIGROUP}\" failed..." - exit 1 - fi - fi - - if ${PW} user show "${CACTIUSER}" 2>/dev/null; then - echo "You already have a user \"${CACTIUSER}\", so I will use it." - else - if ${PW} useradd ${CACTIUSER} -u ${UID} -g ${CACTIGROUP} -h - \ - -d "/nonexistent" -s /sbin/nologin -c "Cacti Sandbox" - then - echo "Added user \"${CACTIUSER}\"." - else - echo "Adding user \"${CACTIUSER}\" failed..." - exit 1 - fi - fi - ;; - -POST-INSTALL) - - chown ${CACTIUSER}:${CACTIGROUP} ${PREFIX}/${CACTIDIR}/log/ - chown ${CACTIUSER}:${CACTIGROUP} ${PREFIX}/${CACTIDIR}/log/* - chown ${CACTIUSER}:${CACTIGROUP} ${PREFIX}/${CACTIDIR}/rra/ - ;; -*) - exit 1 -;; -esac -exit diff --git a/net-mgmt/cacti/pkg-message b/net-mgmt/cacti/pkg-message deleted file mode 100644 index 9b37b13e9b41..000000000000 --- a/net-mgmt/cacti/pkg-message +++ /dev/null @@ -1,18 +0,0 @@ -================================================================== -Cacti is now installed. You may have to follow this steps -to make it work correctly. - -1: Create the MySQL database -# mysqladmin --user=root create cacti -2: Create a mysql user/password for cacti -# echo "GRANT ALL ON cacti.* TO cactiuser at localhost IDENTIFIED BY 'cactiuser'; FLUSH PRIVILEGES;" | mysql && -3: Import the default cacti database -# mysql cacti < %%PREFIX%%/%%CACTIDIR%%/cacti.sql -4: Edit your config.php -Specify the MySQL user, password and database for your cacti configuration. -5: Add a line to your /etc/crontab file similar to: -*/5 * * * * %%CACTIUSER%% %%LOCALBASE%%/bin/php %%PREFIX%%/%%CACTIDIR%%/poller.php > /dev/null 2>&1 -6: Point your web browser to the cacti dir and login with admin/admin - -Have fun! -================================================================== diff --git a/net-mgmt/cacti/pkg-plist b/net-mgmt/cacti/pkg-plist index 6f01b6feb0a8..530ea61c03fc 100644 --- a/net-mgmt/cacti/pkg-plist +++ b/net-mgmt/cacti/pkg-plist @@ -126,9 +126,9 @@ %%CACTIDIR%%/images/transparent_line.gif %%CACTIDIR%%/include/auth.php %%CACTIDIR%%/include/bottom_footer.php +@unexec cmp -s %D/%%CACTIDIR%%/include/config.php.orig %D/%%CACTIDIR%%/include/config.php && rm -f %D/%%CACTIDIR%%/include/config.php %%CACTIDIR%%/include/config.php.orig @exec [ -f %D/%%CACTIDIR%%/include/config.php ] || cp %D/%%CACTIDIR%%/include/config.php.orig %D/%%CACTIDIR%%/include/config.php -@unexec if cmp -s %D/%%CACTIDIR%%/include/config.php.orig %D/%%CACTIDIR%%/include/config.php; then rm -f %D/%%CACTIDIR%%/include/config.php; fi %%CACTIDIR%%/include/config_arrays.php %%CACTIDIR%%/include/config_constants.php %%CACTIDIR%%/include/config_form.php @@ -379,8 +379,6 @@ @dirrm %%CACTIDIR%%/lib @dirrm %%CACTIDIR%%/install @dirrm %%CACTIDIR%%/include/treeview -@dirrm %%CACTIDIR%%/include/lang/en -@dirrm %%CACTIDIR%%/include/lang @dirrm %%CACTIDIR%%/include/jscalendar/lang @dirrm %%CACTIDIR%%/include/jscalendar @dirrm %%CACTIDIR%%/include/html -- cgit