Skip to content

Commit

Permalink
systemd user + system services management for Debian and derivatives …
Browse files Browse the repository at this point in the history
…as well
  • Loading branch information
gs-kamnas committed Mar 8, 2024
1 parent 81d8420 commit eb16e4a
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 123 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ DESTDIR :=
PREFIX := /usr/local
SYSCONFDIR := $(DESTDIR)/etc
BINDIR := $(DESTDIR)$(PREFIX)/sbin
LIBEXECDIR := $(DESTDIR)$(PREFIX)/libexec
MANDIR := $(DESTDIR)$(PREFIX)/share/man

STAMP := configure-stamp
Expand Down Expand Up @@ -153,6 +154,8 @@ install: $(NAME)
install -m 600 doc/$(NAME).conf $(SYSCONFDIR)/$(NAME).conf; \
else \
install -D -m 755 $(STRIP) $(NAME) $(BINDIR)/$(NAME); \
sed "s#%BINDIR%#$(BINDIR)#g" cntlm-user.in > cntlm-user; \
install -D -m 755 $(NAME)-user $(LIBEXECDIR)/$(NAME)-user; \
install -D -m 644 doc/$(NAME).1 $(MANDIR)/man1/$(NAME).1; \
[ -f $(SYSCONFDIR)/$(NAME).conf -o -z "$(SYSCONFDIR)" ] \
|| install -D -m 600 doc/$(NAME).conf $(SYSCONFDIR)/$(NAME).conf; \
Expand Down Expand Up @@ -238,7 +241,7 @@ uninstall:

clean:
@rm -f config/endian config/gethostname config/socklen_t config/strdup config/arc4random_buf config/strlcat config/strlcpy config/memset_s config/gss config/*.exe
@rm -f *.o cntlm cntlm.exe configure-stamp build-stamp config/config.h
@rm -f *.o cntlm cntlm.exe configure-stamp build-stamp config/config.h cntlm-user
@rm -f $(patsubst %, win/%, $(CYGWIN_REQS) cntlm.exe cntlm.ini LICENSE.txt resources.o setup.iss cntlm_manual.pdf)

distclean: clean
Expand Down
2 changes: 1 addition & 1 deletion rpm/SOURCES/cntlm-user → cntlm-user.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ if [ ! -e "${CNTLM_CONFIG_LOC}" ] ; then
exit 0
fi

exec /usr/sbin/cntlm -f -c "${CNTLM_CONFIG_LOC}" "$@"
exec %BINDIR%/cntlm -f -c "${CNTLM_CONFIG_LOC}" "$@"
2 changes: 1 addition & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cntlm (0.94beta1) unstable; urgency=low
cntlm (0.95.0beta1) unstable; urgency=low

* Ad-hoc source build, not a Debian maintained package!

Expand Down
3 changes: 1 addition & 2 deletions debian/cntlm.default
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Additional options that are passed to the Daemon.
TIMEOUT=1
RUNAS=cntlm
OPTARGS=""
87 changes: 0 additions & 87 deletions debian/cntlm.init

This file was deleted.

13 changes: 13 additions & 0 deletions debian/cntlm.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=cNTLM authentication proxy
After=network.target

[Service]
Type=simple
Environment="RUNAS=cntlm"
EnvironmentFile=-/etc/default/cntlm
ExecStart=/usr/sbin/cntlm -f -U $RUNAS -c /etc/cntlm.conf $OPTARGS
Restart=on-failure

[Install]
WantedBy=default.target
12 changes: 12 additions & 0 deletions debian/cntlm.user.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=cNTLM authentication proxy - per user instance
After=network.target

[Service]
Type=simple
EnvironmentFile=-/etc/default/cntlm
ExecStart=/usr/libexec/cntlm-user $OPTARGS
Restart=on-failure

[Install]
WantedBy=default.target
11 changes: 0 additions & 11 deletions debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,3 @@ if ! [ -d $HOME ]; then
fi

#DEBHELPER#

# Automatically added by dh_installinit
if [ -x "/etc/init.d/cntlm" ]; then
update-rc.d cntlm defaults >/dev/null
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d cntlm start || exit $?
else
/etc/init.d/cntlm start || exit $?
fi
fi
# End automatically added section
6 changes: 0 additions & 6 deletions debian/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,3 @@ if [ "$1" = "purge" ]; then
fi

#DEBHELPER#

# Automatically added by dh_installinit
if [ "$1" = "purge" ] ; then
update-rc.d cntlm remove >/dev/null || exit $?
fi
# End automatically added section
10 changes: 0 additions & 10 deletions debian/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,3 @@
set -e

#DEBHELPER#

# Automatically added by dh_installinit
if [ -x "/etc/init.d/cntlm" ]; then
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d cntlm stop || exit $?
else
/etc/init.d/cntlm stop || exit $?
fi
fi
# End automatically added section
3 changes: 2 additions & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ binary-arch: build install
dh_install
cp debian/lintian-override debian/cntlm/usr/share/lintian/overrides/cntlm
dh_installdebconf
dh_installinit -n
dh_installsystemd --no-enable
dh_installsystemduser --no-enable
dh_installman doc/cntlm.1
dh_link
dh_strip
Expand Down
4 changes: 1 addition & 3 deletions rpm/SPECS/cntlm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Source1: cntlm.tmpfiles
Source2: cntlm.sysconfig
Source3: cntlm.service
Source4: cntlm-user.service
Source5: cntlm-user

Requires: systemd
BuildRequires: systemd
Expand Down Expand Up @@ -42,13 +41,12 @@ CC=gcc ./configure
make NOSTRIP=1 %{?_smp_mflags} SYSCONFDIR=%{_sysconfdir}

%install
make BINDIR=%{buildroot}%{_sbindir} MANDIR=%{buildroot}%{_mandir} SYSCONFDIR=%{buildroot}%{_sysconfdir} NOSTRIP=1 install
make BINDIR=%{buildroot}%{_sbindir} MANDIR=%{buildroot}%{_mandir} SYSCONFDIR=%{buildroot}%{_sysconfdir} LIBEXECDIR=%{buildroot}%{_libexecdir} NOSTRIP=1 install

install -D -m 0644 %{SOURCE1} %{buildroot}%{_tmpfilesdir}/%{name}.conf
install -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/cntlmd
install -D -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}.service
install -D -m 0644 %{SOURCE4} %{buildroot}%{_userunitdir}/%{name}.service
install -D -m 0755 %{SOURCE5} %{buildroot}%{_libexecdir}/%{name}-user

install -D -d -m 0755 %{buildroot}/run/%{name}/

Expand Down

0 comments on commit eb16e4a

Please sign in to comment.