Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:olh
dyndns-conf
dyndns-conf.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File dyndns-conf.spec of Package dyndns-conf
# # spec file for package dyndns-conf # # Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: dyndns-conf Version: 2 Release: 0 License: GPL Summary: Update dyndns address Group: Base/System Requires: cron Requires: curl Requires: iproute2 Requires: sed BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build %define script_dir /etc/NetworkManager/dispatcher.d %define script_name %{script_dir}/%{name}.sh %description Update dyndns address regulary and when the link comes up. %prep %build # cat > %{name}.cron <<'__EOF__' #MAILTO="" PATH=/sbin:/usr/sbin:/bin:/usr/bin -* * * * * root %{script_name} cron recheck __EOF__ chmod 444 %{name}.cron # cat > %{name}.conf <<'__EOF__' #afraid_token="aaa" #dynv6_hostname="myname.dynv6.net" #dynv6_token='bbb' #myonlineportal_user="usr" #myonlineportal_password="pass" #myonlineportal_hostname="myname.my-homeip.de" __EOF__ chmod 444 %{name}.conf # cat > %{name}.sh <<'__EOF__' #/usr/bin/env bash conf=/etc/%{name}.conf file=/dev/shm/.%{name}.addr6.txt old_address= address= iface=$1 mode=$2 do_log= some_error= # [ -e "${conf}" ] || exit 0 # case "${mode}" in recheck) ;; *) do_log=;; esac if test -n "${do_log}" then echo "$0 $*" env | sort fi # netmask=128 address=$( ip -oneline -family inet6 address show scope global -deprecated mngtmpaddr | sed -n '/inet6 fd/d;/inet6 /{s/.*inet6 \([0-9a-f:]\+[^/]\+\)\/\([0-9]\+\).*/\1/p;q}') if [ -z "${address}" ]; then address=$( ip -oneline -family inet6 address show scope global -deprecated | sed -n '/inet6 fd/d;/inet6 /{s/.*inet6 \([0-9a-f:]\+[^/]\+\)\/\([0-9]\+\).*/\1/p;q}') fi # if [ -z "${address}" ]; then exit 0 fi # [ -e "${file}" ] && old_address="`cat \"${file}\"`" if [ "${old_address}" = "${address}" ]; then exit 0 fi # . "${conf}" t=`mktemp --directory --tmpdir=/dev/shm` [ -z "${t}" ] && exit 1 te="${t}/e" to="${t}/o" function _x() { rm -fr "${t}" } trap _x EXIT # function do_curl() { local url=$1 shift bash -c " set -ex ; curl \ --connect-timeout 13 \ --max-time 42 \ --fail \ --silent \ --show-error \ --noproxy '*' \ $@ \ '${url}'" < /dev/null > "${to}" 2> "${te}" return $? } curl_out() { head -n 1234 "${to}" "${te}" } function set_afraid_org() { local addr=$1 local token=$2 local ret local out do_curl \ "http://freedns.afraid.org/dynamic/update.php?${token}&address=${addr}" ret=$? read out < "${to}" case "${out}" in *" has not changed.") ;; *) echo "freedns.afraid.org reported (${ret}):" curl_out some_error=true ;; esac return "${ret}" } # function set_dynv6_com() { local addr=$1 local netmask=$2 local token=$3 local hostname=$4 local ret local out do_curl \ "http://dynv6.com/api/update?hostname=${hostname}&ipv6=${addr}/${netmask}&token=${token}" ret=$? read out < "${to}" case "${out}" in "host updated") ;; "addresses unchanged") ;; *) echo "dynv6.com reported (${ret}):" curl_out some_error=true ;; esac if test "${ret}" != "0" then return "${ret}" fi do_curl \ "http://ipv4.dynv6.com/api/update?hostname=${hostname}&ipv4=auto&token=${token}" ret=$? read out < "${to}" case "${out}" in "host updated") ;; "addresses unchanged") ;; *) echo "ipv4.dynv6.com reported (${ret}):" curl_out some_error=true ;; esac return "${ret}" } # function set_myonlineportal_net() { local user=$1 local pass=$2 local host=$3 local out do_curl \ "https://myonlineportal.net/updateddns?hostname=${host}" \ --ipv6 --user "${user}:${pass}" ret=$? read out < "${to}" case "${out}" in nochg) ;; *) echo "myonlineportal.net reported (${ret}):" curl_out some_error=true ;; esac return "${ret}" } # if test -n "${afraid_token}" then set_afraid_org "${address}" "${afraid_token}" fi # if test -n "${dynv6_token}" && test -n "${dynv6_hostname}" then set_dynv6_com "${address}" "${netmask}" "${dynv6_token}" "${dynv6_hostname}" fi # if test -n "${myonlineportal_user}" && test -n "${myonlineportal_password}" && test -n "${myonlineportal_hostname}" then set_myonlineportal_net "${myonlineportal_user}" "${myonlineportal_password}" "${myonlineportal_hostname}" fi # save current address if test -n "${some_error}" then rm -f "${file}" else echo "${address}" > "${file}" fi __EOF__ chmod 555 %{name}.sh # %install install -D -m 444 %{name}.cron %{buildroot}/etc/cron.d/%{name} install -D -m 555 %{name}.sh %{buildroot}%{script_name} # %files %defattr(-,root,root) %doc %{name}.conf %config /etc/*
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor