Revize 2258
Přidáno uživatelem Ondřej Fibich před téměř 11 roky(ů)
freenetis/branches/1.1/application/vendors/qos/freenetis-qos.conf | ||
---|---|---|
################################################################################
|
||
# #
|
||
# This script serves for IS FreenetIS (redirection and QoS) #
|
||
# #
|
||
# Author Michal Kliment 2012 #
|
||
# Email kliment@freenetis.org #
|
||
# #
|
||
# name freenetis-qos.conf #
|
||
# version 0.9.0 #
|
||
# #
|
||
################################################################################
|
||
|
||
################################################################################
|
||
# G E N E R A L S E T T I N G S #
|
||
################################################################################
|
||
|
||
# Base PATH_FN to running FreenetIS instance
|
||
PATH_FN=http://localhost/freenetis
|
||
|
||
# Log file, change to /dev/null to disable logging
|
||
LOG_FILE=/var/log/freenetis-qos.log
|
||
|
||
# Input interface on which redirection rules and QoS download are applicated on
|
||
INPUT_INTERFACE=eth0
|
||
|
||
# Output interface on which QoS upload is applicated on
|
||
OUTPUT_INTERFACE=eth0
|
||
|
||
# Delay in seconds between next update cycle
|
||
DELAY=60
|
||
|
||
# URL of pages which we need to download from FreenetIS. [DO NOT CHANGE THIS VALUES!!]
|
||
SET_URL_QOS_MEMBERS=$PATH_FN/index.php/en/web_interface/members_qos_ceil_rate
|
||
SET_URL_QOS_IP_ADDRESSES=$PATH_FN/index.php/en/web_interface/ip_addresses_qos_ceil_rate
|
freenetis/branches/1.1/application/vendors/qos/freenetis-qos-sync.sh | ||
---|---|---|
#!/bin/bash
|
||
################################################################################
|
||
# #
|
||
# This script serves for QoS synchronization of IS FreenetIS #
|
||
# #
|
||
# Author Michal Kliment 2012 #
|
||
# Email kliment@freenetis.org #
|
||
# #
|
||
# name freenetis-qos-sync.sh #
|
||
# version 0.9.0 #
|
||
# #
|
||
################################################################################
|
||
|
||
#Load variables from config file
|
||
CONFIG=/etc/freenetis/freenetis-qos.conf
|
||
|
||
PATH_QOS_MEMBERS=/tmp/qos_members
|
||
PATH_QOS_IP_ADDRESSES=/tmp/qos_ip_addresses
|
||
PATH_QOS_IPSETS=/tmp/qos_ipsets
|
||
|
||
IPTABLES=/sbin/iptables
|
||
|
||
LOG_PREFIX=`date "+%Y-%m-%d %H:%M"`" QoS: "
|
||
|
||
ROOT="1:"
|
||
|
||
#Load variables
|
||
if [ -f ${CONFIG} ]; then
|
||
. $CONFIG;
|
||
else
|
||
echo "Config file is missing at path $CONFIG."
|
||
echo "Terminating..."
|
||
exit 0
|
||
fi
|
||
|
||
stop ()
|
||
{
|
||
# for each current ipsets, list is stored in file
|
||
cat $PATH_QOS_IPSETS | while read line
|
||
do
|
||
ID=`echo $line | awk '{print $1}'`
|
||
IPSET=`echo $line | awk '{print $2}'`
|
||
|
||
# flush ipset
|
||
ipset -F $IPSET
|
||
echo $LOG_PREFIX"Emptied ipset $IPSET";
|
||
|
||
# remove its iptables rules
|
||
#$IPTABLES -t mangle -D POSTROUTING -o $OUTPUT_INTERFACE -m set --set $IPSET src -j CLASSIFY --set-class $ROOT$ID
|
||
$IPTABLES -t mangle -D POSTROUTING -m set --set $IPSET src -j CLASSIFY --set-class $ROOT$ID
|
||
$IPTABLES -t mangle -D POSTROUTING -m set --set $IPSET src -j RETURN
|
||
echo $LOG_PREFIX"Deleted iptables rule for assignment upload tc class $ROOT$ID to ipset $IPSET"
|
||
|
||
#$IPTABLES -t mangle -D POSTROUTING -o $INPUT_INTERFACE -m set --set $IPSET dst -j CLASSIFY --set-class $ROOT$ID
|
||
$IPTABLES -t mangle -D POSTROUTING -m set --set $IPSET dst -j CLASSIFY --set-class $ROOT$ID
|
||
$IPTABLES -t mangle -D POSTROUTING -m set --set $IPSET dst -j RETURN
|
||
echo $LOG_PREFIX"Deleted iptables rule for assignment download tc class $ROOT$ID to ipset $IPSET"
|
||
|
||
# remove ipset
|
||
ipset -X $IPSET
|
||
echo $LOG_PREFIX"Removed ipset $IPSET"
|
||
done
|
||
|
||
# clear file with ipset list
|
||
cat /dev/null > $PATH_QOS_IPSETS
|
||
|
||
echo $LOG_PREFIX"Deleting old tc classes"
|
||
|
||
# deletes all old qdiscs, its remove all children classes, qdisc, etc.
|
||
tc qdisc del dev $OUTPUT_INTERFACE root 2> /dev/null
|
||
tc qdisc del dev $INPUT_INTERFACE root 2> /dev/null
|
||
}
|
||
|
||
start ()
|
||
{
|
||
echo $LOG_PREFIX"Downloading data"
|
||
|
||
wget -q -O $PATH_QOS_MEMBERS $SET_URL_QOS_MEMBERS --no-check-certificate
|
||
wget -q -O $PATH_QOS_IP_ADDRESSES $SET_URL_QOS_IP_ADDRESSES --no-check-certificate
|
||
|
||
# creates default qdiscs (first for upload, second for download)
|
||
tc qdisc add dev $OUTPUT_INTERFACE root handle $ROOT htb default 2
|
||
echo $LOG_PREFIX"Added root tc qdisc for upload"
|
||
|
||
tc qdisc add dev $INPUT_INTERFACE root handle $ROOT htb default 2
|
||
echo $LOG_PREFIX"Added root tc qdisc for download"
|
||
|
||
# line number counter
|
||
LNR=1
|
||
|
||
cat $PATH_QOS_MEMBERS | while read line
|
||
do
|
||
ID=`echo $line | awk '{print $1}'`
|
||
|
||
UPLOAD_CEIL=`echo $line | awk '{print $2}'`
|
||
DOWNLOAD_CEIL=`echo $line | awk '{print $3}'`
|
||
|
||
UPLOAD_RATE=`echo $line | awk '{print $4}'`
|
||
DOWNLOAD_RATE=`echo $line | awk '{print $5}'`
|
||
|
||
PRIORITY=`echo $line | awk '{print $6}'`
|
||
|
||
PROTOCOL=`echo $line | awk '{print $7}'`
|
||
|
||
PARENT=`echo $line | awk '{print $8}'`
|
||
|
||
IPSET=`echo $line | awk '{print $9}'`
|
||
|
||
if [ "$UPLOAD_CEIL" != "0M" ]; then
|
||
UPLOAD_CEIL=" ceil "$UPLOAD_CEIL"bit"
|
||
else
|
||
UPLOAD_CEIL=""
|
||
fi
|
||
|
||
if [ "$UPLOAD_RATE" != "0M" ]; then
|
||
UPLOAD_RATE=" rate "$UPLOAD_RATE"bit"
|
||
else
|
||
UPLOAD_RATE=""
|
||
fi
|
||
|
||
if [ "$DOWNLOAD_CEIL" != "0M" ]; then
|
||
DOWNLOAD_CEIL=" ceil "$DOWNLOAD_CEIL"bit"
|
||
else
|
||
DOWNLOAD_CEIL=""
|
||
fi
|
||
|
||
if [ "$DOWNLOAD_RATE" != "0M" ]; then
|
||
DOWNLOAD_RATE=" rate "$DOWNLOAD_RATE"bit"
|
||
else
|
||
DOWNLOAD_RATE=""
|
||
fi
|
||
|
||
# creates classes (first for upload, second for download)
|
||
tc class add dev $OUTPUT_INTERFACE parent $ROOT$PARENT classid $ROOT$ID htb $UPLOAD_RATE $UPLOAD_CEIL
|
||
echo $LOG_PREFIX"Created tc class $ROOT$ID for upload"
|
||
|
||
tc class add dev $INPUT_INTERFACE parent $ROOT$PARENT classid $ROOT$ID htb $DOWNLOAD_RATE $DOWNLOAD_CEIL
|
||
echo $LOG_PREFIX"Created tc class $ROOT$ID for download"
|
||
|
||
if [ "$LNR" -gt 1 ]; then
|
||
|
||
tc qdisc add dev $OUTPUT_INTERFACE parent $ROOT$ID handle $ID: sfq
|
||
echo $LOG_PREFIX"Created tc qdisc for upload tc class $ROOT$ID"
|
||
|
||
tc qdisc add dev $INPUT_INTERFACE parent $ROOT$ID handle $ID: sfq
|
||
echo $LOG_PREFIX"Created tc qdisc for download tc class $ROOT$ID"
|
||
|
||
tc filter add dev $OUTPUT_INTERFACE parent $ID: prio $PRIORITY handle $ID protocol $PROTOCOL flow hash keys nfct-src divisor 1024
|
||
echo $LOG_PREFIX"Created filter for upload tc class $ROOT$ID with priority $PRIORITY and protocol $PROTOCOL"
|
||
|
||
tc filter add dev $INPUT_INTERFACE parent $ID: prio $PRIORITY handle $ID protocol $PROTOCOL flow hash keys dst divisor 1024
|
||
echo $LOG_PREFIX"Created filter for download tc class $ROOT$ID with priority $PRIORITY and protocol $PROTOCOL"
|
||
|
||
fi
|
||
|
||
if [ "$IPSET" != "" ]; then
|
||
|
||
ipset -N $IPSET iphash --hashsize 10000 --probes 8 --resize 50
|
||
echo $LOG_PREFIX"Created ipset $IPSET for tc class $ROOT$ID"
|
||
|
||
#$IPTABLES -t mangle -A POSTROUTING -o $OUTPUT_INTERFACE -m set --set $IPSET src -j CLASSIFY --set-class $ROOT$ID
|
||
$IPTABLES -t mangle -A POSTROUTING -m set --set $IPSET src -j CLASSIFY --set-class $ROOT$ID
|
||
$IPTABLES -t mangle -A POSTROUTING -m set --set $IPSET src -j RETURN
|
||
echo $LOG_PREFIX"Added iptables rule for assignment upload tc class $ROOT$ID to ipset $IPSET"
|
||
|
||
#$IPTABLES -t mangle -A POSTROUTING -o $INPUT_INTERFACE -m set --set $IPSET dst -j CLASSIFY --set-class $ROOT$ID
|
||
$IPTABLES -t mangle -A POSTROUTING -m set --set $IPSET dst -j CLASSIFY --set-class $ROOT$ID
|
||
$IPTABLES -t mangle -A POSTROUTING -m set --set $IPSET dst -j RETURN
|
||
echo $LOG_PREFIX"Added iptables rule for assignment download tc class $ROOT$ID to ipset $IPSET"
|
||
|
||
awk '{ if ($1=='$ID') print $2 }' $PATH_QOS_IP_ADDRESSES | while read IP_ADDRESS
|
||
do
|
||
ipset -A $IPSET $IP_ADDRESS
|
||
echo $LOG_PREFIX"Added ip address $IP_ADDRESS to ipset $IPSET"
|
||
done
|
||
|
||
echo "$ID $IPSET" >> $PATH_QOS_IPSETS
|
||
fi
|
||
|
||
LNR=$(($LNR+1))
|
||
done
|
||
|
||
echo $LOG_PREFIX"Sleeping"
|
||
sleep $DELAY
|
||
}
|
||
|
||
update()
|
||
{
|
||
stop
|
||
start
|
||
}
|
||
|
||
case "$1" in
|
||
update)
|
||
while (true);
|
||
do
|
||
update
|
||
done
|
||
;;
|
||
stop)
|
||
stop
|
||
;;
|
||
esac
|
freenetis/branches/1.1/application/vendors/qos/freenetis-qos.init.sh | ||
---|---|---|
#! /bin/bash
|
||
|
||
### BEGIN INIT INFO
|
||
# Provides: freenetis-qos
|
||
# Required-Start: $remote_fs
|
||
# Required-Stop: $remote_fs
|
||
# Should-Start: $network $syslog
|
||
# Should-Stop: $network $syslog
|
||
# Default-Start: 2 3 4 5
|
||
# Default-Stop: 0 1 6
|
||
# Short-Description: Start and stop freenetis QoS daemon
|
||
# Description: FreenetIS initialization QoS synchronization script.
|
||
### END INIT INFO
|
||
|
||
################################################################################
|
||
# #
|
||
# This script serves for initialization of QoS of IS FreenetIS #
|
||
# #
|
||
# Author Michal Kliment 2012 #
|
||
# Email kliment@freenetis.org #
|
||
# #
|
||
# Name freenetis-qos.init.sh #
|
||
# Version 0.9.0 #
|
||
# #
|
||
################################################################################
|
||
|
||
#Local variable contains path to iptables - mandatory
|
||
IPTABLES=/sbin/iptables
|
||
|
||
#Load variables from config file
|
||
CONFIG=/etc/freenetis/freenetis-qos.conf
|
||
|
||
# Path to QoS synchronization file
|
||
QOS_SYNCFILE=/usr/sbin/freenetis-qos-sync
|
||
|
||
#Path to QoS pid file
|
||
QOS_PIDFILE=/var/run/freenetis-qos-sync.pid
|
||
|
||
#Load variables
|
||
if [ -f ${CONFIG} ]; then
|
||
. $CONFIG;
|
||
else
|
||
echo "Config file is missing at path $CONFIG."
|
||
echo "Terminating..."
|
||
exit 0
|
||
fi
|
||
|
||
start_qos ()
|
||
{
|
||
cat /dev/null > "$LOG_FILE"
|
||
|
||
if [ -f ${QOS_PIDFILE} ]; then
|
||
echo "Already started"
|
||
return 0
|
||
fi
|
||
|
||
echo -n "Starting FreenetIS QoS deamon: "
|
||
nohup $QOS_SYNCFILE update >> "$LOG_FILE" 2>&1 &
|
||
|
||
#Parse PID a save to file
|
||
ps aux | grep $QOS_SYNCFILE | grep -v grep | awk '{print $2}' > $QOS_PIDFILE
|
||
|
||
# test if daemon is started
|
||
if [ `ps aux | grep $QOS_SYNCFILE | grep -v grep | wc -l` -gt 0 ];
|
||
then
|
||
echo "OK"
|
||
else
|
||
echo "FAILED!"
|
||
fi
|
||
|
||
return 0
|
||
}
|
||
|
||
stop_qos ()
|
||
{
|
||
if [ ! -f ${QOS_PIDFILE} ]; then
|
||
echo "Already stopped"
|
||
return 0
|
||
fi
|
||
|
||
#Killing of process by sigterm
|
||
echo -n "Stopping FreenetIS QoS deamon: "
|
||
kill -9 `cat $QOS_PIDFILE`
|
||
|
||
rm -f $QOS_PIDFILE
|
||
|
||
$QOS_SYNCFILE stop >> "$LOG_FILE" 2>&1
|
||
|
||
# test if daemon is stopped
|
||
if [ `ps aux | grep $QOS_SYNCFILE | grep -v grep | wc -l` -eq 0 ];
|
||
then
|
||
echo "OK"
|
||
else
|
||
echo "FAILED!";
|
||
fi
|
||
|
||
return 0
|
||
}
|
||
|
||
status_qos ()
|
||
{
|
||
if [ -f ${QOS_PIDFILE} ]; then
|
||
echo "Freenetis QoS is running with PID `cat $QOS_PIDFILE`"
|
||
return 0
|
||
else
|
||
echo "Freenetis QoS is not running"
|
||
return 0
|
||
fi
|
||
}
|
||
|
||
usage_qos ()
|
||
{
|
||
echo "usage : `echo $0` (start|stop|restart|status|help)"
|
||
}
|
||
|
||
help_qos ()
|
||
{
|
||
echo " start - initialization of firewall rules and settings for QoS"
|
||
echo " stop - clears firewall rules and settings for QoS"
|
||
echo " restart - restarts firewall rules and settings for QoS"
|
||
echo " status - returns actual status of QoS"
|
||
echo " help - prints help for QoS"
|
||
}
|
||
|
||
# Is parameter #1 zero length?
|
||
if [ -z "$1" ]; then
|
||
usage_qos
|
||
exit 0
|
||
fi;
|
||
|
||
case "$1" in
|
||
|
||
start)
|
||
start_qos
|
||
exit 0
|
||
;;
|
||
|
||
restart)
|
||
stop_qos
|
||
start_qos
|
||
exit 0
|
||
;;
|
||
|
||
stop)
|
||
stop_qos
|
||
exit 0
|
||
;;
|
||
|
||
status)
|
||
status_qos
|
||
exit 0
|
||
;;
|
||
|
||
help)
|
||
usage_qos
|
||
help_qos
|
||
exit 0
|
||
;;
|
||
|
||
*)
|
||
usage_qos
|
||
exit 0
|
||
;;
|
||
|
||
esac
|
||
|
||
exit 0
|
freenetis/branches/1.1/application/vendors/deb/freenetis-qos/templates | ||
---|---|---|
Template: freenetis-qos/path_freenetis
|
||
Type: string
|
||
Default: http://localhost/freenetis
|
||
Description: FreenetIS URL:
|
||
Base path to running FreenetIS instance (e.g. http://freenet.org/is)
|
||
Description-cs.UTF-8: FreenetIS URL:
|
||
Cesta ke kořenu běžící instalace FreenetISu (např. http://freenet.org/is)
|
||
|
||
Template: freenetis-qos/input_interface
|
||
Type: string
|
||
Default: eth0
|
||
Description: Input interface:
|
||
Input interface on which QoS download rules are applicated on.
|
||
Description-cs.UTF-8: Vstupní rozhraní:
|
||
Vstupní rozhraní, na kterém jsou aplikována QoS download pravidla.
|
||
|
||
Template: freenetis-qos/output_interface
|
||
Type: string
|
||
Default: eth0
|
||
Description: Output interface:
|
||
Output interface on which QoS upload rules are applicated on
|
||
Description-cs.UTF-8: Výstupní rozhraní:
|
||
Výstupní rozhraní, na které je aplikován QoS upload pravidla.
|
||
|
||
Template: freenetis-qos/hack_reload
|
||
Type: boolean
|
||
Default: true
|
||
Description: Hack:
|
||
Hack for propper working of loading package.
|
freenetis/branches/1.1/application/vendors/deb/freenetis-qos/debianization.sh | ||
---|---|---|
#!/bin/sh
|
||
################################################################################
|
||
# Script for debianization of FreenetIS redirection and QoS package
|
||
# (c) Ondrej Fibich, 2012
|
||
#
|
||
# Takes two arguments (version of package - FreenetIS and debian version).
|
||
#
|
||
################################################################################
|
||
|
||
if [ $# -ne 2 ]; then
|
||
echo "Wrong arg count.. Terminating"
|
||
exit 1
|
||
fi
|
||
|
||
NAME=freenetis-qos
|
||
VERSION=$1
|
||
DEBIAN=$2
|
||
|
||
# create dirs ##################################################################
|
||
mkdir deb_packages/tmp
|
||
cd deb_packages/tmp
|
||
|
||
mkdir DEBIAN
|
||
mkdir etc
|
||
mkdir etc/init.d
|
||
mkdir etc/freenetis
|
||
mkdir usr
|
||
mkdir usr/sbin
|
||
|
||
# copy content of package ######################################################
|
||
cp ../../../qos/freenetis-qos.init.sh etc/init.d/${NAME}
|
||
cp ../../../qos/freenetis-qos-sync.sh usr/sbin/freenetis-qos-sync
|
||
cp ../../../qos/freenetis-qos.conf etc/freenetis/
|
||
|
||
# count size
|
||
SIZE=`du -s etc usr | cut -f1 | paste -sd+ | bc`
|
||
|
||
# calculate checksum ###########################################################
|
||
|
||
find * -type f ! -regex '^DEBIAN/.*' -exec md5sum {} \; >> DEBIAN/md5sums
|
||
|
||
# create info files ############################################################
|
||
|
||
# create package info
|
||
|
||
echo "Package: ${NAME}" >> DEBIAN/control
|
||
echo "Version: ${VERSION}-${DEBIAN}" >> DEBIAN/control
|
||
echo "Installed-Size: ${SIZE}" >> DEBIAN/control
|
||
|
||
if [ "$DEBIAN" = lenny ] || [ "$DEBIAN" = squeeze ]; then
|
||
echo "Depends: coreutils, ipset, wget, procps, iptables, ipset-source, module-assistant, lsb-release" >> DEBIAN/control
|
||
else
|
||
echo "Depends: coreutils, ipset, wget, procps, iptables, lsb-release" >> DEBIAN/control
|
||
fi
|
||
|
||
cat ../../${NAME}/control >> DEBIAN/control
|
||
|
||
# change log
|
||
|
||
cat ../../${NAME}/changelog >> DEBIAN/changelog
|
||
|
||
# copywriting
|
||
|
||
echo "This package was debianized by Ondrej Fibich <ondrej.fibich@gmail.com> on" >> DEBIAN/copyright
|
||
date -R >> DEBIAN/copyright
|
||
echo "" >> DEBIAN/copyright
|
||
echo "It was downloaded from <http://freenetis.org/>" >> DEBIAN/copyright
|
||
echo "" >> DEBIAN/copyright
|
||
echo "Upstream Author:" >> DEBIAN/copyright
|
||
cat ../../../../../AUTHORS >> DEBIAN/copyright
|
||
echo "" >> DEBIAN/copyright
|
||
echo "License:" >> DEBIAN/copyright
|
||
cat ../../../../../COPYING >> DEBIAN/copyright
|
||
|
||
# scripts ######################################################################
|
||
|
||
cat ../../${NAME}/postinst >> DEBIAN/postinst
|
||
cat ../../${NAME}/prerm >> DEBIAN/prerm
|
||
cat ../../${NAME}/postrm >> DEBIAN/postrm
|
||
cat ../../${NAME}/templates >> DEBIAN/templates
|
||
cat ../../${NAME}/config >> DEBIAN/config
|
||
|
||
chmod +x DEBIAN/postinst DEBIAN/postrm DEBIAN/prerm DEBIAN/config
|
||
|
||
# create deb ###################################################################
|
||
|
||
# change owner of files to root (security)
|
||
cd ..
|
||
sudo chown -hR root:root *
|
||
|
||
# make package
|
||
sudo dpkg-deb -b tmp ${NAME}_${VERSION}+${DEBIAN}.deb
|
||
|
||
# clean-up mess ################################################################
|
||
|
||
# clean
|
||
sudo rm -rf tmp
|
||
freenetis/branches/1.1/application/vendors/deb/freenetis-qos/changelog | ||
---|---|---|
freenetis-qos (0.9.0) stable; urgency=low
|
||
* First release
|
||
-- Ondrej Fibich <ondrej.fibich@gmail.com> Tue, 07 Aug 2012 15:05:33 +0200
|
||
|
||
freenetis-qos (0.9.1) stable; urgency=low
|
||
* Fixes in postinst script
|
||
-- Ondrej Fibich <ondrej.fibich@gmail.com> Tue, 07 Aug 2012 15:59:41 +0200
|
||
|
||
freenetis-qos (0.9.2) stable; urgency=low
|
||
* Fixes in dependencies
|
||
-- Ondrej Fibich <ondrej.fibich@gmail.com> Mon, 13 Aug 2012 11:10:52 +0200
|
||
|
||
freenetis-qos (0.9.3) stable; urgency=low
|
||
* Improved building of ipset on squeeze (#454)
|
||
-- Ondrej Fibich <ondrej.fibich@gmail.com> Wed, 23 Jan 2013 14:24:32 +0100
|
freenetis/branches/1.1/application/vendors/deb/freenetis-qos/control | ||
---|---|---|
Priority: optional
|
||
Section: web
|
||
Pre-Depends: debconf (>= 0.5) | debconf-2.0
|
||
Suggests: freenetis
|
||
Architecture: all
|
||
Maintainer: Ondrej Fibich <ondrej.fibich@gmail.com>
|
||
Homepage: http://www.freenetis.org
|
||
Description: FreenetIS QoS - QoS tool for FreenetIS
|
||
The tool is capable of:
|
||
* enforcing of download and upload rate of users (max and guaranteed)
|
||
* set priority of services (dedicated services may be set)
|
||
Data that are required are fetched dynamically from FreenetIS using wget tool.
|
||
Description-cs.UTF-8: FreenetIS QoS - QoS nástroj pro FreenetIS
|
||
Nástroj je schopný:
|
||
* vynutit rychlost downloadu a uploadu uživatelů (maximální and garantovanou)
|
||
* nastavit priritu služeb (dedikované služby mohou být nastaveny)
|
||
Data, která jsou nutná pro jsou získávány dynamicky z FreenetISu pomoví nástroje wget.
|
freenetis/branches/1.1/application/vendors/deb/freenetis-qos/postrm | ||
---|---|---|
#!/bin/sh
|
||
# FreenetIS-qos DEB: actions before uninstalling of package
|
||
|
||
set -e
|
||
. /usr/share/debconf/confmodule
|
||
|
||
NAME=freenetis-qos
|
||
CONFIGFILE=/etc/freenetis/freenetis-qos.conf
|
||
|
||
# disable startup from update-rc.d
|
||
set +e
|
||
update-rc.d -f ${NAME} remove
|
||
set -e
|
||
|
||
# remove all configuration if purge
|
||
if [ "$1" = purge ]; then
|
||
# remove defconf values
|
||
if [ -e /usr/share/debconf/confmodule ]; then
|
||
db_purge
|
||
fi
|
||
# remove config files
|
||
rm -rf $CONFIGFILE
|
||
# remove dir if empty
|
||
[ "$(ls -A /etc/freenetis)" ] || rm -rf /etc/freenetis
|
||
fi
|
||
|
||
#DEBHELPER#
|
||
|
||
exit 0
|
freenetis/branches/1.1/application/vendors/deb/freenetis-qos/conffiles | ||
---|---|---|
/etc/freenetis/freenetis-qos.conf
|
freenetis/branches/1.1/application/vendors/deb/freenetis-qos/config | ||
---|---|---|
#!/bin/sh
|
||
|
||
set -e
|
||
. /usr/share/debconf/confmodule
|
||
|
||
CONFIGFILE=/etc/freenetis/freenetis-qos.conf
|
||
|
||
# Load config file, if it exists.
|
||
if [ -e $CONFIGFILE ]; then
|
||
db_get freenetis-qos/hack_reload
|
||
if [ "$RET" = true ]; then
|
||
. $CONFIGFILE || true
|
||
db_set freenetis-qos/path_freenetis "$PATH_FN"
|
||
db_set freenetis-qos/input_interface "$INPUT_INTERFACE"
|
||
db_set freenetis-qos/output_interface "$OUTPUT_INTERFACE"
|
||
fi
|
||
fi
|
||
|
||
# h@ck for not reloading variables from config file (enabled again by postinst)
|
||
db_set freenetis-qos/hack_reload false
|
||
|
||
# Ask questions.
|
||
db_input critical freenetis-qos/path_freenetis || true
|
||
db_input critical freenetis-qos/input_interface || true
|
||
db_input critical freenetis-qos/output_interface || true
|
||
db_go || true
|
freenetis/branches/1.1/application/vendors/deb/freenetis-qos/postinst | ||
---|---|---|
#!/bin/bash
|
||
# FreenetIS-qos DEB: actions after installing of package
|
||
|
||
set -e
|
||
. /usr/share/debconf/confmodule
|
||
|
||
NAME=freenetis-qos
|
||
CONFIGFILE=/etc/freenetis/freenetis-qos.conf
|
||
|
||
# Quit if config file is missing.
|
||
if [ ! -e $CONFIGFILE ]; then
|
||
echo "$CONFIGFILE not founded!"
|
||
exit 1
|
||
fi
|
||
|
||
url_regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
|
||
|
||
# Substitute in the values from the debconf db.
|
||
# There are obvious optimizations possible here.
|
||
# The cp before the sed ensures we do not mess up
|
||
# the config file’s ownership and permissions.
|
||
|
||
db_get freenetis-qos/path_freenetis
|
||
PATH_FN="$RET"
|
||
|
||
db_get freenetis-qos/input_interface
|
||
INPUT_INTERFACE="$RET"
|
||
|
||
db_get freenetis-qos/output_interface
|
||
OUTPUT_INTERFACE="$RET"
|
||
|
||
# check path
|
||
if [ -z "$PATH_FN" ]; then
|
||
echo "Empty path to FreenetIS instance, configuration failed!"
|
||
exit 3
|
||
fi
|
||
|
||
# check path format
|
||
if [[ ! "$PATH_FN" =~ $url_regex ]]; then
|
||
echo "Wrong format of the path to FreenetIS instance, configuration failed!"
|
||
exit 3
|
||
fi
|
||
|
||
# check input iface
|
||
if [ -z "$INPUT_INTERFACE" ]; then
|
||
echo "Empty input interface, configuration failed!"
|
||
exit 3
|
||
fi
|
||
|
||
# check output iface
|
||
if [ -z "$OUTPUT_INTERFACE" ]; then
|
||
echo "Empty output interface, configuration failed!"
|
||
exit 3
|
||
fi
|
||
|
||
cp -a -f $CONFIGFILE $CONFIGFILE.tmp
|
||
|
||
# If the admin deleted or commented some variables but then set
|
||
# them via debconf, (re-)add them to the conffile.
|
||
|
||
test -z "$PATH_FN" || grep -Eq '^ *PATH_FN=' $CONFIGFILE || echo "PATH_FN=" >> $CONFIGFILE
|
||
test -z "$INPUT_INTERFACE" || grep -Eq '^ *INPUT_INTERFACE=' $CONFIGFILE || echo "INPUT_INTERFACE=" >> $CONFIGFILE
|
||
test -z "$OUTPUT_INTERFACE" || grep -Eq '^ *OUTPUT_INTERFACE=' $CONFIGFILE || echo "OUTPUT_INTERFACE=" >> $CONFIGFILE
|
||
|
||
PATH_FN_ESCAPED="${PATH_FN//\//\\/}"
|
||
INPUT_INTERFACE_ESCAPED="${INPUT_INTERFACE//\//\\/}"
|
||
OUTPUT_INTERFACE_ESCAPED="${OUTPUT_INTERFACE//\//\\/}"
|
||
|
||
sed -e "s/^ *PATH_FN=.*/PATH_FN=\"$PATH_FN_ESCAPED\"/" \
|
||
-e "s/^ *INPUT_INTERFACE=.*/INPUT_INTERFACE=\"$INPUT_INTERFACE_ESCAPED\"/" \
|
||
-e "s/^ *OUTPUT_INTERFACE=.*/OUTPUT_INTERFACE=\"$OUTPUT_INTERFACE_ESCAPED\"/" < $CONFIGFILE > $CONFIGFILE.tmp
|
||
|
||
mv -f $CONFIGFILE.tmp $CONFIGFILE
|
||
|
||
# Make post install things
|
||
|
||
# 1) Rights
|
||
|
||
# set rights
|
||
chmod u+x /etc/init.d/${NAME}
|
||
chmod u+x /usr/sbin/freenetis-qos-sync
|
||
|
||
# 2) Startup at boot
|
||
|
||
# set on fire after boot
|
||
update-rc.d ${NAME} defaults
|
||
|
||
exit 0
|
freenetis/branches/1.1/application/vendors/deb/freenetis-qos/prerm | ||
---|---|---|
#!/bin/sh
|
||
# FreenetIS-qos DEB: actions before uninstalling of package
|
||
|
||
NAME=freenetis-qos
|
||
|
||
# stop daemon
|
||
/etc/init.d/$NAME stop
|
||
|
||
#DEBHELPER#
|
||
|
||
exit 0
|
Také k dispozici: Unified diff
Upravy:
- uplne odstraneni freenetis-qos z hlavniho repozitare, nahrazeno https://github.com/freenetis/freenetis-qos. Dalsi vyvoj bude probihat pouze v novem repozitari.