diff options
author | anders <anders@FreeBSD.org> | 2004-11-23 15:29:45 +0800 |
---|---|---|
committer | anders <anders@FreeBSD.org> | 2004-11-23 15:29:45 +0800 |
commit | 4b5916713ce1dbc0793ac1b65ea0522fb6c37612 (patch) | |
tree | c2353c2569da43477d2b74276d7046224d6f6b15 /net-mgmt/nav/scripts | |
parent | 3f5e639d59f7809ca41e1df8065f4014588e6541 (diff) | |
download | freebsd-ports-gnome-4b5916713ce1dbc0793ac1b65ea0522fb6c37612.tar.gz freebsd-ports-gnome-4b5916713ce1dbc0793ac1b65ea0522fb6c37612.tar.zst freebsd-ports-gnome-4b5916713ce1dbc0793ac1b65ea0522fb6c37612.zip |
Add NAV (Network Administration Visualized), a network administration
package from NTNU - Norwegian University of Science and Technology.
This port is work-in-progress, currently.
Sponsored by: University of Tromsø
Diffstat (limited to 'net-mgmt/nav/scripts')
-rw-r--r-- | net-mgmt/nav/scripts/fixpyenc | 12 | ||||
-rw-r--r-- | net-mgmt/nav/scripts/myautoconf | 148 | ||||
-rw-r--r-- | net-mgmt/nav/scripts/navenv | 15 |
3 files changed, 175 insertions, 0 deletions
diff --git a/net-mgmt/nav/scripts/fixpyenc b/net-mgmt/nav/scripts/fixpyenc new file mode 100644 index 000000000000..4f6c5020004a --- /dev/null +++ b/net-mgmt/nav/scripts/fixpyenc @@ -0,0 +1,12 @@ +#! /bin/sh + +encstr="# -*- coding: ISO8859-1 -*-" + +if [ -z "`head -1 $1 | egrep '#.*!.*python'`" ] +then + (echo $encstr; cat $1) >$1.tmp +else + (head -1 $1; echo $encstr; tail +2 $1) >$1.tmp +fi +cp $1.tmp $1 +rm -f $1.tmp diff --git a/net-mgmt/nav/scripts/myautoconf b/net-mgmt/nav/scripts/myautoconf new file mode 100644 index 000000000000..6183da54a6d7 --- /dev/null +++ b/net-mgmt/nav/scripts/myautoconf @@ -0,0 +1,148 @@ +#! /bin/sh +# auto-configure nav, anders@FreeBSD.org 2004-11-14 +# +# Variabels that needs to be set: LOCALBASE + +navuser=navcron +navgroup=nav + +if [ -z "$LOCALBASE" ] +then + echo "LOCALBASE variable not set. Aborting." + exit 1 +fi +if [ -z "$PORTSDIR" ] +then + echo "PORTSDIR variable not set. Aborting." + exit 1 +fi + +if [ -z "`grep \"^if \[ -f $LOCALBASE/nav/bin/navenv\.sh \]; then \. $LOCALBASE/nav/bin/navenv\.sh; fi\" /etc/profile`" ] +then + echo "Add sourcing of environment in /etc/profile." + echo "if [ -f $LOCALBASE/nav/bin/navenv.sh ]; then . $LOCALBASE/nav/bin/navenv.sh; fi" >>/etc/profile +fi + +if [ ! -f $LOCALBASE/etc/cricket-conf.pl ] +then + echo "Default cricket config missing, copying default one to" + echo "$LOCALBASE/etc/cricket-conf.pl." + install -g $navgroup -o $navuser -m 0755 $LOCALBASE/etc/cricket-conf.pl.dist $LOCALBASE/etc/cricket-conf.pl +fi + +setdbcvar() { + # $1: variable $2: password $3: config + sed "s/^$1=.*/$1=$2/" $3 >$3.tmp + cp $3.tmp $3 + rm -f $3.tmp +} + +ifyes() { + read line + if [ "`echo $line | cut -c1-1 | tr 'A-Z' 'a-z'`" != "y" ] + then + return 1 + fi +} + +apgck() { + if [ ! -x $LOCALBASE/bin/apg ] + then + printf "Password-generation program ports/security/apg is missing. Do you want me to\n" + printf "try to install it for you? (y/n) " + if (ifyes) + then + cd $PORTSDIR/security/apg + (make clean && make install && make clean) >/dev/null 2>&1 + fi + if [ ! -x $LOCALBASE/bin/apg ] + then + echo "Please install ports/security/apg. Need it to generate random passwords" + echo "for PostgreSQL. Then re-run this script/make auto-config." + exit 1 + fi + fi +} + +if (id pgsql >/dev/null 2>&1) +then + printf "Do you want to auto-configure PostgreSQL? (y/n) " + if (ifyes) + then + apgck + + pdir=$LOCALBASE/pgsql/data + pconf=$pdir/postgresql.conf + phbaconf=$pdir/pg_hba.conf + pgsqlp=`$LOCALBASE/bin/apg -M NCL -n 1` + navreadp=`$LOCALBASE/bin/apg -M NCL -n 1` + navwritep=`$LOCALBASE/bin/apg -M NCL -n 1` + navdbconf=$LOCALBASE/nav/etc/db.conf + navdbbkconf=$LOCALBASE/nav/etc/pg_backup.conf + + if [ ! -d $pdir ] + then + echo "Running PostgreSQL initdb." + su -l pgsql -c "$LOCALBASE/bin/initdb" + fi + if [ -f $pconf ] + then + echo "Setting up TCP/IP socket for PostgreSQL." + sed "s/.*tcpip_socket.*/tcpip_socket = true/" \ + $pconf >$pconf.tmp + cp $pconf.tmp $pconf + rm -f $pconf.tmp + fi + printf "To continue, we need to start the database engine. Proceed? (y/n) " + if (ifyes) + then + echo "Starting PostgreSQL database." + su -l pgsql -c "$LOCALBASE/bin/pg_ctl start -s -w" + echo "Waiting 5 seconds." + sleep 5 + echo "Creating users & databases, importing data." + usedb=template1 +# firstdb=`su -l pgsql -c "$LOCALBASE/bin/psql -l -t -A" | head -1 | cut -d'|' -f1` + PGUSER=pgsql + export PGUSER + $LOCALBASE/bin/createdb --encoding UTF-8 manage + $LOCALBASE/bin/createdb --encoding UTF-8 navprofiles + $LOCALBASE/bin/createdb --encoding UTF-8 logger + $LOCALBASE/bin/createlang plpgsql manage + $LOCALBASE/bin/createlang plpgsql navprofiles + $LOCALBASE/bin/createlang plpgsql logger + $LOCALBASE/bin/createuser -A -D navread + $LOCALBASE/bin/createuser -A -D navwrite + $LOCALBASE/bin/psql -f $LOCALBASE/nav/doc/sql/manage.sql manage + $LOCALBASE/bin/psql -f $LOCALBASE/nav/doc/sql/navprofiles.sql navprofiles + $LOCALBASE/bin/psql -f $LOCALBASE/nav/doc/sql/logger.sql logger + $LOCALBASE/bin/psql -f $LOCALBASE/nav/doc/sql/snmpoid.sql manage + echo "Setting passwords." + echo "alter user pgsql with password '$pgsqlp';" | $LOCALBASE/bin/psql $usedb + echo "alter user navread with password '$navreadp';" | $LOCALBASE/bin/psql $usedb + echo "alter user navwrite with password '$navwritep';" | $LOCALBASE/bin/psql $usedb + echo + echo "Password for database user navread: $navreadp" + echo "Password for database user navwrite: $navwritep" + echo "Password for database user pgsql: $pgsqlp" + echo "Make a mental note of it!" + echo + echo "Setting database passwords in NAV db.conf and pg_backup.conf." + setdbcvar userpw_navread $navreadp $navdbconf + setdbcvar userpw_navwrite $navwritep $navdbconf + setdbcvar username pgsql $navdbbkconf + setdbcvar password $pgsqlp $navdbbkconf + echo "Configure database to only allow authentcated connections." + cat $phbaconf | sed -E "s/(^(local|host).*)trust/\1md5/" >$phbaconf.tmp + cp $phbaconf.tmp $phbaconf + rm -f $phbaconf.tmp + echo "Reloading database." + su -l pgsql -c "$LOCALBASE/bin/pg_ctl reload" + else + echo "Fine, you have an empty database set up. Now create users, set passwords," + echo "and import default data. Do not forget to configure pg_hba.conf." + fi + else + echo "Fine, see if I care." + fi +fi diff --git a/net-mgmt/nav/scripts/navenv b/net-mgmt/nav/scripts/navenv new file mode 100644 index 000000000000..f84fe834f2f1 --- /dev/null +++ b/net-mgmt/nav/scripts/navenv @@ -0,0 +1,15 @@ +#! /bin/sh + +if [ -z "$LOCALBASE" -o -z "$JAVA_HOME" ] +then + echo "ERROR: \$LOCALBASE and/or \$JAVA_HOME not set. Exiting." + exit 1 +fi + +echo "PYTHONPATH=$LOCALBASE/nav/lib/python" +echo "JAVA_HOME=$JAVA_HOME" +echo "PATH=\$PATH:$LOCALBASE/nav/bin:$JAVA_HOME/bin" +echo "PERL5LIB=$LOCALBASE/nav/lib/perl:$LOCALBASE/cricket/cricket/lib" +echo "CLASSPATH=\"\`echo $LOCALBASE/nav/lib/java/*.jar | tr ' ' ':'\`:$LOCALBASE/share/java/classes/postgresql.jar:$LOCALBASE/share/java/classes/snmp.jar\"" +#echo "CLASSPATH=\"\`find $LOCALBASE/nav/lib/java -type f | tr '\n' ':' | sed 's/:$//'\`:$LOCALBASE/share/java/classes/postgresql.jar:$LOCALBASE/share/java/classes/snmp.jar\"" +echo "export PYTHONPATH JAVA_HOME PATH PERL5LIB CLASSPATH" |