summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am3
-rw-r--r--configure.ac3
-rw-r--r--debian/vyatta-cfg.postinst.in3
-rw-r--r--debian/vyatta-cfg.postrm.in6
-rw-r--r--etc/config.boot.default29
-rwxr-xr-xetc/init.d/vyatta-ofr172
7 files changed, 216 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 63b6513..358c973 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,6 +20,7 @@ libtool
/debian/files
/debian/vyatta-cfg
/debian/vyatta-cfg.postinst
+/debian/vyatta-cfg.postrm
/INSTALL
/Makefile.in
/Makefile
diff --git a/Makefile.am b/Makefile.am
index 3ff591d..da82552 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,12 +1,15 @@
cfgdir = $(datadir)/vyatta-cfg/templates
share_perl5dir = /opt/vyatta/share/perl5
completiondir = /etc/bash_completion.d
+initddir = /etc/init.d
AM_CFLAGS = -I src -Wall
AM_YFLAGS = -d --name-prefix=yy_`basename $* .y`_
AM_LFLAGS = --prefix=yy_`basename $* .l`_ -olex.yy.c
completion_DATA = etc/bash_completion.d/vyatta-cfg
+initd_SCRIPTS = etc/init.d/vyatta-ofr
+sysconf_DATA = etc/config.boot.default
lib_LTLIBRARIES = src/libvyatta-cfg.la
src_libvyatta_cfg_la_LDFLAGS = -version-info 1:0:0
diff --git a/configure.ac b/configure.ac
index c108943..4e344f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,7 +31,8 @@ AC_ARG_ENABLE([nostrip],
AC_CONFIG_FILES(
[Makefile]
- [debian/vyatta-cfg.postinst])
+ [debian/vyatta-cfg.postinst]
+ [debian/vyatta-cfg.postrm])
AC_SUBST(NOSTRIP)
diff --git a/debian/vyatta-cfg.postinst.in b/debian/vyatta-cfg.postinst.in
index 6a5a3ec..e84995e 100644
--- a/debian/vyatta-cfg.postinst.in
+++ b/debian/vyatta-cfg.postinst.in
@@ -10,3 +10,6 @@ for d in {$prefix,$sysconfdir}/config; do
chmod -R g+w $d
done
+update-rc.d vyatta-ofr defaults >/dev/null
+# do we want to start vyatta-ofr here in postinst?
+
diff --git a/debian/vyatta-cfg.postrm.in b/debian/vyatta-cfg.postrm.in
new file mode 100644
index 0000000..262b9fe
--- /dev/null
+++ b/debian/vyatta-cfg.postrm.in
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+if [ "$1" = "purge" ]; then
+ update-rc.d vyatta-ofr remove >/dev/null || exit $?
+fi
+
diff --git a/etc/config.boot.default b/etc/config.boot.default
new file mode 100644
index 0000000..941507f
--- /dev/null
+++ b/etc/config.boot.default
@@ -0,0 +1,29 @@
+system {
+ ntp-server "69.59.150.135"
+ login {
+ user root {
+ authentication {
+ encrypted-password: "$1$$Ht7gBYnxI1xCdO/JOnodh."
+ }
+ }
+ user vyatta {
+ authentication {
+ encrypted-password: "$1$$Ht7gBYnxI1xCdO/JOnodh."
+ }
+ }
+ }
+ package {
+ repository community {
+ component: "main"
+ url: "http://archive.vyatta.com/vyatta"
+ }
+ }
+}
+
+interfaces {
+ loopback lo {
+ }
+}
+
+/* Warning: Do not remove the following line. */
+/* === vyatta-config-version: "cluster@1:dhcp-relay@1:dhcp-server@1:firewall@1:nat@2:serial@1:webgui@1" === */
diff --git a/etc/init.d/vyatta-ofr b/etc/init.d/vyatta-ofr
new file mode 100755
index 0000000..f8782ec
--- /dev/null
+++ b/etc/init.d/vyatta-ofr
@@ -0,0 +1,172 @@
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: ofr
+# Required-Start: $syslog $time $local_fs
+# Required-Stop: $syslog $time $local_fs
+# Default-Start: 2 3 4 5
+# Default-Stop: S 0 1 6
+# Short-Description: Vyatta Router
+# Description: Debian init script for the Vyatta Router
+### END INIT INFO
+# **** License ****
+# Version: VPL 1.0
+#
+# The contents of this file are subject to the Vyatta Public License
+# Version 1.0 ("License"); you may not use this file except in
+# compliance with the License. You may obtain a copy of the License at
+# http://www.vyatta.com/vpl
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+# the License for the specific language governing rights and limitations
+# under the License.
+#
+# This code was originally developed by Vyatta, Inc.
+# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
+# All Rights Reserved.
+#
+# Author: Tom Grennan <tgrennan@vyatta.com>
+# **** End License ****
+
+. /lib/lsb/init-functions
+
+: ${vyatta_env:=/etc/default/vyatta}
+source $vyatta_env
+
+declare progname=${0##*/}
+declare action=$1; shift
+
+declare -x BOOTFILE=$vyatta_sysconfdir/config/config.boot
+
+declare -a subinit
+declare -a all_subinits=(
+ rl-system
+ sysklogd
+ firewall
+ dhcpd
+ dhcrelay
+ lighttpd
+ ntpd
+ sshd
+ telnetd )
+
+if [ $# -gt 0 ] ; then
+ for s in $@ ; do
+ [ -x ${vyatta_sbindir}/${s}.init ] && subinit[${#subinit}]=$s
+ done
+else
+ for s in ${all_subinits[@]} ; do
+ [ -x ${vyatta_sbindir}/${s}.init ] && subinit[${#subinit}]=$s
+ done
+# NOTE: rtrmgr (i.e. xorp) is mutually exclusive of quagga
+ if [ -x /etc/init.d/quagga ] ; then
+ # quagga should already be started.
+ GROUP=quagga
+ elif [ -x ${vyatta_sbindir}/rtrmgr.init ] ; then
+ subinit[${#subinit}]=rtrmgr
+ GROUP=xorp
+ fi
+fi
+
+
+have_rl_system () {
+ test -x $vyatta_sbindir/rl-system.init
+}
+
+try_floppy () {
+ _fd_=/media/floppy
+ _fd_config_=$_fd_/config/config.boot
+ _fd_rc_local_=$_fd_/rc.local
+
+ if have_rl_system ; then
+## only do this if we have the rl-system package
+## if we donot discover an fd device, try loading the floppy module
+ grep -q fd /proc/devices || modprobe -q floppy 2>/dev/null
+ if grep -q fd /proc/devices ; then
+ if awk -- '$1 ~ /\/dev\/fd/ { exit 1 }' /proc/mounts
+ then
+ mkdir -p $_fd_
+ mount -t ext2 /dev/fd0 $_fd_ -o sync 2>/dev/null
+ test $? -eq 32 && mount -t vfat /dev/fd0 $_fd_ 2>/dev/null
+ fi
+ fi
+ test -x $_fd_rc_local_ && $_fd_rc_local_ start
+ test -f $_fd_config_ && BOOTFILE=$_fd_config_
+ fi
+}
+
+# if necessary, provide initial config
+init_bootfile () {
+ if [ ! -f $BOOTFILE ] ; then
+ if [ ! -d $vyatta_sysconfdir/config ]; then
+ mkdir -p $vyatta_sysconfdir/config
+ fi
+ cp $vyatta_sysconfdir/config.boot.default $BOOTFILE
+ fi
+ chgrp ${GROUP} $BOOTFILE
+ chmod 660 $BOOTFILE
+ ## remove the unnecessary and potentially conflicting
+ ## config-directory statement (i.e. /mnt/floppy vs. /media/floppy
+ sed -i '/^rtrmgr {$/,/^}$/d' $BOOTFILE
+}
+
+# if necessary, migrate initial config
+migrate_bootfile ()
+{
+ if [ -x $vyatta_sbindir/vyatta_config_migrate.pl ]; then
+ log_progress_msg migrate
+ $vyatta_sbindir/vyatta_config_migrate.pl $BOOTFILE
+ fi
+}
+
+# load the initial config
+load_bootfile ()
+{
+ if [ -x $vyatta_sbindir/vyatta-config-loader.pl ]; then
+ log_progress_msg configure
+ $vyatta_sbindir/vyatta-config-loader.pl $BOOTFILE
+ fi
+}
+
+start ()
+{
+ log_daemon_msg "Starting Vyatta Router"
+ try_floppy
+ init_bootfile
+ migrate_bootfile
+ for s in ${subinit[@]} ; do
+ log_progress_msg $s
+ ${vyatta_sbindir}/${s}.init start || (log_end_msg $? && return)
+ done
+ load_bootfile
+ echo -n $BOOTFILE > ${vyatta_sysconfdir}/bootfile_path
+ log_end_msg $?
+}
+
+stop()
+{
+ local -i status=0
+ log_daemon_msg "Stopping Vyatta Router"
+ for ((i=${#sub_inits[@]} - 1; i >= 0; i--)) ; do
+ s=${subinit[$i]}
+ log_progress_msg $s
+ ${vyatta_sbindir}/${s}.init stop
+ let status\|=$?
+ done
+ log_end_msg $status
+}
+
+case "$action" in
+ start) start ;;
+ stop) stop ;;
+ restart|force-reload) stop && start ;;
+ *) log_failure_msg "usage: $progname [ start|stop|restart ] [ subinit ... ]" ;
+ false ;;
+esac
+
+exit $?
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 4
+# End: