@@ -4,8 +4,9 @@ if [ ! -e /etc/httpd/conf.d/patchman.conf ] ; then
44 cp /etc/patchman/apache.conf.example /etc/httpd/conf.d/patchman.conf
55fi
66
7- if ! grep /usr/lib/python3.9/site-packages /etc/httpd/conf.d/patchman.conf > /dev/null 2>&1 ; then
8- sed -i -e " s/^\(Define patchman_pythonpath\).*/\1 \/usr\/lib\/python3.9\/site-packages/" \
7+ PYTHON_SITEPACKAGES=$( python3 -c " import site; print(site.getsitepackages()[0])" )
8+ if ! grep " ${PYTHON_SITEPACKAGES} " /etc/httpd/conf.d/patchman.conf > /dev/null 2>&1 ; then
9+ sed -i -e " s|^\(Define patchman_pythonpath\).*|\1 ${PYTHON_SITEPACKAGES} |" \
910 /etc/httpd/conf.d/patchman.conf
1011fi
1112
@@ -24,15 +25,38 @@ patchman-manage makemigrations
2425patchman-manage migrate --run-syncdb --fake-initial
2526sqlite3 /var/lib/patchman/db/patchman.db ' PRAGMA journal_mode=WAL;'
2627
27- chown -R apache:apache /var/lib/patchman
2828adduser --system --group patchman-celery
2929usermod -a -G apache patchman-celery
30- chmod g+w /var/lib/patchman /var/lib/patchman/db /var/lib/patchman/db/patchman.db
31- chcon --type httpd_sys_rw_content_t /var/lib/patchman/db/patchman.db
32- semanage port -a -t http_port_t -p tcp 5672
30+ chown root:patchman-celery /etc/patchman/celery.conf
31+ chmod 640 /etc/patchman/celery.conf
32+
33+ chown -R apache:apache /var/lib/patchman
34+ semanage fcontext -a -t httpd_sys_rw_content_t " /var/lib/patchman/db(/.*)?"
35+ restorecon -Rv /var/lib/patchman/db
3336setsebool -P httpd_can_network_memcache 1
3437setsebool -P httpd_can_network_connect 1
3538
39+ WORKER_COUNT=1
40+ if [ -f /etc/patchman/celery.conf ]; then
41+ . /etc/patchman/celery.conf
42+ WORKER_COUNT=${CELERY_WORKER_COUNT:- 1}
43+ fi
44+
45+ for i in $( seq 1 " ${WORKER_COUNT} " ) ; do
46+ systemctl enable --now " patchman-celery-worker@$i .service"
47+ done
48+
49+ active_instances=$( systemctl list-units --type=service --state=active " patchman-celery-worker@*" --no-legend | awk ' {print $1}' )
50+ for service in $active_instances ; do
51+ inst_num=$( echo " $service " | cut -d' @' -f2 | cut -d' .' -f1)
52+ if [ " $inst_num " -gt " ${WORKER_COUNT} " ]; then
53+ systemctl stop " $service "
54+ systemctl disable " $service "
55+ fi
56+ done
57+
58+ systemctl enable --now patchman-celery-beat.service
59+
3660echo
3761echo " Remember to run 'patchman-manage createsuperuser' to create a user."
3862echo
0 commit comments