Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1604

Přidáno uživatelem Ondřej Fibich před asi 12 roky(ů)

commit nedokonceneho baliku k presmerovani

Zobrazit rozdíly:

freenetis/branches/testing/application/vendors/deb/freenetis/postinst
fi
# pre-configure protocol
sed -e "s/^ *\$config\['protocol'\] *=/\$config['protocol'] = '$PROTOCOL';/" < $CONFIG_SAMPLE_PHP > $CONFIG_SAMPLE_PHP.tmp
sed -e "s/^ *\$config\['protocol'\] *=.*/\$config['protocol'] = '$PROTOCOL';/" < $CONFIG_SAMPLE_PHP > $CONFIG_SAMPLE_PHP.tmp
mv -f $CONFIG_SAMPLE_PHP.tmp $CONFIG_SAMPLE_PHP
# restart
freenetis/branches/testing/application/vendors/deb/freenetis-redirection/control
Priority: optional
Section: web
Pre-Depends: debconf (>= 0.5) | debconf-2.0
Depends: ipset, lighttpd
Suggests: freenetis
Architecture: all
Maintainer: Ondrej Fibich <ondrej.fibich@gmail.com>
Homepage: http://www.freenetis.org
Description: FreenetIS redirection:
FreenetIS redirection is system which depends on FreenetIS and it is used for
restriction of traffic. The restrictions may be applicated on clouds,
subnets, members and single IP address.
freenetis/branches/testing/application/vendors/deb/freenetis-redirection/postinst
#!/bin/bash
# FreenetIS-redir-qos DEB: actions after installing of package
set -e
. /usr/share/debconf/confmodule
NAME=freenetis-redirection
CONFIGFILE=/etc/freenetis/freenetis-redirection.conf
LIGHTTPD_CONFIGFILE=/etc/lighttpd/lighttpd.conf
# Quit if config file is missing.
if [ ! -e $CONFIGFILE ]; then
echo "$CONFIGFILE not founded!"
exit 1
fi
ip_regex='^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'
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-redirection/path_freenetis
PATH_FN="$RET"
db_get freenetis-redirection/input_interface
INPUT_INTERFACE="$RET"
db_get freenetis-redirection/self_cancel_target_ip
IP_TARGET="$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 IP target
if [ -z "$IP_TARGET" ]; then
echo "Empty target IP for self-canceling, configuration failed!"
exit 3
fi
# check IP target format
if [[ ! "$IP_TARGET" =~ $ip_regex ]]; then
echo "Wrong format of the target IP for self-canceling, 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 "$IP_TARGET" || grep -Eq '^ *IP_TARGET=' $CONFIGFILE || echo "IP_TARGET=" >> $CONFIGFILE
PATH_FN_ESCAPED="${PATH_FN//\//\\/}"
INPUT_INTERFACE_ESCAPED="${INPUT_INTERFACE//\//\\/}"
IP_TARGET_ESCAPED="${IP_TARGET//\//\\/}"
sed -e "s/^ *PATH_FN=.*/PATH_FN=\"$PATH_FN_ESCAPED\"/" \
-e "s/^ *INPUT_INTERFACE=.*/INPUT_INTERFACE=\"$INPUT_INTERFACE_ESCAPED\"/" \
-e "s/^ *IP_TARGET=.*/IP_TARGET=\"$IP_TARGET_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-redirection-sync
# 2) Lighttpd
# configure lighttpd ###########################################################
cp -a -f $LIGHTTPD_CONFIGFILE $LIGHTTPD_CONFIGFILE.tmp
# bacup
cp -a -f $LIGHTTPD_CONFIGFILE $LIGHTTPD_CONFIGFILE.before_fn_install
# port redirect from
test -z "$PORT_REDIRECT" || grep -Eq '^ *server.port *=' $LIGHTTPD_CONFIGFILE || echo "server.port=" >> $LIGHTTPD_CONFIGFILE
PORT_REDIRECT_ESCAPED="${PORT_REDIRECT//\//\\/}"
sed -e "s/^ *server.port *=.*/server.port=\"$PORT_REDIRECT_ESCAPED\"/" < $LIGHTTPD_CONFIGFILE > $LIGHTTPD_CONFIGFILE.tmp
# append other config
# set config
mv -f $LIGHTTPD_CONFIGFILE.tmp $LIGHTTPD_CONFIGFILE
# restart
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d lighttpd restart 3>/dev/null || true
else
/etc/init.d/lighttpd restart 3>/dev/null || true
fi
# 3) Startup at boot
# set on fire after boot
update-rc.d ${NAME} defaults
exit 0
freenetis/branches/testing/application/vendors/deb/freenetis-redirection/postrm
#!/bin/sh
# FreenetIS DEB: actions before uninstalling of package
set -e
. /usr/share/debconf/confmodule
NAME=freenetis-redirection
CONFIGFILE=/etc/freenetis/freenetis-redirection.conf
LIGHTTPD_CONFIGFILE=/etc/lighttpd/lighttpd.conf
# get lighttpd configuration to previous state
if [ -f "$LIGHTTPD_CONFIGFILE.before_fn_install" ]; then
mv $LIGHTTPD_CONFIGFILE.before_fn_install $LIGHTTPD_CONFIGFILE
fi
# disable startup from update-rc.d
update-rc.d -f ${NAME} remove
# 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#
freenetis/branches/testing/application/vendors/deb/freenetis-redirection/config
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
CONFIGFILE=/etc/freenetis/freenetis-redirection.conf
# Load config file, if it exists.
if [ -e $CONFIGFILE ]; then
. $CONFIGFILE || true
db_get freenetis-redirection/hack_reload
if [ "$RET" = true ]; then
db_set freenetis-redirection/path_freenetis "$PATH_FN"
db_set freenetis-redirection/input_interface "$INPUT_INTERFACE"
db_set freenetis-redirection/self_cancel_target_ip "$IP_TARGET"
fi
fi
# h@ck for not reloading variables from config file (enabled again by postinst)
db_set freenetis-redirection/hack_reload false
# Ask questions.
db_input critical freenetis-redirection/path_freenetis || true
db_input critical freenetis-redirection/input_interface || true
db_input critical freenetis-redirection/self_cancel_target_ip || true
db_go || true
freenetis/branches/testing/application/vendors/deb/freenetis-redirection/prerm
#!/bin/sh
# FreenetIS-redirection DEB: actions before uninstalling of package
NAME=freenetis-redirection
# stop daemon
/etc/init.d/$NAME stop
#DEBHELPER#
exit 0
freenetis/branches/testing/application/vendors/deb/freenetis-redirection/changelog
freenetis-redirection (1.9.0) unstable; urgency=low
* First release
-- Ondrej Fibich <ondrej.fibich@gmail.com> Tue, 07 Aug 2012 15:05:33 +0200
freenetis/branches/testing/application/vendors/deb/freenetis-redirection/conffiles
/etc/freenetis/freenetis-redirection.conf
freenetis/branches/testing/application/vendors/deb/freenetis-redirection/debianization.sh
#!/bin/sh
################################################################################
# Script for debianization of FreenetIS redirection and QoS package
# (c) Ondrej Fibich, 2012
#
# Takes two arguments (version of package - FreenetIS).
#
################################################################################
if [ $# -ne 1 ]; then
echo "Wrong arg count.. Terminating"
exit 1
fi
NAME=freenetis-redirection
VERSION=$1
# 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 ../../../redirection/freenetis-redirection.init.sh etc/init.d/${NAME}
cp ../../../redirection/freenetis-redirection-sync.sh usr/sbin/freenetis-redirection-sync
cp ../../../redirection/freenetis-redirection.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/control
echo "Installed-Size: ${SIZE}" >> DEBIAN/control
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/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}_all.deb
# clean-up mess ################################################################
# clean
sudo rm -rf tmp
freenetis/branches/testing/application/vendors/deb/freenetis-redirection/templates
Template: freenetis-redirection/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-redirection/input_interface
Type: string
Default: eth0
Description: Input interface:
Input interface on which redirection rules are applicated on.
Description-cs.UTF-8: Vstupní rozhraní:
Vstupní rozhraní, na které jsou aplikována pravidla přesměrování a QoS download.
Template: freenetis-redirection/self_cancel_target_ip
Type: string
Default:
Description: Self cancel IP:
IP address which is use for self-canceling of the redirection directly by a redirected member.
Description-cs.UTF-8: IP adresa samozrušení
IP adresa, která je použita pro samozrušení přesměrování přesměrovaným členem.
Template: freenetis-redirection/hack_reload
Type: boolean
Default: true
Description: Hack:
Hack for propper working of loading package.

Také k dispozici: Unified diff