From 206d6d50c39dbc97c14f7d97ad949d2c831e7301 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Sat, 26 May 2018 09:42:38 +0200 Subject: [PATCH] first fixes in the systemd/ area --- setup.py | 10 ---------- sfa.spec | 1 - systemd/sfa-aggregate.service | 6 ++---- systemd/sfa-db-init.sh | 17 ++++++++++------- systemd/sfa-db.service | 5 ++--- systemd/sfa-registry.service | 5 ++--- 6 files changed, 16 insertions(+), 28 deletions(-) diff --git a/setup.py b/setup.py index 770dace7..b168ec7c 100755 --- a/setup.py +++ b/setup.py @@ -88,14 +88,6 @@ data_files = [ ] -initscripts = [ 'sfa' ] -if not os.path.isfile('/etc/redhat-release'): - initscripts.append('functions.sfa') -data_files.append( - ('/etc/init.d/', - [ "init.d/%s"%x for x in initscripts ])) - - services = ['sfa-db', 'sfa-aggregate', 'sfa-registry'] data_files.append( ('/usr/lib/systemd/system', @@ -122,8 +114,6 @@ if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']: remove_dirs = ['/etc/sfa/', '/etc/sfatables'] + site_packages_path remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in scripts ] remove_files = (remove_bins - + ["/etc/init.d/{}}".format(x) - for x in initscripts ] + ["/usr/lib/systemd/system/{}".format(x) for x in services]) diff --git a/sfa.spec b/sfa.spec index 71870ed0..b778da79 100644 --- a/sfa.spec +++ b/sfa.spec @@ -150,7 +150,6 @@ make VERSIONTAG="%{version}-%{taglevel}" SCMURL="%{SCMURL}" install DESTDIR="$RP rm -rf $RPM_BUILD_ROOT %files -/etc/init.d/sfa /usr/lib/systemd/system/*.service %{_bindir}/sfa-start.py* %{_bindir}/sfaadmin.py* diff --git a/systemd/sfa-aggregate.service b/systemd/sfa-aggregate.service index 1174bb76..497c8606 100644 --- a/systemd/sfa-aggregate.service +++ b/systemd/sfa-aggregate.service @@ -1,12 +1,10 @@ -# this is meant to be installed under /etc/systemd/system [Unit] Description=SFA Aggregate Manager (AM) +Requires=sfa-db +After=sfa-db [Service] -#Environment=PYTHONPATH=/root/nbhosting/nbhosting ExecStart=/bin/bash -c "/usr/bin/sfa-start.py -a" -Requires=sfa-db -After=sfa-db [Install] WantedBy=multi-user.target diff --git a/systemd/sfa-db-init.sh b/systemd/sfa-db-init.sh index 1a030fd9..f28d7bd4 100755 --- a/systemd/sfa-db-init.sh +++ b/systemd/sfa-db-init.sh @@ -18,12 +18,6 @@ sfa_local_config=/etc/sfa/configs/site_config sfa_local_config_xml=/etc/sfa/configs/site_config.xml sfa_local_config_sh=/etc/sfa/sfa_config.sh -# source shell config if present; might not be the very first time -[ -f $sfa_local_config_sh ] && source $sfa_local_config_sh - -# Export so that we do not have to specify -p to psql invocations -export PGPORT=$SFA_DB_PORT - # Regenerate configuration files - almost verbatim from plc.init function reconfigure () { @@ -108,7 +102,7 @@ function start () { echo "local all all trust" >> $pg_hba_conf # Disable access to our DB from all hosts - sed -i -e "/^host ${SFA_DB_NAME}/d' $pg_hba_conf + sed -i -e "/^host ${SFA_DB_NAME}/d" $pg_hba_conf # grant access { echo "host $SFA_DB_NAME $SFA_DB_USER 127.0.0.1/32 password" @@ -145,4 +139,13 @@ function start () { } +# source shell config if present +# but it might not be present the very first time +[ ! -f $sfa_local_config_sh ] && reconfigure + +source $sfa_local_config_sh + +# Export so that we do not have to specify -p to psql invocations +export PGPORT=$SFA_DB_PORT + start diff --git a/systemd/sfa-db.service b/systemd/sfa-db.service index f2d7d2c1..7ad798e4 100644 --- a/systemd/sfa-db.service +++ b/systemd/sfa-db.service @@ -1,6 +1,7 @@ [Unit] Description=SFA Database service -#After=network.target +Requires=postgresql +After=postgresql [Service] Type=oneshot @@ -10,8 +11,6 @@ RemainAfterExit=true # that does not seem useful in our case ExecStop=/bin/true StandardOutput=journal -Requires=postgresql -After=postgresql [Install] WantedBy=multi-user.target diff --git a/systemd/sfa-registry.service b/systemd/sfa-registry.service index fec12f58..e87af52c 100644 --- a/systemd/sfa-registry.service +++ b/systemd/sfa-registry.service @@ -1,12 +1,11 @@ # this is meant to be installed under /etc/systemd/system [Unit] Description=SFA Registry Service +Requires=sfa-db +After=sfa-db [Service] -#Environment=PYTHONPATH=/root/nbhosting/nbhosting ExecStart=/bin/bash -c "/usr/bin/sfa-start.py -r" -Requires=sfa-db -After=sfa-db [Install] WantedBy=multi-user.target -- 2.43.0