Compare commits

...

2 Commits

Author SHA1 Message Date
Max
e14ee36650 .deb/.rpm: add osmocom user during package install
Create osmocom user & group during package installation.
Fix the configuration dir/files permission to match.

Related: OS#4107
Change-Id: Ibb83c231231b39dc6732c0f375aeb3b21f3938ef
2022-11-13 21:50:18 +03:00
Max
cd35f724f0 Add realtime scheduling and set priority in service file
This sets lowest realtime priority which still takes precedence over any non-realtime service.

Related: OS#5687
Change-Id: Ib1705a164b04b876f129a17c4e8353b9ddcc538e
2022-11-12 20:43:25 +03:00
4 changed files with 55 additions and 1 deletions

View File

@@ -37,6 +37,7 @@ BuildRequires: pkgconfig(libosmovty) >= 1.7.0
BuildRequires: pkgconfig(libosmocoding) >= 1.7.0 BuildRequires: pkgconfig(libosmocoding) >= 1.7.0
BuildRequires: pkgconfig(libosmoabis) >= 1.3.0 BuildRequires: pkgconfig(libosmoabis) >= 1.3.0
BuildRequires: pkgconfig(libosmotrau) >= 1.3.0 BuildRequires: pkgconfig(libosmotrau) >= 1.3.0
Requires(pre): shadow
%{?systemd_requires} %{?systemd_requires}
%description %description
@@ -101,10 +102,17 @@ make %{?_smp_mflags} check || (find . -name testsuite.log -exec cat {} +)
%service_del_postun osmo-mgw.service %service_del_postun osmo-mgw.service
%pre %pre
getent group osmocom >/dev/null || groupadd --system osmocom
getent passwd osmocom >/dev/null || useradd --system --gid osmocom --home-dir /var/lib/osmocom \
--shell /sbin/nologin --comment "Open Source Mobile Communications" osmocom
%service_add_pre osmo-mgw.service %service_add_pre osmo-mgw.service
%post %post
%service_add_post osmo-mgw.service %service_add_post osmo-mgw.service
chown osmocom:osmocom /etc/osmocom/osmo-mgw.cfg
chmod 0660 /etc/osmocom/osmo-mgw.cfg
chown root:osmocom /etc/osmocom
chmod 2775 /etc/osmocom
%endif %endif
%files %files

View File

@@ -5,9 +5,16 @@ Description=Osmocom Media Gateway (MGW)
Type=simple Type=simple
StateDirectory=osmocom StateDirectory=osmocom
WorkingDirectory=%S/osmocom WorkingDirectory=%S/osmocom
User=osmocom
Group=osmocom
Restart=always Restart=always
ExecStart=/usr/bin/osmo-mgw -s -c /etc/osmocom/osmo-mgw.cfg ExecStart=/usr/bin/osmo-mgw -s -c /etc/osmocom/osmo-mgw.cfg
RestartSec=2 RestartSec=2
# CPU scheduling policy:
CPUSchedulingPolicy=rr
# For real-time scheduling policies an integer between 1 (lowest priority) and 99 (highest priority):
CPUSchedulingPriority=1
# See sched(7) for further details on real-time policies and priorities
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

2
debian/control vendored
View File

@@ -18,7 +18,7 @@ Homepage: https://osmocom.org/projects/osmo-mgw
Package: osmo-mgw Package: osmo-mgw
Architecture: any Architecture: any
Multi-Arch: foreign Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends} Depends: ${misc:Depends}, ${shlibs:Depends}, adduser
Description: OsmoMGW: Osmocom's Media Gateway for 2G and 3G circuit-switched mobile networks Description: OsmoMGW: Osmocom's Media Gateway for 2G and 3G circuit-switched mobile networks
Package: libosmo-mgcp-client9 Package: libosmo-mgcp-client9

39
debian/postinst vendored Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/sh -e
# Create 'osmocom' user and group (if it doesn't exist yet) and adjust permissions
# of directories which are not automatically adjusted by systemd from previous (root-owned)
# install.
# N. B: the user is intentionally NOT removed during package uninstall:
# see https://wiki.debian.org/AccountHandlingInMaintainerScripts for reasoning.
chperms() {
# chperms <user> <group> <perms> <file>
if ! OVERRIDE=`dpkg-statoverride --list $4 2>&1`; then
if [ -e $4 ]; then
chown $1:$2 $4
chmod $3 $4
fi
fi
}
case "$1" in
configure)
if ! getent passwd osmocom > /dev/null; then
adduser --quiet \
--system \
--group \
--no-create-home \
--disabled-password \
--home /var/lib/osmocom \
--gecos "Open Source Mobile Communications" \
osmocom
fi
# Set permissions according to https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
chperms osmocom osmocom 0660 /etc/osmocom/osmo-mgw.cfg
chperms root osmocom 2775 /etc/osmocom
;;
esac
# dh_installdeb(1) will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#