Changeset 627f707 for debian


Ignore:
Timestamp:
Jun 14, 2015 8:16:16 PM (5 years ago)
Author:
kytv <kytv@…>
Branches:
master
Children:
8096e4f6
Parents:
863e120
Message:

debian: Add support for setting open file limits to initscript, add comment to explain how to do it with systemd

Location:
debian
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • debian/i2p.init

    r863e120 r627f707  
    3333NICE=0
    3434I2PUSER="i2psvc"
    35 USE_AA="yes"
    3635
    3736I2P_ARGS="/etc/i2p/wrapper.config \
     
    6867fi
    6968
     69case "$CONFINE_WITH_APPARMOR" in
     70    [NnFf]*)
     71        USE_AA="no"
     72        ;;
     73    *)
     74        USE_AA="yes"
     75        ;;
     76esac
     77
    7078case "$RUN_DAEMON" in
    7179    [NnFf]*)
     
    8492do_start()
    8593{
     94    [ ! -z $ULIMIT ] && ulimit -n $ULIMIT
    8695    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null 2>&1 \
    8796        || return 1
  • debian/i2p.postinst

    r863e120 r627f707  
    77
    88conffile="/etc/default/i2p"
    9 #systemdservice="/lib/systemd/system/i2p.service"
     9systemdservice="/lib/systemd/system/i2p.service"
    1010
    1111# Source debconf library -- we have a Depends line
     
    2626            echo "RUN_DAEMON=" >> $conffile
    2727            echo "I2PUSER=" >> $conffile
     28            echo "ULIMIT=" >> $conffile
    2829            echo "CONFINE_WITH_APPARMOR=" >> $conffile
    2930            echo "# The next value is also wrapper.java.maxmemory in /etc/i2p/wrapper.config" >> $conffile
     
    5051        test -z "$MEMORYLIMIT" || grep -Eq '^ *MEMORYLIMIT=' $conffile || \
    5152            echo "MEMORYLIMIT=" >> $conffile
     53        test -z "$ULIMIT" || grep -Eq '^ *ULIMIT=' $conffile || \
     54            echo "ULIMIT=" >> $conffile
    5255        test -z "$CONFINE_WITH_APPARMOR" || grep -Eq '^ *CONFINE_WITH_APPARMOR=' $conffile || \
    5356            echo "CONFINE_WITH_APPARMOR=" >> $conffile
     
    5861        fi
    5962
    60 
    61 
    6263        sed -e "s/^ *RUN_DAEMON=.*/RUN_DAEMON=\"$RUN_DAEMON\"/" \
    6364            -e "s/^ *I2PUSER=.*/I2PUSER=\"$I2PUSER\"/" \
     
    6768        mv -f $conffile.tmp $conffile
    6869
    69 #        if [ -e "$systemdservice" ]; then
    70 #            sed -e "s/User=.*/User=$I2PUSER/" < "$systemdservice" > "$systemdservice.tmp"
    71 #            mv -f "$systemdservice.tmp" "$systemdservice"
    72 #            chmod 0644 -f "$systemdservice"
    73 #            if grep -q 'systemd' /proc/1/comm > /dev/null 2>&1; then
    74 #                systemctl --system daemon-reload
    75 #                if [ $RUN_DAEMON = 'true' ]; then
    76 #                    systemctl enable i2p.service
    77 #                else
    78 #                    systemctl disable i2p.service
    79 #                fi
    80 #            fi
    81 #        fi
     70        if [ -e "$systemdservice" ]; then
     71            sed -e "s/User=.*/User=$I2PUSER/" < "$systemdservice" > "$systemdservice.tmp"
     72            mv -f "$systemdservice.tmp" "$systemdservice"
     73            chmod 0644 -f "$systemdservice"
     74            if grep -q 'systemd' /proc/1/comm > /dev/null 2>&1; then
     75                systemctl --system daemon-reload
     76                if [ $RUN_DAEMON = 'true' ]; then
     77                    systemctl enable i2p.service
     78                else
     79                    systemctl disable i2p.service
     80                fi
     81            fi
     82        fi
    8283
    8384        sed -e "s/^ *wrapper\.java\.maxmemory=.*/wrapper\.java\.maxmemory=$MEMORYLIMIT/" \
  • debian/i2p.service

    r863e120 r627f707  
     1# It's not recommended to modify this file because it will be
     2# overwritten during package upgrades.  If you want to make changes, the
     3# best way is to create a file "/etc/systemd/system/i2p.service.d/foo.conf"
     4# and make your changes there. This file will be parsed after the file
     5# i2p.service itself is parsed.
     6#
     7# For more info about custom unit files, see systemd.unit(5) or
     8# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F
     9
     10# For example, if you want to increase I2P's open-files-limit to 10000,
     11# you need to increase systemd's LimitNOFILE setting, so create a file named
     12# "/etc/systemd/system/i2p.service.d/limits.conf" containing:
     13#       [Service]
     14#       LimitNOFILE=10000
     15
     16# Don't forget to reload systemd daemon after you change unit configuration:
     17# root> systemctl --system daemon-reload
     18
    119[Unit]
    220Description=load-balanced unspoofable packet switching network
    3 After=network.target
     21After=local-fs.target network.target time-sync.target
    422
    523[Service]
    624Type=forking
    725EnvironmentFile=/etc/default/i2p
     26RuntimeDirectory=i2p
     27RuntimeDirectoryMode=750
     28PIDFile=/run/i2p/i2p.pid
    829Environment="I2P_ARGS=/etc/i2p/wrapper.config \
    930 wrapper.java.additional.1=-DloggerFilenameOverride=/var/log/i2p/log-router-@.txt \
     
    1738User=i2psvc
    1839PermissionsStartOnly=true
    19 ExecStartPre=/bin/mkdir -p /run/i2p /tmp/i2p-daemon
     40AppArmorProfile=system_i2p
     41ExecStartPre=/bin/mkdir -p /tmp/i2p-daemon
    2042ExecStartPre=/bin/chown -R ${I2PUSER}:${I2PUSER} /var/log/i2p /run/i2p /tmp/i2p-daemon
    2143ExecStartPre=/bin/chmod 750 /var/log/i2p
    2244ExecStart=/usr/sbin/wrapper "$I2P_ARGS"
    23 ExecStopPost=/bin/rm -rf /run/i2p /tmp/i2p-daemon
     45ExecStopPost=/bin/rm -rf /run/i2p
    2446
    2547[Install]
Note: See TracChangeset for help on using the changeset viewer.