From 8b0ce30dfc98d9fe785d9dcc95db93064ca5d054 Mon Sep 17 00:00:00 2001 From: atnaguzin Date: Thu, 3 Nov 2016 19:08:21 +0300 Subject: [PATCH] systemd unit, debian patch fix, makefile last-dist added, package log&pid folder edited --- Makefile | 6 +++++- contrib/debian/README | 2 ++ contrib/debian/i2pd.service | 25 +++++++++++++++++++++++++ contrib/debian/i2pd.tmpfile | 2 ++ debian/.gitignore | 9 +++++++++ debian/i2pd.default | 3 +++ debian/i2pd.init | 8 +++++--- debian/i2pd.openrc | 7 ++----- debian/i2pd.upstart | 2 +- debian/logrotate | 2 +- debian/patches/01-tune-build-opts.patch | 11 +++++------ debian/postinst | 4 +++- debian/postrm | 4 +++- debian/rules | 3 +++ 14 files changed, 69 insertions(+), 19 deletions(-) create mode 100644 contrib/debian/README create mode 100644 contrib/debian/i2pd.service create mode 100644 contrib/debian/i2pd.tmpfile create mode 100644 debian/.gitignore diff --git a/Makefile b/Makefile index f6d117fa..7dcecb26 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,6 @@ USE_STATIC := no USE_MESHNET := no USE_UPNP := no - ifeq ($(WEBSOCKETS),1) NEEDED_CXXFLAGS += -DWITH_EVENTS DAEMON_SRC += Websocket.cpp @@ -95,10 +94,15 @@ strip: $(I2PD) $(SHLIB_CLIENT) $(SHLIB) strip $^ LATEST_TAG=$(shell git describe --tags --abbrev=0 openssl) +BRANCH=$(shell git branch --no-color | cut -c 3-) dist: git archive --format=tar.gz -9 --worktree-attributes \ --prefix=i2pd_$(LATEST_TAG)/ $(LATEST_TAG) -o i2pd_$(LATEST_TAG).tar.gz +last-dist: + git archive --format=tar.gz -9 --worktree-attributes \ + --prefix=i2pd_$(LATEST_TAG)/ $(BRANCH) -o ../i2pd_$(LATEST_TAG).orig.tar.gz + doxygen: doxygen -s docs/Doxyfile diff --git a/contrib/debian/README b/contrib/debian/README new file mode 100644 index 00000000..077d7b96 --- /dev/null +++ b/contrib/debian/README @@ -0,0 +1,2 @@ +This forder contain systemd unit files. +To use systemd daemon control, place files from this directory to debian folder. diff --git a/contrib/debian/i2pd.service b/contrib/debian/i2pd.service new file mode 100644 index 00000000..a83b1396 --- /dev/null +++ b/contrib/debian/i2pd.service @@ -0,0 +1,25 @@ +[Unit] +Description=I2P Router written in C++ +After=network.target + +[Service] +User=i2pd +Group=i2pd +Type=forking +ExecStart=/usr/sbin/i2pd --conf=/etc/i2pd/i2pd.conf --pidfile=/var/run/i2pd/i2pd.pid --logfile=/var/log/i2pd/i2pd.log --daemon --service +ExecReload=/bin/kill -HUP $MAINPID +PIDFile=/var/run/i2pd/i2pd.pid +### Uncomment, if auto restart needed +#Restart=on-failure + +### Use SIGINT for gracefull stop daemon. +# i2pd stops accepting new tunnels and waits ~10 min while old ones do not die. +KillSignal=SIGINT +TimeoutStopSec=10m + +# If you have problems with hunging i2pd, you can try enable this +#LimitNOFILE=4096 +PrivateDevices=yes + +[Install] +WantedBy=multi-user.target diff --git a/contrib/debian/i2pd.tmpfile b/contrib/debian/i2pd.tmpfile new file mode 100644 index 00000000..6cd19112 --- /dev/null +++ b/contrib/debian/i2pd.tmpfile @@ -0,0 +1,2 @@ +d /var/run/i2pd 0755 i2pd i2pd - - +d /var/log/i2pd 0755 i2pd i2pd - - diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 00000000..6bc6bcf2 --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,9 @@ +files +i2pd-dbg.substvars +i2pd-dbg/ +i2pd.postinst.debhelper +i2pd.postrm.debhelper +i2pd.prerm.debhelper +i2pd.substvars +i2pd/ + diff --git a/debian/i2pd.default b/debian/i2pd.default index 1e5d5c2e..c45eff9d 100644 --- a/debian/i2pd.default +++ b/debian/i2pd.default @@ -6,3 +6,6 @@ I2PD_ENABLED="yes" # Additional options that are passed to the Daemon. # see possible switches in /usr/share/doc/i2pd/configuration.md.gz DAEMON_OPTS="" + +# If you have problems with hunging i2pd, you can try enable this +#ulimit -n 4096 diff --git a/debian/i2pd.init b/debian/i2pd.init index 32c181bb..ca403598 100644 --- a/debian/i2pd.init +++ b/debian/i2pd.init @@ -15,10 +15,10 @@ DESC=i2pd # Introduce a short description here NAME=i2pd # Introduce the short server's name here DAEMON=/usr/sbin/$NAME # Introduce the server's location here DAEMON_OPTS="" # Arguments to run the daemon with -PIDFILE=/var/run/$NAME.pid +PIDFILE=/var/run/$NAME/$NAME.pid I2PCONF=/etc/$NAME/i2pd.conf TUNCONF=/etc/$NAME/tunnels.conf -LOGFILE=/var/log/$NAME.log +LOGFILE=/var/log/$NAME/$NAME.log USER="i2pd" # Exit if the package is not installed @@ -41,9 +41,11 @@ do_start() return 2 fi + test -e /var/run/i2pd || install -m 755 -o i2pd -g i2pd -d /var/run/i2pd touch "$PIDFILE" chown -f $USER:adm "$PIDFILE" + test -e /var/log/i2pd || install -m 755 -o i2pd -g i2pd -d /var/log/i2pd touch "$LOGFILE" chown -f $USER:adm "$LOGFILE" @@ -99,7 +101,7 @@ case "$1" in status) status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? ;; - reload) + reload|force-reload) log_daemon_msg "Reloading $DESC" "$NAME" do_reload log_end_msg $? diff --git a/debian/i2pd.openrc b/debian/i2pd.openrc index 6253cfa6..2ad10bc5 100644 --- a/debian/i2pd.openrc +++ b/debian/i2pd.openrc @@ -1,7 +1,7 @@ #!/sbin/openrc-run -pidfile="/var/run/i2pd.pid" -logfile="/var/log/i2pd.log" +pidfile="/var/run/i2pd/i2pd.pid" +logfile="/var/log/i2pd/i2pd.log" mainconf="/etc/i2pd/i2pd.conf" tunconf="/etc/i2pd/tunnels.conf" @@ -32,9 +32,6 @@ start_pre() { checkpath -f -o i2pd:adm $logfile checkpath -f -o i2pd:adm $pidfile - if [ -n "$I2PD_PORT" -a "$I2PD_PORT" -gt 0 ]; then - command_args="$command_args --port=$I2PD_PORT" - fi if [ -n "$DAEMON_OPTS" ]; then command_args="$command_args $DAEMON_OPTS" fi diff --git a/debian/i2pd.upstart b/debian/i2pd.upstart index fd2b24f0..c45b5fe7 100644 --- a/debian/i2pd.upstart +++ b/debian/i2pd.upstart @@ -4,6 +4,6 @@ start on runlevel [2345] stop on runlevel [016] or unmounting-filesystem # these can be overridden in /etc/init/i2pd.override -env LOGFILE="/var/log/i2pd.log" +env LOGFILE="/var/log/i2pd/i2pd.log" exec /usr/sbin/i2pd --daemon --service --log=file --logfile=$LOGFILE diff --git a/debian/logrotate b/debian/logrotate index 3462c696..63c44270 100644 --- a/debian/logrotate +++ b/debian/logrotate @@ -1,4 +1,4 @@ -/var/log/i2pd.log { +/var/log/i2pd/i2pd.log { rotate 6 daily missingok diff --git a/debian/patches/01-tune-build-opts.patch b/debian/patches/01-tune-build-opts.patch index 2a09b07b..fba12f4e 100644 --- a/debian/patches/01-tune-build-opts.patch +++ b/debian/patches/01-tune-build-opts.patch @@ -1,5 +1,5 @@ diff --git a/Makefile b/Makefile -index 7d04ba0..33ee184 100644 +index b6fc795..abc3ace 100644 --- a/Makefile +++ b/Makefile @@ -9,10 +9,10 @@ DEPS := obj/make.dep @@ -10,8 +10,7 @@ index 7d04ba0..33ee184 100644 +USE_AESNI := no USE_STATIC := no USE_MESHNET := no --USE_UPNP := no -+USE_UPNP := yes - - ifeq ($(UNAME),Darwin) - DAEMON_SRC += DaemonLinux.cpp + USE_UPNP := no + + ifeq ($(WEBSOCKETS),1) + NEEDED_CXXFLAGS += -DWITH_EVENTS diff --git a/debian/postinst b/debian/postinst index 1de58c1e..9c9e74ae 100755 --- a/debian/postinst +++ b/debian/postinst @@ -1,7 +1,7 @@ #!/bin/sh set -e -LOGFILE='/var/log/i2pd.log' +LOGFILE='/var/log/i2pd/i2pd.log' I2PDHOME='/var/lib/i2pd' I2PDUSER='i2pd' @@ -17,6 +17,8 @@ case "$1" in adduser --system --quiet --group --home $I2PDHOME $I2PDUSER fi + mkdir -p -m0750 /var/log/i2pd + chown -f ${I2PDUSER}:adm /var/log/i2pd touch $LOGFILE chmod 640 $LOGFILE chown -f ${I2PDUSER}:adm $LOGFILE diff --git a/debian/postrm b/debian/postrm index a188b52c..53ab15e7 100755 --- a/debian/postrm +++ b/debian/postrm @@ -2,9 +2,11 @@ set -e if [ "$1" = "purge" ]; then - rm -f /etc/default/i2pd /var/log/i2pd.log + rm -f /etc/default/i2pd rm -rf /etc/i2pd rm -rf /var/lib/i2pd + rm -rf /var/log/i2pd + rm -rf /var/run/i2pd fi #DEBHELPER# diff --git a/debian/rules b/debian/rules index 1e3535da..171a5269 100755 --- a/debian/rules +++ b/debian/rules @@ -15,3 +15,6 @@ PREFIX=/usr override_dh_strip: dh_strip --dbg-package=i2pd-dbg + +override_dh_shlibdeps: + dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info