From owner-freebsd-rc@FreeBSD.ORG Sat Oct 6 20:39:10 2007 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D75E16A418 for ; Sat, 6 Oct 2007 20:39:10 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.191]) by mx1.freebsd.org (Postfix) with ESMTP id B39F413C458 for ; Sat, 6 Oct 2007 20:39:09 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: by nf-out-0910.google.com with SMTP id b2so696673nfb for ; Sat, 06 Oct 2007 13:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=8e5CWTpJLZn8HziXwXjuclxyz1EG47q6h1kmrgBfDes=; b=jQaFaMoSOg/GC4NHvtGarHe/OyG7xMA29VPlHIqDEAHiVHhhsd3mGviCDyWs/CRzqGPaIpwhYtnHvi1C+7aV/6wY+o8AlecHFV6Gfczdct90tDH19HVGHOskyf6cQfhLTP03q17DhpZlMTfYQrhvonSkRN11P3dp2+LlkTT9bKQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=R7Y9SuUDmF0iXeqKxzcePpX5Sj8yHi+8B2x9JJRswm8mratTABDSIE+kpBaAc0JB20mIekJxeb5ll3QIEzVO+Wz1QakJV0emg/uae4siwuTOItv/kYq7hjjEf7hq9iugEufSQwnxLOElJDAdsJPb907RMAu2JWBav1rRG1jqJcY= Received: by 10.86.62.3 with SMTP id k3mr3646020fga.1191701658774; Sat, 06 Oct 2007 13:14:18 -0700 (PDT) Received: by 10.86.25.9 with HTTP; Sat, 6 Oct 2007 13:14:18 -0700 (PDT) Message-ID: Date: Sat, 6 Oct 2007 13:14:18 -0700 From: "Maksim Yevmenkin" To: freebsd-rc@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: multiple instances of ppp X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Oct 2007 20:39:10 -0000 hello, a friend of mine send me the following /etc/rc.c/ppp replacement script. the idea is to start multiple instances of ppp at boot time (possibly with different profiles). i'm not sure if this is ok to commit as it is, so i decided to ask if there is a better way to handle this. any thoughts on the subject is very much appreciated. thanks, max #ppp_enable="NO" # Start user-ppp (or NO). #ppp_program="/usr/sbin/ppp" # Path to user-ppp program. #ppp_mode="auto" # Choice of "auto", "ddial", "direct" or "dedicated". #ppp_nat="YES" # Use PPP's internal network address translation or NO. #ppp_user="root" # Which user to run ppp as #ppp_profile="papchap" # Which profiles to use from /etc/ppp/ppp.conf, # # in example: # # ppp_profile="papchap profile2 profile3" # Override default settings ppp_mode and ppp_nat for profiles #ppp_papchap_mode="ddial" #ppp_profile3_mode="dedicated" #ppp_profile3_nat="NO" # # PROVIDE: ppp # REQUIRE: netif isdnd # KEYWORD: nojail . /etc/rc.subr name="ppp" rcvar=`set_rcvar` command="/usr/sbin/${name}" start_cmd="ppp_prestart" start_poststart="ppp_poststart" ppp_prestart() { echo -n "Starting PPP profile:" for profile in ${ppp_profile} do echo -n " ${profile}" # Establish ppp mode. # rc_flags='' eval ppp_mode=\$ppp_${profile}_mode if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \ -a "${ppp_mode}" != "dedicated" \ -a "${ppp_mode}" != "background" ]; then ppp_mode="auto" fi rc_flags="$rc_flags -quiet -${ppp_mode}" # Switch on NAT mode? # nat=$ppp_nat eval cur_nat=\$ppp_${profile}_nat case $cur_nat in [Yy][Ee][Ss]|[Nn][Oo]) nat=${cur_nat} ;; esac case ${nat} in [Yy][Ee][Ss]) rc_flags="$rc_flags -nat" ;; esac # Run ! # su -m $ppp_user -c "$command ${rc_flags} ${profile}" done echo "." } ppp_poststart() { # Re-Sync ipfilter and pf so they pick up any new network interfaces # /etc/rc.d/ipfilter resync /etc/rc.d/pf resync } load_rc_config $name run_rc_command "$1"