From owner-freebsd-questions@freebsd.org Mon Nov 6 23:32:20 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 30D86E69AE4 for ; Mon, 6 Nov 2017 23:32:20 +0000 (UTC) (envelope-from luzar722@gmail.com) Received: from mail-it0-x231.google.com (mail-it0-x231.google.com [IPv6:2607:f8b0:4001:c0b::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EB24764ECD for ; Mon, 6 Nov 2017 23:32:19 +0000 (UTC) (envelope-from luzar722@gmail.com) Received: by mail-it0-x231.google.com with SMTP id l196so221820itl.4 for ; Mon, 06 Nov 2017 15:32:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:from:user-agent:mime-version:to:subject :content-transfer-encoding; bh=ObOQvkZ8mtzQxU6tw//KgIusdh/RrV+lUWlVZibp00Q=; b=vgHRp7xPej7dTDsyCxzHJJ0de5P7G3yeHN6tRhSHCNFwdJ0HXkkZEXV15qLiXnWNZl PnbEv5mTtQM3Q2S6dQNIJ/5jAJg0dr2WuZ6rXBem3q9+/sogDt85RsGnZlZajKduBbLL Cl/9K0vqRgOEAIZ/0LKxvxxbLihzUb2+t7/yNVjIRvrfOgDOs69J+eZJF32qW4xr+g3e pMznrCBDeNjf9fiv+CV0d+EDDe5cZ/Ps25+sMDY3+v3QCTGUwgnf2v/Q4DltgmsjKmxq ya1icPu63/cmVhrNXt2blW7ccOtsYjZYgWnPl9IR0fknCIoByC4GBPb+KMsJ2VNbcVvs Kwqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:content-transfer-encoding; bh=ObOQvkZ8mtzQxU6tw//KgIusdh/RrV+lUWlVZibp00Q=; b=BqajyEShzBR3xvAxssfqsQ6iu7ymPX0TKaweCPDBYMfy8WHRtExUiCghx7+1yNrQvF HSQ/ncO4erE19eWEHxWJrO1UkXcp5qvLXTUUsVK79yCLgMdh5WRfzoABOXxpCR4i0TFr 74isRDTbRNjTmc+8nNTYLvKpcsM0Hh5v5EenUin+HuK1OmUTmEVTvHUhAte0g9UbpT7C 5k68szmR/wztS2oDatRhFatHQ4yLcDejQJ121QYA0oBwniQESVlOeM5fBMQuOW7kJ3YN iUewzm0/bRxqkiEvS03i7Uda9HAExU3h1Oh4hUx0yYaUSxt58618/U3+XJi0822PFFy7 GXrg== X-Gm-Message-State: AJaThX5lLTA3i0MIXw+RY15dT3cvw8Ln1M/3Poe5xd546cvB2Mh/uRqN y/FylFU1HCRTaiL7xCAL5kg2Uw== X-Google-Smtp-Source: ABhQp+SCLfMv0598EjHT5aCEo+DPqJ0uZLiTDkPfnufMl72ULFku7E0v804yBXSBjQYKli2nwHDQBA== X-Received: by 10.36.185.94 with SMTP id k30mr11475537iti.2.1510011139054; Mon, 06 Nov 2017 15:32:19 -0800 (PST) Received: from [10.0.10.7] (cpe-65-25-50-122.neo.res.rr.com. [65.25.50.122]) by smtp.googlemail.com with ESMTPSA id g26sm6032008iob.34.2017.11.06.15.32.18 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Nov 2017 15:32:18 -0800 (PST) Message-ID: <5A00F101.8040708@gmail.com> Date: Mon, 06 Nov 2017 18:32:17 -0500 From: Ernie Luzar User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: "freebsd-questions@freebsd.org" Subject: Need help with rc.d script Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Nov 2017 23:32:20 -0000 I wrote this sh script today for dynamic dns ip updates. When I use service dynip start command it just hangs there. Need pointer to what I am doing wrong. Here are the 2 scripts in question: Script started on Mon Nov 6 18:19:18 2017 /root/bin >cat /usr/local/bin/dynip #!/bin/sh # # Script to update the dynamic DNS pointer at your dynamic DNS hosting site. # This script runs continually and on a user defined timed cycle will # check the dynamic ip address of the interface facing the public internet # to determin if it has changed. If it has changed the browser URL format # is used to update the DNS pointer IP address at the dynamic DNS hosting # site that is hosting your Fully qualified domain to the newly changed # ip address. # # The default browser URL format being used is for NameCheap (namecheap.com). # NOTE: Most DNS hosting sites that provide dynamic DNS services use a # variation of the default browser URL format used here. A simple user # substitution to the "wget" command for the browser URL format used by your # dynamic DNS hosting site will allow this script to work for you. prev_ip_file="/usr/local/etc/dynip" # Cycle time to wait between ip checks. #elapse_time="7200" # 7200 seconds = 2 hours #elapse_time="3600" # 3600 seconds = 1 hour #elapse_time="1800" # 1800 seconds = 30 minutes #elapse_time="900" # 1800 seconds = 15 minutes #elapse_time="600" # 600 seconds = 10 minutes #elapse_time="300" # 300 seconds = 5 minutes elapse_time="10" # Find the NIC device name of the NIC connected to the public internet. # The default interface obtained from route command is the one connected # to the public internet. # nic_devicename="$(route get -inet default 2> /dev/null | \ grep -o "interface.*" | cut -d ' ' -f 2)" ##echo "nic_devicename = ${nic_devicename}" # Get the IP address assigned to that NIC device name. # nic_ip="$(ifconfig $nic_devicename inet | \ grep -o "inet.*" | cut -d ' ' -f 2)" #echo "nic_ip1 = ${nic_ip}" # On start up get the last recorded ip address in use and populate variable # with its value. # if [ -f "${prev_ip_file}" ]; then prev_ip="$(cat ${prev_ip_file})" else prev_ip="0.0.0.0" echo "${prev_ip}" > ${prev_ip_file} fi #echo "prev_ip = $prev_ip" # This is the continuous loop checking the current ip address to # to determin if it changed. while [ 1 ]; do # Get the IP address assigned to that NIC device name. nic_ip="$(ifconfig $nic_devicename inet | \ grep -o "inet.*" | cut -d ' ' -f 2)" #echo "nic_ip2 = ${nic_ip}" if [ "${prev_ip}" != "${nic_ip}" ]; then # Update dynamic DNS hosting site with new ip address. website="https://dynamicdns.park-your-domain.com/update?" dyn_host="host=home-fbsd&domain=host.xxxxxxx.com" password="&password=a3e0ffc2274746b29ceaf126d59e51c1" url="$website$dyn_host$password" #echo "$url" /usr/local/bin/wget -O /var/log/namecheap.dynip.update.log -q "$url" #echo "rtn-code = $?" if [ $? -ne 0 ]; then echo "Error: /usr/local/bin/wget command failed." exit 3 fi #echo "${nic_ip}" > ${prev_ip_file} prev_ip="${nic_ip}" fi sleep ${elapse_time} done /root/bin cat /usr/local/etc/rc.d/dynip #!/bin/sh # # # PROVIDE: dynip # REQUIRE: LOGIN # KEYWORD: shutdown # # Add the following line to /etc/rc.conf to enable dynip: # # dynip_enable="YES" # . /etc/rc.subr name=dynip rcvar=dynip_enable command="/usr/local/bin/${name}" run_rc_command "$1"