Revize 1815
Přidáno uživatelem Ondřej Fibich před více než 11 roky(ů)
freenetis/branches/1.1/application/vendors/deb/freenetis-dhcp/control | ||
---|---|---|
Priority: optional
|
||
Section: web
|
||
Pre-Depends: debconf (>= 0.5) | debconf-2.0
|
||
Depends: coreutils, wget, isc-dhcp-server, diffutils
|
||
Suggests: freenetis
|
||
Architecture: all
|
||
Maintainer: Ondrej Fibich <ondrej.fibich@gmail.com>
|
||
Homepage: http://www.freenetis.org
|
||
Description: FreenetIS DHCP server synchronization
|
||
The tool is used for the DHCP server synchronization with data from FreenetIS.
|
||
DHCP server is represented in FreenetIS by the device ID.
|
freenetis/branches/1.1/application/vendors/deb/freenetis-dhcp/freenetis-dhcp.cron | ||
---|---|---|
# /etc/cron.d/freenetis-dhcp: Regular CRON file for freenetis-dhcp package (triggered each minute)
|
||
|
||
SHELL=/bin/sh
|
||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
freenetis/branches/1.1/application/vendors/deb/freenetis-dhcp/postinst | ||
---|---|---|
#!/bin/bash
|
||
# FreenetIS-dhcp DEB: actions after installing of package
|
||
|
||
set -e
|
||
. /usr/share/debconf/confmodule
|
||
|
||
NAME=freenetis-dhcp
|
||
CONFIGFILE=/etc/freenetis/freenetis-dhcp.conf
|
||
|
||
# Quit if config file is missing.
|
||
if [ ! -e $CONFIGFILE ]; then
|
||
echo "$CONFIGFILE not founded!"
|
||
exit 1
|
||
fi
|
||
|
||
. $CONFIGFILE
|
||
|
||
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-dhcp/path_freenetis
|
||
PATH_FN="$RET"
|
||
|
||
db_get freenetis-dhcp/device_id
|
||
DEVICE_ID="$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 device ID
|
||
if [[ ! "$DEVICE_ID" =~ ^[0-9]+$ ]] || [ $DEVICE_ID -lt 1 ]; then
|
||
echo "Wrong configuration (ID not set properly), configuration failed!" 1>&2
|
||
exit 1
|
||
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 "$DEVICE_ID" || grep -Eq '^ *DEVICE_ID=' $CONFIGFILE || echo "DEVICE_ID=" >> $CONFIGFILE
|
||
|
||
PATH_FN_ESCAPED="${PATH_FN//\//\\/}"
|
||
DEVICE_ID_ESCAPED="${DEVICE_ID//\//\\/}"
|
||
|
||
sed -e "s/^ *PATH_FN=.*/PATH_FN=\"$PATH_FN_ESCAPED\"/" \
|
||
-e "s/^ *DEVICE_ID=.*/DEVICE_ID=\"$DEVICE_ID_ESCAPED\"/" < $CONFIGFILE > $CONFIGFILE.tmp
|
||
|
||
mv -f $CONFIGFILE.tmp $CONFIGFILE
|
||
|
||
# Make post install things
|
||
|
||
# 1) Rights
|
||
|
||
# set rights
|
||
chmod u+x /usr/sbin/freenetis-dhcp-sync
|
||
|
||
# 2) CRON
|
||
|
||
echo "Preparing CRON"
|
||
|
||
echo "# /etc/cron.d/freenetis-dhcp: Regular CRON file for freenetis-dhcp package (triggered each minute)" > /etc/cron.d/freenetis-dhcp
|
||
echo "" >> /etc/cron.d/freenetis-dhcp
|
||
echo "SHELL=/bin/sh" >> /etc/cron.d/freenetis-dhcp
|
||
echo "PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" >> /etc/cron.d/freenetis-dhcp
|
||
echo "* * * * * root /usr/sbin/freenetis-dhcp-sync 1>>\"$LOG_FILE\"" >> /etc/cron.d/freenetis-dhcp
|
||
|
||
if [ -x /usr/sbin/invoke-rc.d ]; then
|
||
invoke-rc.d cron restart 3>/dev/null || true
|
||
else
|
||
/etc/init.d/cron restart 3>/dev/null || true
|
||
fi
|
||
|
||
exit 0
|
freenetis/branches/1.1/application/vendors/deb/freenetis-dhcp/postrm | ||
---|---|---|
#!/bin/sh
|
||
# FreenetIS-dhcp DEB: actions before uninstalling of package
|
||
|
||
set -e
|
||
|
||
CONFIGFILE=/etc/freenetis/freenetis-dhcp.conf
|
||
|
||
# remove all configuration if purge
|
||
if [ "$1" = purge ]; then
|
||
# remove defconf values
|
||
if [ -e /usr/share/debconf/confmodule ]; then
|
||
. /usr/share/debconf/confmodule
|
||
db_purge
|
||
fi
|
||
# remove config files
|
||
rm -rf $CONFIGFILE
|
||
# remove dir if empty
|
||
[ "$(ls -A /etc/freenetis)" ] || rm -rf /etc/freenetis
|
||
fi
|
||
|
||
exit 0
|
freenetis/branches/1.1/application/vendors/deb/freenetis-dhcp/config | ||
---|---|---|
#!/bin/sh
|
||
|
||
set -e
|
||
. /usr/share/debconf/confmodule
|
||
|
||
CONFIGFILE=/etc/freenetis/freenetis-dhcp.conf
|
||
|
||
# Load config file, if it exists.
|
||
if [ -e $CONFIGFILE ]; then
|
||
db_get freenetis-dhcp/hack_reload
|
||
if [ "$RET" = true ]; then
|
||
. $CONFIGFILE || true
|
||
db_set freenetis-dhcp/path_freenetis "$PATH_FN"
|
||
db_set freenetis-dhcp/device_id "$DEVICE_ID"
|
||
fi
|
||
fi
|
||
|
||
# h@ck for not reloading variables from config file (enabled again by postinst)
|
||
db_set freenetis-dhcp/hack_reload false
|
||
|
||
# Ask questions.
|
||
db_input critical freenetis-dhcp/path_freenetis || true
|
||
db_input critical freenetis-dhcp/device_id || true
|
||
db_go || true
|
freenetis/branches/1.1/application/vendors/deb/freenetis-dhcp/changelog | ||
---|---|---|
freenetis-dhcp (0.1.0) stable; urgency=low
|
||
* First release
|
||
-- Ondrej Fibich <ondrej.fibich@gmail.com> Wed, 16 Jan 2013 19:29:49 +0100
|
freenetis/branches/1.1/application/vendors/deb/freenetis-dhcp/conffiles | ||
---|---|---|
/etc/freenetis/freenetis-dhcp.conf
|
freenetis/branches/1.1/application/vendors/deb/freenetis-dhcp/debianization.sh | ||
---|---|---|
#!/bin/sh
|
||
################################################################################
|
||
# Script for debianization of FreenetIS DHCP package
|
||
# (c) Ondrej Fibich, 2013
|
||
#
|
||
# Takes one argument (version of package - FreenetIS DHCP).
|
||
#
|
||
################################################################################
|
||
|
||
if [ $# -ne 1 ]; then
|
||
echo "Wrong arg count.. Terminating"
|
||
exit 1
|
||
fi
|
||
|
||
NAME=freenetis-dhcp
|
||
VERSION=$1
|
||
|
||
# create dirs ##################################################################
|
||
mkdir deb_packages/tmp
|
||
cd deb_packages/tmp
|
||
|
||
mkdir DEBIAN
|
||
mkdir etc
|
||
mkdir etc/freenetis
|
||
mkdir etc/cron.d
|
||
mkdir usr
|
||
mkdir usr/sbin
|
||
|
||
# copy content of package ######################################################
|
||
cp ../../../dhcp/freenetis-dhcp-sync.sh usr/sbin/freenetis-dhcp-sync
|
||
cp ../../../dhcp/freenetis-dhcp.conf etc/freenetis/
|
||
cp ../../freenetis-dhcp/freenetis-dhcp.cron etc/cron.d/freenetis-dhcp
|
||
|
||
# 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}/postrm >> DEBIAN/postrm
|
||
cat ../../${NAME}/templates >> DEBIAN/templates
|
||
cat ../../${NAME}/config >> DEBIAN/config
|
||
|
||
chmod +x DEBIAN/postinst DEBIAN/postrm /config
|
||
|
||
# create deb ###################################################################
|
||
|
||
# change owner of files to root (security)
|
||
cd ..
|
||
sudo chown -hR root:root *
|
||
sudo chmod 0644 *
|
||
|
||
# make package
|
||
sudo dpkg-deb -b tmp ${NAME}_${VERSION}_all.deb
|
||
|
||
# clean-up mess ################################################################
|
||
|
||
# clean
|
||
sudo rm -rf tmp
|
||
freenetis/branches/1.1/application/vendors/deb/freenetis-dhcp/templates | ||
---|---|---|
Template: freenetis-dhcp/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-dhcp/device_id
|
||
Type: string
|
||
Default:
|
||
Description: Device ID:
|
||
ID of device from FreenetIS.
|
||
Description-cs.UTF-8: Vstupní rozhraní:
|
||
ID zařízení z FreenetISu.
|
||
|
||
Template: freenetis-dhcp/hack_reload
|
||
Type: boolean
|
||
Default: true
|
||
Description: Hack:
|
||
Hack for propper working of loading package.
|
Také k dispozici: Unified diff
Novinky:
- #458: Vytvorit balik pro aktualizaci DHCP serveru z FreenetISu (implementovano, zbyva otestovat)