Ignore:
Timestamp:
Dec 10, 2011 2:17:37 AM (9 years ago)
Author:
kytv <kytv@…>
Branches:
master
Children:
fc7d8f7
Parents:
1d842f02
Message:

Add wrapper.java.maxmemory to debconf

The amount of RAM that I2P is limited to can be adjusted using debconf. The
value in /etc/i2p/wrapper.config is stored in the debconf db and is written to
/etc/default/i2p.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • debian/i2p.postinst

    r1d842f02 r03ff4dc0  
    1313
    1414case "$1" in
    15         configure|reconfigure)
    16                 if [ ! -e $conffile ]; then
    17                         echo "# Defaults for i2p initscript (/etc/init.d/i2p" >> $conffile
    18                         echo "# This is a posix shell fragment" >> $conffile
    19                         echo >> $conffile
    20                         echo "# [automatically edited by postinst, do not change line format ]" >> $conffile
    21                         echo "# Run 'dpkg-reconfigure -plow i2p' to change these values." >> $conffile
    22                         echo >> $conffile
    23                         echo "RUN_DAEMON=" >> $conffile
    24                         echo "I2PUSER=" >> $conffile
    25                 fi
     15    configure|reconfigure)
     16        if [ ! -e $conffile ]; then
     17            echo "# Defaults for i2p initscript (/etc/init.d/i2p" >> $conffile
     18            echo "# This is a posix shell fragment" >> $conffile
     19            echo >> $conffile
     20            echo "# [automatically edited by postinst, do not change line format ]" >> $conffile
     21            echo "# Run 'dpkg-reconfigure -plow i2p' to change these values." >> $conffile
     22            echo >> $conffile
     23            echo "RUN_DAEMON=" >> $conffile
     24            echo "I2PUSER=" >> $conffile
     25            echo "# The next value is also wrapper.java.maxmemory in /etc/i2p/wrapper.config" >> $conffile
     26            echo "MEMORYLIMIT=" >> $conffile
     27        fi
    2628
    27                 db_get i2p/daemon
    28                 RUN_DAEMON="$RET"
    29                 db_get i2p/user
    30                 I2PUSER="$RET"
     29        db_get i2p/daemon
     30        RUN_DAEMON="$RET"
     31        db_get i2p/user
     32        I2PUSER="$RET"
     33        db_get i2p/memory
     34        MEMORYLIMIT="$RET"
    3135
    32                 cp -a -f $conffile $conffile.tmp
     36        cp -a -f $conffile $conffile.tmp
    3337
    34                 # If the admin deleted or commented some variables but then set them via debconf,
    35                 # (re-)add them to the conffile.
    36                 test -z "$RUN_DAEMON" || grep -Eq '^ *RUN_DAEMON=' $conffile || \
    37                         echo "RUN_DAEMON=" >> $conffile
    38                 test -z "$I2PUSER" || grep -Eq '^ *I2PUSER=' $conffile || \
    39                         echo "I2PUSER=" >> $conffile
     38        # If the admin deleted or commented some variables but then set them via debconf,
     39        # (re-)add them to the conffile.
     40        test -z "$RUN_DAEMON" || grep -Eq '^ *RUN_DAEMON=' $conffile || \
     41            echo "RUN_DAEMON=" >> $conffile
     42        test -z "$I2PUSER" || grep -Eq '^ *I2PUSER=' $conffile || \
     43            echo "I2PUSER=" >> $conffile
     44        test -z "$MEMORYLIMIT" || grep -Eq '^ *MEMORYLIMIT=' $conffile || \
     45            echo "MEMORYLIMIT=" >> $conffile
    4046
    41                 if [ -z $RUN_DAEMON ]; then
    42                         RUN_DAEMON="false"
    43                         I2PUSER="i2psvc"
    44                 fi
     47        if [ -z $RUN_DAEMON ]; then
     48            RUN_DAEMON="false"
     49            I2PUSER="i2psvc"
     50        fi
    4551
    46                 sed -e "s/^ *RUN_DAEMON=.*/RUN_DAEMON=\"$RUN_DAEMON\"/" \
    47                         -e "s/^ *I2PUSER=.*/I2PUSER=\"$I2PUSER\"/" \
    48                         < $conffile > $conffile.tmp
    49                 mv -f $conffile.tmp $conffile
    5052
    51         migrate_existing_user(){
    52                 # Adjust the user/group in /etc/passwd, mainly for upgrades from old packages that didn't
    53                 # create $I2PSYSUSER as a system group/user
    54                 usermod -c "I2P Router Daemon" -m -d $I2PHOME -g $I2PSYSUSER -s "/bin/false" \
    55                         -l $I2PSYSUSER -e 1 > /dev/null 2>&1
    56                 echo "Existing user migrated, home directory moved to $I2PHOME"
    57         }
    5853
    59         # Create user and group as a system user.
    60         adduser --system --quiet --group --home $I2PHOME $I2PSYSUSER || migrate_existing_user
     54        sed -e "s/^ *RUN_DAEMON=.*/RUN_DAEMON=\"$RUN_DAEMON\"/" \
     55            -e "s/^ *I2PUSER=.*/I2PUSER=\"$I2PUSER\"/" \
     56            -e "s/^ *MEMORYLIMIT=.*/MEMORYLIMIT=\"$MEMORYLIMIT\"/" \
     57            < $conffile > $conffile.tmp
     58        mv -f $conffile.tmp $conffile
    6159
    62         [ -d /var/log/i2p ] || mkdir -m0750 /var/log/i2p
    63         chown -f -R $I2PSYSUSER:adm /var/log/i2p
     60        sed -e "s/^ *wrapper\.java\.maxmemory=.*/wrapper\.java\.maxmemory=$MEMORYLIMIT/" \
     61            < /etc/i2p/wrapper.config > /etc/i2p/wrapper.config.tmp
     62        mv -f /etc/i2p/wrapper.config.tmp /etc/i2p/wrapper.config
    6463
    65         # Has someone set the permissions with dpkg-statoverride? If so, obey them.
    66         if ! dpkg-statoverride --list $I2PHOME > /dev/null 2>&1
    67         then
    68                 chown -f -R $I2PSYSUSER:$I2PSYSUSER $I2PHOME
    69                 chmod -f u=rwx,g=rxs,o= $I2PHOME
    70         fi
     64    migrate_existing_user(){
     65        # Adjust the user/group in /etc/passwd, mainly for upgrades from old packages that didn't
     66        # create $I2PSYSUSER as a system group/user
     67        usermod -c "I2P Router Daemon" -m -d $I2PHOME -g $I2PSYSUSER -s "/bin/false" \
     68            -l $I2PSYSUSER -e 1 > /dev/null 2>&1
     69        echo "Existing user migrated, home directory moved to $I2PHOME"
     70    }
    7171
    72         db_stop
     72    # Create user and group as a system user.
     73    adduser --system --quiet --group --home $I2PHOME $I2PSYSUSER || migrate_existing_user
     74
     75    [ -d /var/log/i2p ] || mkdir -m0750 /var/log/i2p
     76    chown -f -R $I2PSYSUSER:adm /var/log/i2p
     77
     78    # Has someone set the permissions with dpkg-statoverride? If so, obey them.
     79    if ! dpkg-statoverride --list $I2PHOME > /dev/null 2>&1
     80    then
     81        chown -f -R $I2PSYSUSER:$I2PSYSUSER $I2PHOME
     82        chmod -f u=rwx,g=rxs,o= $I2PHOME
     83    fi
     84
     85    db_stop
    7386;;
    7487abort-upgrade|abort-remove|abort-deconfigure)
    75         echo "Aborting upgrade"
    76         exit 0
    77         ;;
     88    echo "Aborting upgrade"
     89    exit 0
     90    ;;
    7891*)
    7992        echo "postinst called with unknown argument \`$1'" >&2
     
    8194                ;;
    8295esac
    83        
     96   
    8497#DEBHELPER#
    8598
Note: See TracChangeset for help on using the changeset viewer.