Advertisement
Guest User

pkg_config from noc-15.05.1.ebuild

a guest
May 27th, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.59 KB | None | 0 0
  1. pkg_config() {
  2.         ebegin "Checking PostreSQL server"
  3.         if [ -z "$(/etc/init.d/postgresql-* -C status |grep started)" ] ; then
  4.                 eend 1
  5.                 ewarn "Configure PostgreSQL server if you run it first time, like this:"
  6.                 ewarn "Check /etc/conf.d/postgresql-9.4"
  7.                 ewarn " # emerge --config dev-db/postgresql"
  8.                 ewarn "Then run PostgreSQL server:"
  9.                 ewarn " # /etc/init.d/postgresql-9.4 start"
  10.                 die "Run PostgreSQL server!"
  11.         else
  12.                 eend 0
  13.         fi
  14.  
  15.         ebegin "Checking MongoDB server"
  16.         if [ -z "$(/etc/init.d/mongodb -C status |grep started)" ] ; then
  17.                 eend 1
  18.                 ewarn "Check /etc/mongodb.conf"
  19.                 ewarn "Run MongoDB server:"
  20.                 ewarn " # /etc/init.d/mongodb start"
  21.                 die "Run MongoDB server!"
  22.         else
  23.                 eend 0
  24.         fi
  25.  
  26.         cd /opt/noc
  27.         [ -f ./etc/upgrade.defaults ] && . ./etc/upgrade.defaults
  28.         . ./etc/upgrade.conf || die "Can't find configfile: /opt/noc/etc/upgrade.conf Create it from /opt/noc/etc/upgrade.defaults"
  29.  
  30.         groupadd -f "${NOC_GROUP}"
  31.         useradd -g "${NOC_GROUP}" -s /bin/bash -M -d /opt/noc "${NOC_USER}"
  32.         touch .bash_history
  33.         chown -R "${NOC_USER}":"${NOC_GROUP}" .bash_history
  34.         chmod 600 .bash_history
  35.  
  36.         if use extensions; then
  37.                 chown -R "${NOC_USER}":"${NOC_GROUP}" static/staticvlan
  38.         fi
  39.  
  40.         einfo "Create PostgreSQL 'noc' user and database..."
  41.         if [ "${PG_PASSWORD}" == "noc" ] ; then
  42.                 PG_PASSWORD="$(pwgen -s1 16)"
  43.                 sed -i "s/PG_PASSWORD=noc/PG_PASSWORD=${PG_PASSWORD}/" etc/upgrade.conf
  44.         fi
  45.         su - postgres -c 'psql -c "CREATE USER '${PG_USER}' SUPERUSER ENCRYPTED PASSWORD '"'${PG_PASSWORD}'"';"' || die "Failed create user"
  46.         su - postgres -c 'psql -c "CREATE DATABASE '${PG_DB}' ENCODING '"'UTF8' OWNER ${PG_USER};"'"' || die "Failed create DB"
  47.  
  48.         einfo "Setting MongoDB authentication..."
  49.         if [ ${MONGO_PASSWORD} == "noc" ] ; then
  50.                 MONGO_PASSWORD="$(pwgen -s1 16)"
  51.                 sed -i "s/MONGO_PASSWORD=noc/MONGO_PASSWORD=${MONGO_PASSWORD}/" etc/upgrade.conf
  52.         fi
  53.         mongo --shell << __EOF__
  54. use ${MONGO_DB}
  55. db.createUser({ user: "${MONGO_USER}", pwd: "${MONGO_PASSWORD}", roles: [ "readWrite", "dbAdmin" ] })
  56. __EOF__
  57. [[ $? -eq 0 ]] || die "Failed to initialize MongoDB database and user"
  58.  
  59.         einfo ""
  60.         einfo "Running NOC's setups..."
  61.         sed -i 's/ENABLED=no/ENABLED=yes/' ./etc/upgrade.conf
  62.         for i in $(ls ./etc/*.defaults); do sed -i 's/logfiles = 0/logfiles = 9/' $i; done
  63.         for i in $(ls ./etc/*.defaults); do sed -i 's/logsize  = 0/logsize =  2000000/' $i; done
  64.         ./scripts/upgrade || die "NOC script './scripts/upgrade' failed!!!"
  65.         su - postgres -c "psql -c 'ALTER USER ${PG_USER} NOSUPERUSER;'" || die "Failed drop noc user privilege"
  66.         pass="$(pwgen -sy1 50)"
  67.         ./scripts/set-conf.py etc/noc.conf main secret_key "${pass}"
  68.         ./scripts/set-conf.py etc/noc-launcher.conf noc-web user "${NOC_USER}"
  69.         ./scripts/set-conf.py etc/noc-launcher.conf noc-scheduler user "${NOC_USER}"
  70.         ./scripts/set-conf.py etc/noc-launcher.conf noc-sae user "${NOC_USER}"
  71.         ./scripts/set-conf.py etc/noc-launcher.conf noc-classifier user "${NOC_USER}"
  72.         ./scripts/set-conf.py etc/noc-launcher.conf noc-correlator user "${NOC_USER}"
  73.         ./scripts/set-conf.py etc/noc-launcher.conf noc-notifier user "${NOC_USER}"
  74.         ./scripts/set-conf.py etc/noc-launcher.conf noc-probe user "${NOC_USER}"
  75.         ./scripts/set-conf.py etc/noc-launcher.conf noc-discovery user "${NOC_USER}"
  76.         ./scripts/set-conf.py etc/noc-launcher.conf noc-sync user "${NOC_USER}"
  77.         ./scripts/set-conf.py etc/noc-launcher.conf noc-pmwriter user "${NOC_USER}"
  78.         einfo ""
  79.         einfo "Configuring NOC's activator..."
  80.         einfo "Input name of network devise with acces to you commutators/routers (example: eth0)..."
  81.         read dev
  82.         pass="$(pwgen -s1 16)"
  83.         cd /opt/noc
  84.         ./scripts/set-conf.py etc/noc-launcher.conf noc-activator user root
  85.         ./scripts/set-conf.py etc/noc-activator.conf activator listen_traps ${dev}
  86.         ./scripts/set-conf.py etc/noc-activator.conf activator listen_syslog ${dev}
  87.         ./scripts/set-conf.py etc/noc-activator.conf activator name default
  88.         ./scripts/set-conf.py etc/noc-activator.conf activator secret "${pass}"
  89.         pg_comands='"BEGIN;UPDATE sa_activator SET auth='"'${pass}'"';COMMIT;"'
  90.         su - postgres -c "psql -d ${PG_DB} -c ${pg_comands}" || die "Failed to configure NOC's activator..."
  91.  
  92.         elog ""
  93.         ewarn "Input NOC web login password for user 'admin'"
  94.         cd /opt/noc
  95.         ./noc changepassword admin
  96.         elog ""
  97.         elog "To change password run as noc user:"
  98.         elog " $ cd /opt/noc"
  99.         elog " $ ./noc changepassword admin"
  100.         elog "Or use web interface: Main -> Setup -> Users"
  101.  
  102.         elog ""
  103.         elog "Now you can start NOC:"
  104.         elog " # /etc/init.d/noc start"
  105.         ewarn "Go in you web browser to 'https://127.0.0.1' accept certificate and enable java scripts."
  106.         elog "You may edit web server configuration file for listening other interface..."
  107.         elog ""
  108.         elog "If some go worong, spetialy in 'Running NOC's setups...' phase, try:"
  109.         elog " # /etc/init.d/noc stop"
  110.         elog " # /etc/init.d/mongodb restart"
  111.         elog " # /etc/init.d/postgresql-9.3 restart"
  112.         elog " # cd /opt/noc"
  113.         elog " # ./scripts/upgrade"
  114.         elog "If you see python trace during running './scripts/upgrade' run it again..."
  115.         elog " # ./scripts/upgrade"
  116.         elog " # /etc/init.d/noc start"
  117.  
  118.         elog ""
  119.         elog "Add one or more Managed Object (Service Activation > Managed Objects)"
  120.         elog "You will get your network database initialized and device configuration grabbed in 5-15 minutes"
  121.         elog ""
  122.         elog "Edit up /opt/noc/etc/noc-notifier.conf and set up SMTP server, address, user and password for outgoing mail"
  123.         elog "Restart NOC:"
  124.         elog " # /etc/init.d/noc restart"
  125.         elog "In web interface, go to Main > Setup > Notification Groups, create notification group and set email"
  126.         elog "In Main > Setup > System Notifications assign newly created notification group to all system events"
  127.         elog ""
  128.         elog "Other documentation: http://kb.nocproject.org/display/DOC/Home"
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement