Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pkg_config() {
- ebegin "Checking PostreSQL server"
- if [ -z "$(/etc/init.d/postgresql-* -C status |grep started)" ] ; then
- eend 1
- ewarn "Configure PostgreSQL server if you run it first time, like this:"
- ewarn "Check /etc/conf.d/postgresql-9.4"
- ewarn " # emerge --config dev-db/postgresql"
- ewarn "Then run PostgreSQL server:"
- ewarn " # /etc/init.d/postgresql-9.4 start"
- die "Run PostgreSQL server!"
- else
- eend 0
- fi
- ebegin "Checking MongoDB server"
- if [ -z "$(/etc/init.d/mongodb -C status |grep started)" ] ; then
- eend 1
- ewarn "Check /etc/mongodb.conf"
- ewarn "Run MongoDB server:"
- ewarn " # /etc/init.d/mongodb start"
- die "Run MongoDB server!"
- else
- eend 0
- fi
- cd /opt/noc
- [ -f ./etc/upgrade.defaults ] && . ./etc/upgrade.defaults
- . ./etc/upgrade.conf || die "Can't find configfile: /opt/noc/etc/upgrade.conf Create it from /opt/noc/etc/upgrade.defaults"
- groupadd -f "${NOC_GROUP}"
- useradd -g "${NOC_GROUP}" -s /bin/bash -M -d /opt/noc "${NOC_USER}"
- touch .bash_history
- chown -R "${NOC_USER}":"${NOC_GROUP}" .bash_history
- chmod 600 .bash_history
- if use extensions; then
- chown -R "${NOC_USER}":"${NOC_GROUP}" static/staticvlan
- fi
- einfo "Create PostgreSQL 'noc' user and database..."
- if [ "${PG_PASSWORD}" == "noc" ] ; then
- PG_PASSWORD="$(pwgen -s1 16)"
- sed -i "s/PG_PASSWORD=noc/PG_PASSWORD=${PG_PASSWORD}/" etc/upgrade.conf
- fi
- su - postgres -c 'psql -c "CREATE USER '${PG_USER}' SUPERUSER ENCRYPTED PASSWORD '"'${PG_PASSWORD}'"';"' || die "Failed create user"
- su - postgres -c 'psql -c "CREATE DATABASE '${PG_DB}' ENCODING '"'UTF8' OWNER ${PG_USER};"'"' || die "Failed create DB"
- einfo "Setting MongoDB authentication..."
- if [ ${MONGO_PASSWORD} == "noc" ] ; then
- MONGO_PASSWORD="$(pwgen -s1 16)"
- sed -i "s/MONGO_PASSWORD=noc/MONGO_PASSWORD=${MONGO_PASSWORD}/" etc/upgrade.conf
- fi
- mongo --shell << __EOF__
- use ${MONGO_DB}
- db.createUser({ user: "${MONGO_USER}", pwd: "${MONGO_PASSWORD}", roles: [ "readWrite", "dbAdmin" ] })
- __EOF__
- [[ $? -eq 0 ]] || die "Failed to initialize MongoDB database and user"
- einfo ""
- einfo "Running NOC's setups..."
- sed -i 's/ENABLED=no/ENABLED=yes/' ./etc/upgrade.conf
- for i in $(ls ./etc/*.defaults); do sed -i 's/logfiles = 0/logfiles = 9/' $i; done
- for i in $(ls ./etc/*.defaults); do sed -i 's/logsize = 0/logsize = 2000000/' $i; done
- ./scripts/upgrade || die "NOC script './scripts/upgrade' failed!!!"
- su - postgres -c "psql -c 'ALTER USER ${PG_USER} NOSUPERUSER;'" || die "Failed drop noc user privilege"
- pass="$(pwgen -sy1 50)"
- ./scripts/set-conf.py etc/noc.conf main secret_key "${pass}"
- ./scripts/set-conf.py etc/noc-launcher.conf noc-web user "${NOC_USER}"
- ./scripts/set-conf.py etc/noc-launcher.conf noc-scheduler user "${NOC_USER}"
- ./scripts/set-conf.py etc/noc-launcher.conf noc-sae user "${NOC_USER}"
- ./scripts/set-conf.py etc/noc-launcher.conf noc-classifier user "${NOC_USER}"
- ./scripts/set-conf.py etc/noc-launcher.conf noc-correlator user "${NOC_USER}"
- ./scripts/set-conf.py etc/noc-launcher.conf noc-notifier user "${NOC_USER}"
- ./scripts/set-conf.py etc/noc-launcher.conf noc-probe user "${NOC_USER}"
- ./scripts/set-conf.py etc/noc-launcher.conf noc-discovery user "${NOC_USER}"
- ./scripts/set-conf.py etc/noc-launcher.conf noc-sync user "${NOC_USER}"
- ./scripts/set-conf.py etc/noc-launcher.conf noc-pmwriter user "${NOC_USER}"
- einfo ""
- einfo "Configuring NOC's activator..."
- einfo "Input name of network devise with acces to you commutators/routers (example: eth0)..."
- read dev
- pass="$(pwgen -s1 16)"
- cd /opt/noc
- ./scripts/set-conf.py etc/noc-launcher.conf noc-activator user root
- ./scripts/set-conf.py etc/noc-activator.conf activator listen_traps ${dev}
- ./scripts/set-conf.py etc/noc-activator.conf activator listen_syslog ${dev}
- ./scripts/set-conf.py etc/noc-activator.conf activator name default
- ./scripts/set-conf.py etc/noc-activator.conf activator secret "${pass}"
- pg_comands='"BEGIN;UPDATE sa_activator SET auth='"'${pass}'"';COMMIT;"'
- su - postgres -c "psql -d ${PG_DB} -c ${pg_comands}" || die "Failed to configure NOC's activator..."
- elog ""
- ewarn "Input NOC web login password for user 'admin'"
- cd /opt/noc
- ./noc changepassword admin
- elog ""
- elog "To change password run as noc user:"
- elog " $ cd /opt/noc"
- elog " $ ./noc changepassword admin"
- elog "Or use web interface: Main -> Setup -> Users"
- elog ""
- elog "Now you can start NOC:"
- elog " # /etc/init.d/noc start"
- ewarn "Go in you web browser to 'https://127.0.0.1' accept certificate and enable java scripts."
- elog "You may edit web server configuration file for listening other interface..."
- elog ""
- elog "If some go worong, spetialy in 'Running NOC's setups...' phase, try:"
- elog " # /etc/init.d/noc stop"
- elog " # /etc/init.d/mongodb restart"
- elog " # /etc/init.d/postgresql-9.3 restart"
- elog " # cd /opt/noc"
- elog " # ./scripts/upgrade"
- elog "If you see python trace during running './scripts/upgrade' run it again..."
- elog " # ./scripts/upgrade"
- elog " # /etc/init.d/noc start"
- elog ""
- elog "Add one or more Managed Object (Service Activation > Managed Objects)"
- elog "You will get your network database initialized and device configuration grabbed in 5-15 minutes"
- elog ""
- elog "Edit up /opt/noc/etc/noc-notifier.conf and set up SMTP server, address, user and password for outgoing mail"
- elog "Restart NOC:"
- elog " # /etc/init.d/noc restart"
- elog "In web interface, go to Main > Setup > Notification Groups, create notification group and set email"
- elog "In Main > Setup > System Notifications assign newly created notification group to all system events"
- elog ""
- elog "Other documentation: http://kb.nocproject.org/display/DOC/Home"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement