Commit 790ca775 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

timer and service

parent 4d4664fa
# padmrun
## Description
A tool used for running padm ws simulations. Used for monitoring and testing
# padmwsverify
A tool used for running padm web service simulations. Used for monitoring, testing and verification
## Installation
......
[Unit]
Description=SMHI-padmwsverify
[Service]
User=APPUSER
Type=oneshot
ExecStart=/local_disk/SMHI-padmwsverify/main.sh
\ No newline at end of file
# Definition av filagare
%define AppOwner seatra
%define AppGroup seatrag
%define AppOwnerTst seatra.t
%define AppGroupTst seatragt
%define AppOwnerUtv seatra.u
%define AppGroupUtv seatragu
Summary: a Padmws runner used for monitoring, test and verification
Name: SMHI-padmwsverify
Version: %{version}
Release: %{release}
Packager: Tomas Pettersson <tomas.pettersson@smhi.se>
License: SMHI
Group: Applications/Webb/System
URL: http://www.smhi.se
Source: padmwsverify.tar
Source1: extras.zip
%description
%prep
%setup -c
%setup -T -D -a 1
%build
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system
mv $RPM_SOURCE_DIR/%{name}.service $RPM_BUILD_ROOT/usr/lib/systemd/system/%{name}.service
mv $RPM_SOURCE_DIR/%{name}.timer $RPM_BUILD_ROOT/usr/lib/systemd/system/%{name}.timer
mkdir -p $RPM_BUILD_ROOT/local_disk/%{name}
cp -a . $RPM_BUILD_ROOT/local_disk/%{name}
%pre
## Stop old version if this rpm is installed as an upgrade
if [ $1 -gt 1 ]; then
echo "Stopping existing %{name}"
/usr/bin/systemctl stop %{name}.timer
# Sleep just to be on the safe side
sleep 10
# Remove all but the logs directory
find /local_disk/%{name} -mindepth 1 -maxdepth 1 -depth -not -name logs -print0 | xargs -0 rm -rf
# Remove all log files older than 10 days
find /local_disk/%{name}/logs -type f -mtime +10 -print0 | xargs -0 rm -rf
fi
%post
source /etc/profile.d/smhi.sh
case "$SMHI_MODE" in
prod)
OWNER=%{AppOwner}
GROUP=%{AppGroup}
;;
test)
OWNER=%{AppOwnerTst}
GROUP=%{AppGroupTst}
;;
utv)
OWNER=%{AppOwnerUtv}
GROUP=%{AppGroupUtv}
;;
esac
# Sed unit file
/bin/sed -i "s/APPUSER/${OWNER}/" /usr/lib/systemd/system/%{name}.service
/bin/chown -R ${OWNER}:${GROUP} /local_disk/%{name}
if [ "$1" = "1" ] ; then # first install
#make app start and stop automatically on boot
/usr/bin/systemctl enable %{name}.timer
#start app on install
/usr/bin/systemctl start %{name}.timer
fi
if [ "$1" = "2" ] ; then # upgrade
#restart app on upgrade
/usr/bin/systemctl daemon-reload
/usr/bin/systemctl restart %{name}.timer
fi
%preun
## Stop old version if this rpm is being erased
if [ $1 -eq 0 ]; then
echo "Stopping existing %{name}"
/usr/bin/systemctl stop %{name}.timer
/usr/bin/systemctl disable %{name}.timer
/usr/bin/systemctl daemon-reload
sleep 10
fi
%postun
if [ $1 -eq 0 ] ; then # last uninstall
# Remove any old remaining stuff (tmp files, log files and whatnot)
rm -rf /local_disk/%{name}
fi
%clean
echo clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root, -)
/local_disk/%{name}
%attr(755,root,root) /usr/lib/systemd/system
%changelog
\ No newline at end of file
[Unit]
Description=Runs SMHI-padmwsverify once an hour, 20 min past.
[Timer]
# Time to wait after booting before we run first time
OnBootSec=10min
# Time between running each consecutive time
OnCalendar=*:20
Unit=SMHI-padmwsverify
[Install]
WantedBy=multi-user.target
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment