build: fully replace apache with nodejs back-end

main
Tsu-ba-me 2 years ago
parent aacbf3003a
commit fc73f4ec15
  1. 43
      anvil.spec.in
  2. 5
      units/striker-ui-api.service

@ -5,6 +5,7 @@
%define debug_package %{nil} %define debug_package %{nil}
%define anviluser admin %define anviluser admin
%define anvilgroup admin %define anvilgroup admin
%define suiapi striker-ui-api
Name: anvil Name: anvil
Version: @version@ Version: @version@
@ -134,7 +135,6 @@ Requires: firefox
Requires: gcc Requires: gcc
Requires: gdm Requires: gdm
Requires: gnome-terminal Requires: gnome-terminal
Requires: httpd
Requires: nmap Requires: nmap
Requires: nodejs Requires: nodejs
Requires: openssh-askpass Requires: openssh-askpass
@ -243,14 +243,32 @@ setenforce 0
systemctl enable --now chronyd.service systemctl enable --now chronyd.service
systemctl enable --now anvil-daemon.service systemctl enable --now anvil-daemon.service
systemctl enable --now scancore.service systemctl enable --now scancore.service
systemctl enable --now striker-ui-api.service
systemctl restart striker-ui-api.service %pre striker
getent passwd %{suiapi} >/dev/null \
|| useradd \
--comment "Striker UI API" \
--home-dir %{_datadir}/%{suiapi} \
--shell %{_sbindir}/nologin \
--user-group \
%{suiapi}
if [ $1 -gt 1 ]; then # >1=Upgrade
# Transfer files owned by apache to Striker UI API user.
chown -R --from apache %{suiapi}: /mnt
chown -R --from apache %{suiapi}: %{_localstatedir}/www
fi
%post striker %post striker
### NOTE: PostgreSQL is initialized and enabled by striker-prep-database later. ### NOTE: PostgreSQL is initialized and enabled by striker-prep-database later.
echo "Enabling and starting apache."
systemctl enable httpd.service # Always reload to handle service file changes.
systemctl start httpd.service systemctl daemon-reload
systemctl enable %{suiapi}.service
# Striker UI API needs explicit restart for changes to take effect.
systemctl restart %{suiapi}.service
restorecon -rv /%{_localstatedir}/www restorecon -rv /%{_localstatedir}/www
if ! $(ls -l /etc/systemd/system/default.target | grep -q graphical); if ! $(ls -l /etc/systemd/system/default.target | grep -q graphical);
then then
@ -329,6 +347,11 @@ touch /etc/anvil/type.dr
# sed -i.anvil 's/SELINUX=permissive/SELINUX=enforcing/' /etc/selinux/config # sed -i.anvil 's/SELINUX=permissive/SELINUX=enforcing/' /etc/selinux/config
# setenforce 1 # setenforce 1
%preun striker
if [ $1 == 0 ]; then # 0=Uninstall, 1=First install, >1=Upgrade (version count)
systemctl disable --now %{suiapi}.service
fi
%postun striker %postun striker
### TODO: Stopping postgres breaks the Anvil! during OS updates. Need to find a ### TODO: Stopping postgres breaks the Anvil! during OS updates. Need to find a
### way to run this only during uninstalls, and not during updates. ### way to run this only during uninstalls, and not during updates.
@ -340,11 +363,13 @@ touch /etc/anvil/type.dr
# firewall-cmd --zone=public --remove-service=postgresql # firewall-cmd --zone=public --remove-service=postgresql
# firewall-cmd --zone=public --remove-service=postgresql --permanent # firewall-cmd --zone=public --remove-service=postgresql --permanent
# echo "Disabling and stopping postgresql-9.6." # echo "Disabling and stopping postgresql-9.6."
# systemctl disable httpd.service
# systemctl stop httpd.service
# systemctl disable postgresql.service # systemctl disable postgresql.service
# systemctl stop postgresql.service # systemctl stop postgresql.service
if [ $1 == 0 ]; then # 0=Uninstall
systemctl daemon-reload
fi
# Remove the system type file. # Remove the system type file.
if [ -e '/etc/anvil/type.striker' ] if [ -e '/etc/anvil/type.striker' ]
then then
@ -376,7 +401,7 @@ fi
%{_sbindir}/* %{_sbindir}/*
%{_sysconfdir}/anvil/anvil.version %{_sysconfdir}/anvil/anvil.version
%{_datadir}/perl5/* %{_datadir}/perl5/*
%{_datadir}/striker-ui-api/* %{_datadir}/%{suiapi}/*
%{_mandir}/* %{_mandir}/*
%files striker %files striker

@ -4,9 +4,8 @@ Wants=network.target
[Service] [Service]
Type=simple Type=simple
# Run as apache to allow the API to access apache-owned locations; i.e., /mnt/shared. User=striker-ui-api
User=apache Group=striker-ui-api
Group=apache
ExecStart=/usr/bin/node /usr/share/striker-ui-api/index.js ExecStart=/usr/bin/node /usr/share/striker-ui-api/index.js
ExecStop=/bin/kill -WINCH ${MAINPID} ExecStop=/bin/kill -WINCH ${MAINPID}
Restart=always Restart=always

Loading…
Cancel
Save