From: Guus Sliepen Date: Fri, 29 Jun 2001 15:33:18 +0000 (+0000) Subject: Update of RedHat build scripts. X-Git-Tag: import-tinc-1.1~785^2~502 X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=748dabdbe93f7439ed7eddf491a556279250e7ac;p=meshlink Update of RedHat build scripts. --- diff --git a/Makefile.am b/Makefile.am index c8cc84cd..85c2c186 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,7 +17,7 @@ ChangeLog: cvs2cl -U cvsusers --fsf cvs-clean: maintainer-clean - for f in $(CVS_CREATED) `find -name Makefile.in` ; do\ + for f in $(CVS_CREATED) `find -name Makefile.in` tinc-$(VERSION).tar.gz; do\ rm -Rf "$$f"; \ done @@ -27,8 +27,7 @@ deb: rpm: dist cp $(distdir).tar.gz /usr/src/redhat/SOURCES/ cp redhat/tinc.spec /usr/src/redhat/SOURCES/ - cd /usr/src/redhat/SOURCES/ - rpm -bi tinc.spec + cd /usr/src/redhat/SOURCES/ && rpm -bb tinc.spec release: rm -f ChangeLog diff --git a/redhat/tinc b/redhat/tinc index d3a34dd7..9fce4174 100644 --- a/redhat/tinc +++ b/redhat/tinc @@ -39,18 +39,6 @@ if [ ! -x $TINCD ]; then exit fi -# Check if ip-route is installed -if [ ! -f /sbin/ip ]; then - echo "**tinc: ip-route utilities not installed!" >&2 - exit -fi - -# Check the kernel -if ! ip addr &> /dev/null; then - echo "**tinc: kernel not configured for use with ip-route!" >&2 - exit -fi - # Check the configuration directory if [ ! -d $TCONF ]; then echo "**tinc: configuration directory ($TCONF) not found!" >&2 @@ -67,166 +55,15 @@ fi NETS="$(sed -e 's/#.*//; s/[[:space:]]//g; /^$/ d' $NETSFILE)" -############################################################################## -# prefix_to_mask Converts prefix length to netmask -# eg. 17 -> 255.255.128.0 -# $1 ... prefix - -prefix_to_mask () { - _MSK=""; _len="$1" - for _dot in "." "." "." " "; do - if [ ${_len} -ge 8 ]; then - _fld=8 - else - _fld="${_len}" - fi - - _MSK="${_MSK}$((255 & (255 << (8 - _fld))))${_dot}" - _len=$((_len - _fld)) - done - - echo ${_MSK} -} - - -############################################################################## -# mask_to_prefix Converts netmask to prefix length -# eg. 255.255.192.0 -> 18 -# $1 ... netmask - -mask_to_prefix () { - _LEN=0; _msk="$1" - for _tmp in 1 2 3 4; do - _fld=${_msk%%.*} - _msk=${_msk#*.} - - while [ ${_fld} -ne 0 ]; do - _fld=$(((_fld << 1) & 255)) - _LEN=$((_LEN + 1)) - done - done - - echo ${_LEN} -} - - -############################################################################## -# vpn_load () Loads VPN configuration -# -# $1 ... VPN to load - -vpn_load () { - CFG="$TCONF/$1/tinc.conf" - [ -f $CFG ] || { MSG="$CFG does not exist!"; return 1; } - - # load TINCD config - DEV="$(grep -i -e '^[[:space:]]*TapDevice' $CFG | sed 's/[[:space:]]//g; s/^.*=//g')" - VPN="$(grep -i -e '^[[:space:]]*(MyOwnVPNIP|MyVirtualIP)' -E $CFG | sed 's/[[:space:]]//g; s/^.*=//g')" - IFM="$(grep -i -e '^[[:space:]]*VPNMask' $CFG | sed 's/[[:space:]]//g; s/^.*=//g')" - - # TapDevice syntax validation - [ -z "$DEV" ] && \ - { MSG="TapDevice required!"; return 1; } - [ $(echo $DEV | wc -l) -gt 1 ] && \ - { MSG="multiple TapDevice entries not allowed!"; return 1; } - echo $DEV | grep -q -x -E '/dev/tap[[:digit:]]+' || - { MSG="TapDevice should be in form /dev/tapX!"; return 1; } - - # MyOwnVPNIP/MyVirtualIP syntax validation - [ -z "$VPN" ] && \ - { MSG="MyOwnVPNIP/MyVirtualIP required!"; return 1; } - [ $(echo $VPN | wc -l) -gt 1 ] && \ - { MSG="multiple MyOwnVPNIP/MyVirtualIP entries not allowed!"; return 1; } - echo $VPN | grep -q -x -E \ - '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}/[[:digit:]]{1,2}' || \ - { MSG="badly formed MyOwnVPNIP/MyVirtualIP address $VPN!"; return 1; } - - # VPNMask syntax validation - [ $(echo $IFM | wc -l) -gt 1 ] && \ - { MSG="multiple VPNMask entries not allowed!"; return 1; } - - - # device & IP address extraction - TAP=${DEV##*/} - NUM=${TAP#tap} - ADR=${VPN%%/*} - - # netmask is calculated from MyVirtualIP netmask prefix length, except when - # VPNMask is specified, in which case it is used instead of default prefix - - # VPNMask not specified - if [ -z "$IFM" ]; then - LEN=${VPN##*/} - MSK=$(prefix_to_mask $LEN) - - # VPNMask is prefix length, convert it to netmask for MSK - elif echo $IFM | grep -q -x -E '[[:digit:]]{1,2}'; then - VPN="$ADR/$IFM" - MSK=$(prefix_to_mask $IFM) - - # VPNMask is netmask, convert it to prefix length for VPN - elif echo $IFM | grep -q -x -E '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}'; then - VPN="$ADR/$(mask_to_prefix $IFM)" - MSK="$IFM" - - else - MSG="badly formed interface netmask (VPNMask=$IFM)!" - return 1 - fi - - - # Network & broadcast addresses - BRD=$(ipcalc --broadcast $ADR $MSK | cut -d"=" -f2) - NET=$(ipcalc --network $ADR $MSK | cut -d"=" -f2) - - # MAC address - MAC=$(printf "fe:fd:%0.2x:%0.2x:%0.2x:%0.2x" $(echo $ADR | { IFS=. ; read a b c d; echo $a $b $c $d; })) - - # debugging - # echo >&2 - # echo "VPN $VPN TAP $TAP NUM $NUM MAC $MAC IFM $IFM" >&2 - # echo "ADR $ADR MSK $MSK NET $NET BRD $BRD" >&2 - - return 0 -} - - ############################################################################## # vpn_start () starts specified VPN # # $1 ... VPN to start vpn_start () { - MSG=""; ERR="" - vpn_load $1 || return 1 - - # create device file - if [ ! -c $DEV ]; then - [ -e $DEV ] && rm -f $DEV - mknod --mode=0600 $DEV c 36 $((16 + NUM)) - fi - - # load device module - ERR="$(insmod ethertap -o "ethertap$NUM" unit="$NUM" 2>&1 1> /dev/null)" || - { MSG="could not insmod ethertap as unit $NUM!"; return 2; } - - # configure the interface - ERR="$(ip link set $TAP address $MAC 2>&1)" || - { MSG="could not set address for device $TAP!"; return 3; } - - ERR="$(ip link set $TAP up 2>&1)" || - { MSG="could not bring up device $TAP!"; return 3; } - - ERR="$(ip addr add $VPN brd $BRD dev $TAP 2>&1)" || - { MSG="could not set IP address for device $TAP!"; return 3; } - # start tincd $TINCD --net="$1" $DEBUG || \ { MSG="could not start daemon for network $1"; return 3; } - - # setup custom static routes - /etc/sysconfig/network-scripts/ifup-routes $TAP - return 0 } # vpn_start @@ -237,9 +74,6 @@ vpn_start () { # $1 ... VPN to stop vpn_stop () { - MSG=""; ERR="" - vpn_load $1 || return 1 - # kill the tincd daemon PID="$TPIDS/tinc.$1.pid" if [ -f $PID ]; then @@ -257,14 +91,6 @@ vpn_stop () { # remove stale PID file [ -f $PID ] && rm -f $PID fi - - # bring the interface down - ip addr flush dev $TAP &> /dev/null - ip link set $TAP down &> /dev/null - - # remove ethertap module - rmmod "ethertap$NUM" &> /dev/null - return 0 } # vpn_stop diff --git a/redhat/tinc.spec b/redhat/tinc.spec index e5dfb76f..b7357d93 100644 --- a/redhat/tinc.spec +++ b/redhat/tinc.spec @@ -1,13 +1,14 @@ Summary: tinc Virtual Private Network daemon Name: tinc -Version: 1.0pre3 -Release: 1 +Version: 1.0 +Release: cvs Copyright: GPL Group: System Environment/Daemons URL: http://tinc.nl.linux.org/ -Source0: %{name}-%{version}.tar.gz -Buildroot: /var/tmp/%{name}-%{version}-%{release} -Requires: iproute +Source0: %{name}-%{version}-%{release}.tar.gz +Buildroot: /var/tmp/%{name} +#-%{version}-%{release} +#Requires: iproute # for building the package the following is required: # /usr/bin/texi2html /usr/bin/patch @@ -27,10 +28,10 @@ See http://tinc.nl.linux.org/ %prep -%setup -q -n %{name}-%{version} +%setup -q -n %{name}-%{version}-%{release} %build -./configure --prefix=/usr --sysconfdir=/etc +./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var make /usr/bin/texi2html doc/tinc.texi @@ -42,29 +43,8 @@ gzip $RPM_BUILD_ROOT/usr/info/tinc.info mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d/ cp redhat/tinc $RPM_BUILD_ROOT/etc/rc.d/init.d/ -ME=my.vpn.ip.number -PEER=peer.vpn.ip.number -PEEREAL=peer.real.ip.number - -umask 077 -mkdir -p $RPM_BUILD_ROOT/etc/tinc/$PEER/passphrases -cat <$RPM_BUILD_ROOT/etc/tinc/$PEER/tinc.conf -# Sample tinc configuration. -# Insert your own ip numbers instead of the placeholders, -# and be sure to use your own passphrases. -# See man tinc.conf(5) tincd(8) genauth(8), info tinc and -# /usr/doc/%{name}-%{version}/tinc.conf.sample -TapDevice = /dev/tap0 -ConnectTo = $PEEREAL -MyVirtualIP = $ME/32 -AllowConnect = no -END -cat <$RPM_BUILD_ROOT/etc/tinc/$PEER/passphrases/local -1024 c1da5b633b428d783fec96ac89bb6bd4ed97ac673942706ba2240cde977158b7cd5f4055b7db70a7365d1f8df6a1a7c9dbb73f4e2bf8484fc14aee68d0f950e2bce82dd2a6386f040546a61e77cd1c25265ce03182e4e2c9a00ae0ea2f1f89ac04a10f7b67312187b5d2d74618803974ba6f053116b1460bc194c652dc28c84a -END -cat <$RPM_BUILD_ROOT/etc/tinc/$PEER/passphrases/$PEER -1024 9dff58799827c3ae73699d9d4029cf80ee4cfd3a8408495cdb68c78dec602c46f362aedeea80928384254bc7d0bfbf9756c0783b5ec9943161863530a8861947147d124286e8c46fd98af988c96ba65c63acefc01f6c03b6b8f7d9897acb02c083adb7416ee5ccbc19610a8b9ade2599d8f66e94c715f2e1a15054a78a3f3260 -END +mkdir -p $RPM_BUILD_ROOT/etc/tinc/ +touch $RPM_BUILD_ROOT/etc/tinc/nets.boot %clean rm -rf $RPM_BUILD_ROOT @@ -92,6 +72,7 @@ grep -q '^alias tap0' /etc/conf.modules || cat >> /etc/conf.modules << END # tinc uses ethertap/netlink alias tap0 ethertap alias char-major-36 netlink_dev +alias char-major-10-200 tun END /sbin/install-info /usr/info/tinc.info.gz /usr/info/dir @@ -101,13 +82,10 @@ END %postun %files -%doc AUTHORS ChangeLog NEWS README THANKS *.html doc/tinc.conf.sample +%doc AUTHORS ChangeLog NEWS README THANKS *.html %config /etc/tinc/ %attr(0755,root,root) /etc/rc.d/init.d/tinc -/usr/sbin/genauth /usr/sbin/tincd -/usr/lib/tinc/ /usr/man/man5/tinc.conf.5 -/usr/man/man8/genauth.8 /usr/man/man8/tincd.8 /usr/info/tinc.info.gz