From d6c2b034875570e4aae8669b761d7a7f102c86da Mon Sep 17 00:00:00 2001 From: Benjamin Schieder Date: Mon, 4 Apr 2005 09:21:29 +0000 Subject: [PATCH] Benjamin Schieder: write a stone and a rocknet module for ezipupdate change rocknet README to show correct information for dyndns [2005022311102506780] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@5757 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- package/base/sysfiles/rocknet_README | 4 +- package/blindcoder/ezipupdate/ezipupdate.conf | 7 + .../blindcoder/ezipupdate/mod_ezipupdate.sh | 160 ++++++++++++++++++ .../blindcoder/ezipupdate/rocknet_dyndns.sh | 18 ++ .../blindcoder/ezipupdate/stone.conf.template | 19 +++ 5 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 package/blindcoder/ezipupdate/mod_ezipupdate.sh create mode 100644 package/blindcoder/ezipupdate/rocknet_dyndns.sh create mode 100644 package/blindcoder/ezipupdate/stone.conf.template diff --git a/package/base/sysfiles/rocknet_README b/package/base/sysfiles/rocknet_README index c2fbd1e1f..b19baafbf 100644 --- a/package/base/sysfiles/rocknet_README +++ b/package/base/sysfiles/rocknet_README @@ -35,7 +35,9 @@ Or another /etc/network/config: interface eth0 dhcp - script dyndns.sh # update dyndns + dyndns # update dyndns + # requires ezipudate + # and setup in stone allow ip 10.10.0.0/24 # office allow ip 192.168.0.0/24 # home allow tcp 80 # webserver is open diff --git a/package/blindcoder/ezipupdate/ezipupdate.conf b/package/blindcoder/ezipupdate/ezipupdate.conf index 3a4cda31a..c62fa94bb 100644 --- a/package/blindcoder/ezipupdate/ezipupdate.conf +++ b/package/blindcoder/ezipupdate/ezipupdate.conf @@ -23,6 +23,13 @@ ezipupdate_pm() { mkdir -p ${root}/etc/ezipupdate/ cp -v example*conf ${root}/etc/ezipupdate/ + cp -v ${confdir}/stone.conf.template $root/etc/ezipupdate/ + for x in ${root}/etc/ezipupdate/*.conf ; do + sed -e "s,/usr/local/bin,$bindir,g" -i ${x} + chmod +x ${x} + done + cp -v ${confdir}/mod_ezipupdate.sh ${root}/etc/stone.d/ + cp -v ${confdir}/rocknet_dyndns.sh ${root}/etc/network/modules/dyndns.sh } hook_add postmake 4 "ezipupdate_pm" diff --git a/package/blindcoder/ezipupdate/mod_ezipupdate.sh b/package/blindcoder/ezipupdate/mod_ezipupdate.sh new file mode 100644 index 000000000..f32830d30 --- /dev/null +++ b/package/blindcoder/ezipupdate/mod_ezipupdate.sh @@ -0,0 +1,160 @@ +# --- ROCK-COPYRIGHT-NOTE-BEGIN --- +# +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# Please add additional copyright information _after_ the line containing +# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by +# the ./scripts/Create-CopyPatch script. Do not edit this copyright text! +# +# ROCK Linux: rock-src/package/blindcoder/ezipupdate/mod_ezipupdate.sh +# ROCK Linux is Copyright (C) 1998 - 2005 Clifford Wolf +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. A copy of the GNU General Public +# License can be found at Documentation/COPYING. +# +# Many people helped and are helping developing ROCK Linux. Please +# have a look at http://www.rocklinux.org/ and the Documentation/TEAM +# file for details. +# +# --- ROCK-COPYRIGHT-NOTE-END --- +# +# [MAIN] 60 ezipupdate EZ-Ipupdate Configuration (dyndns et al) + +ezipupdate_new_step3 () { + cmd="" + iface="$1" + tos="$2" + gui_input "Please enter the dns name you want to update" "" hostname + gui_input "Please enter the username for $hostname" "" user + gui_input "Please enter the password for $hostname" "" pass + gui_input "Please enter the MX record for $hostname" "$hostname" mx + gui_input "Please enter the number of times the update should be tried" 3 retries + gui_input "Please enter the mail-address errors should be reported to" "root@localhost" errorsto + gui_input "Please enter the period to check if the IP-address changed in seconds" 1800 checkperiod + gui_yesno "Do you want wildcard dnsnames? (*.$hostname would all resolve to your current IP-Address)" + wildcard=$? + cmd="-e 's,INTERFACE,$iface,g'" + cmd="$cmd -e 's,SERVICETYPE,$tos,g'" + cmd="$cmd -e 's,HOSTNAME,$hostname,g'" + cmd="$cmd -e 's,USER,$user,g'" + cmd="$cmd -e 's,PASS,$pass,g'" + cmd="$cmd -e 's,MXADDRESS,$mx,g'" + cmd="$cmd -e 's,RETRIES,$retries,g'" + cmd="$cmd -e 's,EMAILADDRESS,$errorsto,g'" + cmd="$cmd -e 's,PERIOD,$checkperiod,g'" + [ $wildcard -eq 1 ] && cmd="$cmd -e 's,wildcard,# nowildcard,g'" + eval "sed $cmd /etc/ezipupdate/stone.conf.template > /etc/ezipupdate/stone.$iface" +} + +ezipupdate_new_step2 () { + cmd="" + iface="$1" + for x in ezip pgpow dhs dyndns dyndns-static dyndns-custom ods tzo \ + easydns easydns-partner gnudip justlinux dyns hn zoneedit \ + heipv6tb ; do + cmd="$cmd '$x' 'ezipupdate_new_step3 $iface $x'" + done + eval "gui_menu ezipupdate_new_step2 'Please select the type of service' $cmd" +} + +ezipupdate_new_step1 () { + cmd="" + while read iface ; do + [ -f /etc/ezipupdate/stone.$iface ] && continue + cmd="$cmd '$iface' 'ezipupdate_new_step2 $iface'" + done < <( grep interface /etc/network/config | cut -f 2 -d\ | cut -f1 -d\( | sort ) + eval "gui_menu ezipupdate_new_step1 'Please select the interface to use' $cmd" +} + +ezipupdate_change_tos () { + cmd="" + for x in ezip pgpow dhs dyndns dyndns-static dyndns-custom ods tzo \ + easydns easydns-partner gnudip justlinux dyns hn zoneedit \ + heipv6tb ; do + cmd="$cmd '$x' 'tos=$x'" + done + eval "gui_menu ezipupdate_change_tos 'Please select the new type of service' $cmd" +} + +ezipupdate_change_wildcard () { + gui_yesno "Do you want wildcard dnsnames? (*.$hostname would all resolve to your current IP-Address)" + case "$?" in + 1) wildcard=0 ; ;; + 0) wildcard=1 ; ;; + esac +} + +ezipdate_change_iface () { + cmd="" + while read i ; do + [ -f /etc/ezipupdate/stone.$i -a $i != $oldiface ] && continue + cmd="$cmd '$i' 'iface=$i'" + done < <( grep interface /etc/network/config | cut -f 2 -d\ | cut -f1 -d\( | sort ) + eval "gui_menu ezipupdate_change_iface 'Please select the new interface to use' $cmd" +} +ezipupdate_edit () { + iface=$1 + oldiface=$1 + conf=/etc/ezipupdate/stone.$iface + tos="`grep ^service-type $conf | cut -f2 -d=`" + hostname="`grep ^host $conf | cut -f2 -d=`" + IFS=":" read user pass < <( grep ^user $conf | cut -f2 -d= ) + mx="`grep ^mx $conf | cut -f2 -d=`" + retries="`grep ^retrys $conf | cut -f2 -d=`" + errorsto="`grep ^notify-email $conf | cut -f2 -d=`" + checkperiod="`grep ^period $conf | cut -f2 -d=`" + wildcard=`grep -c ^wildcard $conf` + + run=0 + while [ $run -eq 0 ] ; do + yesno="yes" + [ $wildcard -eq 0 ] && yesno="no" + gui_menu "ezipupdate_edit" "EZ-IPUpdate settings for $iface" \ + "Type of service: $tos" "ezipupdate_change_tos" \ + "Interface to check: $iface" "ezipdate_change_iface" \ + "Hostname: $hostname" "gui_input 'Enter new hostname' '$hostname' hostname" \ + "Username: $user" "gui_input 'Enter new username' '$user' user" \ + "Password: $pass" "gui_input 'Enter new password' '$pass' pass" \ + "MX-Record: $mx" "gui_input 'Enter new MX-Record' '$mx' mx" \ + "Retries: $retries" "gui_input 'Enter new number of retries' '$retries' retries" \ + "Report errors to: $errorsto" "gui_input 'Enter new mail address to report errors to' '$errorsto' errorsto" \ + "Checking period in seconds: $checkperiod" "gui_input 'Enter new period to check if IP-address changed in seconds' '$checkperiod' checkperiod" \ + "Wildcard DNS: $yesno" "ezipupdate_change_wildcard" + run=$? + done + rm -f /etc/ezipupdate/stone.$oldiface + cmd="-e 's,INTERFACE,$iface,g'" + cmd="$cmd -e 's,SERVICETYPE,$tos,g'" + cmd="$cmd -e 's,HOSTNAME,$hostname,g'" + cmd="$cmd -e 's,USER,$user,g'" + cmd="$cmd -e 's,PASS,$pass,g'" + cmd="$cmd -e 's,MXADDRESS,$mx,g'" + cmd="$cmd -e 's,RETRIES,$retries,g'" + cmd="$cmd -e 's,EMAILADDRESS,$errorsto,g'" + cmd="$cmd -e 's,PERIOD,$checkperiod,g'" + [ $wildcard -eq 0 ] && cmd="$cmd -e 's,wildcard,# nowildcard,g'" + eval "sed $cmd /etc/ezipupdate/stone.conf.template > /etc/ezipupdate/stone.$iface" +} + +main() { + run=0 + while [ $run -eq 0 ] ; do + cmd="" + for conf in /etc/ezipupdate/stone.* ; do + [ -f $conf ] || continue + [ "$conf" == "/etc/ezipupdate/stone.conf.template" ] && continue + interface="`grep 'interface=' $conf | cut -f2 -d=`" + if [ -z "$interface" ] ; then + gui_message "Bogus interface configuration: $interface! Please edit $conf manually!" + continue + fi + cmd="$cmd 'Edit interface $interface' 'ezipupdate_edit $interface'" + done + cmd="$cmd 'Add new interface' 'ezipupdate_new_step1'" + eval "gui_menu ezipupdate 'EZ-Ipupdate Configuration' $cmd" + run=$? + done +} + diff --git a/package/blindcoder/ezipupdate/rocknet_dyndns.sh b/package/blindcoder/ezipupdate/rocknet_dyndns.sh new file mode 100644 index 000000000..6cd323b1c --- /dev/null +++ b/package/blindcoder/ezipupdate/rocknet_dyndns.sh @@ -0,0 +1,18 @@ +public_dyndns() { + addcode up 5 5 "dyndns_start $if" + addcode down 5 5 "dyndns_stop $if" +} + +dyndns_start () { + if=$1 + [ ! -f /etc/ezipupdate/stone.$if ] && \ + error "$if not configured for ez-ipupdate usage! Run \`stone' first!" + ez-ipupdate -F /var/run/ez-ipupdate.$if.pid -c /etc/ezipupdate/stone.$if +} +dyndns_stop () { + if=$1 + [ ! -f /etc/ezipupdate/stone.$if ] && \ + error "$if not configured for ez-ipupdate usage! Run \`stone' first!" + kill -QUIT `cat /var/run/ez-ipupdate.$if.pid` + rm -f /var/run/ez-ipupdate.$if.pid +} diff --git a/package/blindcoder/ezipupdate/stone.conf.template b/package/blindcoder/ezipupdate/stone.conf.template new file mode 100644 index 000000000..4e2dbfd98 --- /dev/null +++ b/package/blindcoder/ezipupdate/stone.conf.template @@ -0,0 +1,19 @@ +#!/usr/bin/ez-ipupdate -c +# +# ezipupdate INTERFACE configuration used by stone +# do not edit by hand! Use `stone' instead! +# + +service-type=SERVICETYPE +user=USER:PASS +interface=INTERFACE +host=HOSTNAME + +cache-file=/var/cache/ez-ipupdate.cache.INTERFACE +mx=MXADDRESS +retrys=RETRIES +notify-email=EMAILADDRESS +period=PERIOD +wildcard +daemon +