etc/rc.d/helper/getdnsfromdhcpc.pl
etc/rc.d/helper/writeipac.pl
#etc/rc.d/init.d
+etc/rc.d/init.d/alfred
#etc/rc.d/init.d/alsa
#etc/rc.d/init.d/amavisd
etc/rc.d/init.d/apache
etc/rc.d/init.d/dhcp
etc/rc.d/init.d/dhcrelay
etc/rc.d/init.d/dnsmasq
+etc/rc.d/init.d/fastd
etc/rc.d/init.d/fcron
#etc/rc.d/init.d/fetchmail
etc/rc.d/init.d/fireinfo
#etc/rc.d/init.d/lcdproc
#etc/rc.d/init.d/lcr
etc/rc.d/init.d/leds
+etc/rc.d/init.d/lib-freifunk
etc/rc.d/init.d/localnet
etc/rc.d/init.d/mISDN
#etc/rc.d/init.d/mediatomb
etc/rc.d/helper/writeipac.pl
#etc/rc.d/init.d
etc/rc.d/init.d/acpid
+etc/rc.d/init.d/alfred
#etc/rc.d/init.d/alsa
#etc/rc.d/init.d/amavisd
etc/rc.d/init.d/apache
etc/rc.d/init.d/dhcp
etc/rc.d/init.d/dhcrelay
etc/rc.d/init.d/dnsmasq
+etc/rc.d/init.d/fastd
etc/rc.d/init.d/fcron
#etc/rc.d/init.d/fetchmail
etc/rc.d/init.d/fireinfo
#etc/rc.d/init.d/lcdproc
#etc/rc.d/init.d/lcr
etc/rc.d/init.d/leds
+etc/rc.d/init.d/lib-freifunk
etc/rc.d/init.d/localnet
etc/rc.d/init.d/mISDN
#etc/rc.d/init.d/mediatomb
print FILE "# Hooks\n";
foreach my $hook ("pre-up", "up") {
- print FILE "on $hook \"/etc/rc.d/init.d/freifunk on-$hook\";\n";
+ print FILE "on $hook \"/etc/init.d/fastd on-$hook\";\n";
}
close(FILE);
--- /dev/null
+#!/bin/sh
+########################################################################
+# Begin $rc_base/init.d/alfred
+#
+# Description : alfred initscript
+#
+########################################################################
+
+. /etc/sysconfig/rc
+. ${rc_functions}
+
+. /etc/rc.d/init.d/lib-freifunk
+
+case "${1}" in
+ start)
+ # Do nothing if Freifunk is not enabled
+ freifunk_is_enabled || exit 0
+
+ boot_mesg "Starting A.L.F.R.E.D. on ${FREIFUNK_BRIDGE}..."
+
+ # Enable IPv6 (for multicasts) on the bridge interface
+ freifunk_ipv6_enable "${FREIFUNK_BRIDGE}"
+
+ /usr/sbin/alfred -i "${FREIFUNK_BRIDGE}" &>/dev/null &
+ evaluate_retval
+ ;;
+
+ stop)
+ boot_mesg "Stopping A.L.F.R.E.D. on ${FREIFUNK_BRIDGE}..."
+ killproc /usr/sbin/alfred
+ ;;
+
+ restart)
+ ${0} stop
+ sleep 1
+ ${0} start
+ ;;
+
+ status)
+ statusproc /usr/sbin/alfred
+ ;;
+
+ *)
+ echo "Usage: ${0} {start|stop|restart|status}"
+ exit 1
+ ;;
+esac
+
+# End $rc_base/init.d/alfred
--- /dev/null
+#!/bin/sh
+########################################################################
+# Begin $rc_base/init.d/fastd
+#
+# Description : fastd initscript
+#
+########################################################################
+
+. /etc/sysconfig/rc
+. ${rc_functions}
+
+. /etc/rc.d/init.d/lib-freifunk
+
+FASTD_CONF="/var/ipfire/freifunk/fastd.conf"
+
+case "${1}" in
+ start)
+ # Do nothing if the fastd configuration file does not exist
+ # or if it is empty
+ [ -s "${FASTD_CONF}" ] || exit 0
+
+ boot_mesg "Starting fastd..."
+
+ # Loading required kernel modules
+ modprobe tun
+
+ loadproc /usr/bin/fastd --daemon --config "${FASTD_CONF}"
+ ;;
+
+ stop)
+ boot_mesg "Stopping fastd..."
+ killproc /usr/bin/fastd
+ ;;
+
+ restart)
+ ${0} stop
+ sleep 1
+ ${0} start
+ ;;
+
+ status)
+ statusproc /usr/bin/fastd
+ ;;
+
+ # Hidden commands used by fastd
+ on-up)
+ # INTERFACE must be set
+ [ -z "${INTERFACE}" ] && exit 2
+
+ # Bring up the device
+ ip link set "${INTERFACE}" up
+
+ # Add the VPN device to the BATMAN network
+ freifunk_batman_attach "${INTERFACE}"
+
+ # Bring up all the rest of Freifunk
+ freifunk_start
+
+ exit 0
+ ;;
+
+ on-*)
+ # Nothing to do, yet
+ exit 0
+ ;;
+
+ *)
+ echo "Usage: ${0} {start|stop|restart|status}"
+ exit 1
+ ;;
+esac
+
+# End $rc_base/init.d/fastd
. /etc/sysconfig/rc
. ${rc_functions}
-FASTD_CONF="/var/ipfire/freifunk/fastd.conf"
-BATMAN_INTERFACE="bat0"
-
-eval $(/usr/local/bin/readhash /var/ipfire/freifunk/settings)
-
-function freifunk_is_enabled() {
- [ "${FREIFUNK_ENABLED}" = "on" ]
-}
+. /etc/rc.d/init.d/lib-freifunk
case "${1}" in
start)
freifunk_is_enabled || exit 0
boot_mesg "Starting Freifunk network..."
+ freifunk_start; evaluate_retval
- # Loading required kernel modules
- modprobe tun
-
- loadproc /usr/bin/fastd --daemon --config "${FASTD_CONF}"
+ # Start fastd (if required)
+ /etc/init.d/fastd start
;;
stop)
+ /etc/init.d/fastd stop
+
boot_mesg "Stopping Freifunk network..."
- killproc /usr/bin/fastd
+ freifunk_stop; evaluate_retval
;;
restart)
;;
status)
- statusproc /usr/bin/fastd
- ;;
-
- # Hidden commands used by fastd
- on-up)
- # INTERFACE must be set
- [ -z "${INTERFACE}" ] && exit 2
-
- # Load batman kernel module
- modprobe batman-adv
-
- # Bring up the device
- ip link set "${INTERFACE}" up
-
- # Add the VPN device to the BATMAN network and bring it up as well
- echo "${BATMAN_INTERFACE}" > "/sys/class/net/${INTERFACE}/batman_adv/mesh_iface"
- ip link set "${BATMAN_INTERFACE}" up
- ;;
-
- on-*)
- # Nothing to do, yet
- exit 0
+ /etc/init.d/alfred status
+ /etc/init.d/fastd status
;;
*)
--- /dev/null
+#!/bin/sh
+
+FREIFUNK_BRIDGE="meshbr0"
+BATMAN_INTERFACE="bat0"
+
+eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
+eval $(/usr/local/bin/readhash /var/ipfire/freifunk/settings)
+
+function freifunk_is_enabled() {
+ [ "${FREIFUNK_ENABLED}" = "on" ]
+}
+
+function freifunk_start() {
+ # Do nothing if Freifunk is not enabled
+ freifunk_is_enabled || exit 0
+
+ # Bring up the batman interface
+ freifunk_batman_create
+ freifunk_batman_attach_all
+
+ # Create the Freifunk bridge
+ freifunk_bridge_create
+ freifunk_bridge_attach "${BATMAN_INTERFACE}"
+
+ # Make sure that alfred is started
+ /etc/init.d/alfred start &>/dev/null
+}
+
+function freifunk_stop() {
+ /etc/init.d/alfred stop &>/dev/null
+
+ ip link set "${BATMAN_INTERFACE}" down &>/dev/null
+ ip link del "${BATMAN_INTERFACE}" &>/dev/null
+
+ ip link set "${FREIFUNK_BRIDGE}" down &>/dev/null
+}
+
+function freifunk_bridge_create() {
+ # Create bridge if it does not exist, yet
+ if [ ! -d "/sys/class/net/${FREIFUNK_BRIDGE}" ]; then
+ ip link add name "${FREIFUNK_BRIDGE}" type bridge
+ fi
+
+ # Bring it up
+ ip link set "${FREIFUNK_BRIDGE}" up
+}
+
+function freifunk_bridge_remove() {
+ if [ -d "/sys/class/net/${FREIFUNK_BRIDGE}" ]; then
+ ip link set "${FREIFUNK_BRIDGE}" down
+ ip link del name "${FREIFUNK_BRIDGE}"
+ fi
+}
+
+function freifunk_bridge_attach() {
+ local device="${1}"
+
+ ip link set "${device}" master "${FREIFUNK_BRIDGE}"
+ ip link set "${device}" up
+}
+
+function freifunk_bridge_detach() {
+ local device="${1}"
+
+ ip link set "${device}" nomaster
+}
+
+function freifunk_batman_create() {
+ local device="${BATMAN_INTERFACE}"
+
+ if [ ! -d "/sys/class/net/${device}" ]; then
+ ip link add name "${device}" type batadv
+ fi
+ ip link set "${BATMAN_INTERFACE}" up
+}
+
+function freifunk_batman_attach() {
+ local device="${1}"
+
+ # Make sure the batman module is loaded
+ modprobe batman-adv
+
+ echo "${BATMAN_INTERFACE}" > "/sys/class/net/${device}/batman_adv/mesh_iface"
+ ip link set "${device}" up
+}
+
+function freifunk_batman_attach_all() {
+ local dev
+
+ for dev in BATMAN1_DEV BATMAN2_DEV; do
+ [ -z "${!dev}" ] && continue
+ [ -d "/sys/class/net/${!dev}" ] || continue
+
+ freifunk_batman_attach "${!dev}"
+ done
+}
+
+function freifunk_ipv6_enable() {
+ local device="${1}"
+
+ sysctl -w "net.ipv6.conf.${device}.disable_ipv6=0" >/dev/null
+}
+
+function freifunk_ipv6_disable() {
+ local device="${1}"
+
+ sysctl -w "net.ipv6.conf.${device}.disable_ipv6=1" >/dev/null
+}