-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update default rpm spec and service templates (#123)
Signed-off-by: Sergiy Kulanov <sergiy_kulanov@epam.com>
- Loading branch information
Showing
2 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
[Unit] | ||
Description=Your service description here | ||
# Ensures the network is up before starting this service | ||
After=network-online.target | ||
# Wants=AnotherService.service: If AnotherService is being started, this service will be started too | ||
# Requires=AnotherService.service: This service will only start if AnotherService starts successfully | ||
|
||
[Service] | ||
# Type of the service: | ||
# simple (default if ExecStart is set, service considered started immediately) | ||
# forking (useful for services that fork a child process) | ||
# oneshot (useful for scripts that perform a task and exit) | ||
# dbus (if the service acquires a name on the D-Bus) | ||
# notify (if the service sends a notification message via sd_notify(3)) | ||
# idle (delayed execution until all jobs are dispatched) | ||
Type=simple | ||
|
||
# The command to run to start the service. This setting is required. | ||
ExecStart=/path/to/your/command | ||
|
||
# The command to run to reload the service configuration without interrupting pending operations. | ||
#ExecReload=/path/to/reload/script | ||
|
||
# The command to run to stop the service. | ||
#ExecStop=/path/to/stop/script | ||
|
||
# Restart policy: | ||
# no (default if no ExecStart= is set) | ||
# on-success (only if service exited successfully) | ||
# on-failure (only on unclean exit) | ||
# on-abnormal (on timeout, signal, core dump) | ||
# on-watchdog (if watchdog timeout for the service expires) | ||
# on-abort (if service is aborted by a signal) | ||
# always (in all cases) | ||
#Restart=no | ||
|
||
# Time to sleep before restarting a service (e.g., 10s) | ||
#RestartSec=10 | ||
|
||
# The user and group to run the service as. | ||
# User=root | ||
# Group=root | ||
|
||
# The working directory for the service. | ||
#WorkingDirectory=/path/to/working/directory | ||
|
||
|
||
[Install] | ||
# Specifies whether the service should start when the system boots. | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
%global source_date_epoch_from_changelog 0 | ||
%define debug_package %{nil} | ||
|
||
%if 0%{?RELEASE_NUMBER:1} != 0 | ||
%define rel %{?RELEASE_NUMBER} | ||
%else | ||
%define rel 1 | ||
%endif | ||
|
||
%if 0%{?VERSION_NUMBER:1} != 0 | ||
%define ver %{?VERSION_NUMBER} | ||
%else | ||
%define ver 0.1.0 | ||
%endif | ||
|
||
Name: {{.Name}} | ||
Version: %{ver} | ||
Release: %{rel} | ||
Summary: {{.Name}} application | ||
ExclusiveArch: %{_arch} | ||
|
||
License: Apache-2.0 | ||
URL: {{.GitURL}} | ||
Source0: %{name}-%{version}.tar.gz | ||
Source1: %{name}.service | ||
|
||
Requires: bash | ||
Requires(post): systemd | ||
Requires(preun): systemd | ||
Requires(postun): systemd | ||
|
||
%description | ||
{{.Name}} application | ||
|
||
%prep | ||
%setup -q | ||
|
||
%install | ||
rm -rf %{buildroot} | ||
mkdir -p %{buildroot}/%{_bindir} | ||
install -m 0755 %{name} %{buildroot}/%{_bindir}/%{name} | ||
|
||
# Install the systemd service file | ||
install -D -m 0644 %{SOURCE1} %{buildroot}/etc/systemd/system/%{name}.service | ||
|
||
%post | ||
# Reload systemd daemon and enable the service | ||
systemctl daemon-reload | ||
systemctl enable %{name}.service | ||
systemctl start %{name}.service | ||
|
||
%preun | ||
# Stop and disable the service before uninstall | ||
systemctl stop %{name}.service | ||
systemctl disable %{name}.service | ||
|
||
%postun | ||
# Reload systemd daemon after uninstall | ||
systemctl daemon-reload | ||
|
||
%files | ||
%{_bindir}/%{name} | ||
%config(noreplace) /etc/systemd/system/%{name}.service |