This adds an init file for tinc. It is mostly based on
http://wiki.freifunk.net/Tinc#Startscript_Kamikaze, i just changed how
the nets from nets.boot are parsed and removed loading of the tun module.

It also adds /etc/tinc to the list of config files which should be
preserved when upgrading with sysupgrade.

Please consider adding these changes to backfire, too.

Regards, Manuel

Signed-off-by: Manuel Munz <freif...@somakoma.de>
Index: net/tinc/files/tinc.init
===================================================================
--- net/tinc/files/tinc.init	(Revision 0)
+++ net/tinc/files/tinc.init	(Revision 0)
@@ -0,0 +1,60 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+START=62
+
+DAEMON="/usr/sbin/tincd"
+NAME="tinc"
+DESC="tinc daemons"
+TCONF="/etc/tinc"
+NETSFILE="$TCONF/nets.boot"
+NETS=""
+
+find_nets () {
+	if [ ! -f $NETSFILE ] ; then
+		echo "**tinc: file with list of VPNs to start ($NETSFILE) not found!"
+		exit 0
+	fi
+	NETS="`grep -v '^#' $NETSFILE`"
+}
+
+start () {
+	find_nets
+	echo -n "Starting $DESC:"
+	for n in $NETS ; do
+		echo -n " $n"
+		$DAEMON -n $n $EXTRA
+	done
+	echo "."
+}
+
+stop() {
+	find_nets
+	echo -n "Stopping $DESC:"
+	for n in $NETS ; do
+		echo -n " $n"
+		$DAEMON -n $n $EXTRA -k
+	done
+	echo "."
+}
+
+restart () {
+	find_nets
+	echo -n "Restarting $DESC:"
+	for n in $NETS ; do
+		echo -n " $n"
+		$DAEMON -n $n $EXTRA -k
+		sleep 1
+		$DAEMON -n $n $EXTRA
+	done
+	echo "."
+}
+
+reload () {
+	find_nets
+	echo -n "Reloading $DESC configuration:"
+	for n in $NETS ; do
+		echo -n " $n"
+		$DAEMON -n $n $EXTRA -kHUP
+	done
+	echo "."
+}
Index: net/tinc/files/etc/tinc/nets.boot
===================================================================
--- net/tinc/files/etc/tinc/nets.boot	(Revision 0)
+++ net/tinc/files/etc/tinc/nets.boot	(Revision 0)
@@ -0,0 +1 @@
+## This file contains all names of the networks to be started on system startup.
Index: net/tinc/Makefile
===================================================================
--- net/tinc/Makefile	(Revision 28753)
+++ net/tinc/Makefile	(Arbeitskopie)
@@ -30,6 +30,28 @@
   SUBMENU:=VPN
 endef
 
+define Package/tinc/conffiles
+/etc/tinc
+endef
+
+define Package/tinc/postinst
+#!/bin/sh
+if [ -z "$${IPKG_INSTROOT}" ]; then
+	echo "Enabling rc.d symlink for tinc"
+	/etc/init.d/tinc enable
+fi
+exit 0
+endef
+
+define Package/tinc/prerm
+#!/bin/sh
+if [ -z "$${IPKG_INSTROOT}" ]; then
+	echo "Removing rc.d symlink for tinc"
+	/etc/init.d/tinc disable
+fi
+exit 0
+endef
+
 define Package/tinc/description
   tinc is a Virtual Private Network (VPN) daemon that uses tunnelling and
   encryption to create a secure private network between hosts on the Internet.
@@ -45,6 +67,10 @@
 define Package/tinc/install
 	$(INSTALL_DIR) $(1)/usr/sbin
 	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tincd $(1)/usr/sbin/
+	$(INSTALL_DIR) $(1)/etc/init.d
+	$(INSTALL_BIN) ./files/tinc.init $(1)/etc/init.d/tinc
+	$(INSTALL_DIR) $(1)/etc/tinc
+	$(INSTALL_DATA) ./files/etc/tinc/nets.boot $(1)/etc/tinc/nets.boot
 endef
 
 $(eval $(call BuildPackage,tinc))

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to