Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37711746
en ru br
ALT Linux repositórios
S:5.2.5-alt1
5.0: 4.5-alt1
4.1: 3.1-alt5.M41.8
4.0: 0.9-alt1.M40.3

Group :: Sistema/Configurações/Rede
RPM: alterator-net-eth

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

alterator-net-eth-4.16.0/000075500000000000000000000000001205343555700151505ustar00rootroot00000000000000alterator-net-eth-4.16.0/Makefile000064400000000000000000000006031205343555700166070ustar00rootroot00000000000000NAME=net-eth
INSTALL=/usr/bin/install

all:
clean: clean-po
install: install-module install-data

include /usr/share/alterator/build/module.mak

install-data:
install -d $(datadir)/install2
install -d $(libexecdir)/alterator/hooks/net-eth.d
install -d $(libexecdir)/alterator/hooks/net-eth-precommit.d
install -Dm0755 hook/hosts-hook-hostname ${sysconfdir}/hooks/hostname.d/05-hosts
alterator-net-eth-4.16.0/applications/000075500000000000000000000000001205343555700176365ustar00rootroot00000000000000alterator-net-eth-4.16.0/applications/net-eth.desktop000064400000000000000000000004131205343555700225730ustar00rootroot00000000000000[Desktop Entry]
Type=Application
Categories=X-Alterator-Network
Icon=net-eth
Terminal=false
Name=Ethernet interfaces
X-Alterator-URI=/net-eth
X-Alterator-Weight=30
X-Alterator-Help=net-eth
Name[ru]=Ethernet-интерфейсы
Name[uk]=Ethernet-інтерфейси
alterator-net-eth-4.16.0/backend3/000075500000000000000000000000001205343555700166225ustar00rootroot00000000000000alterator-net-eth-4.16.0/backend3/net-eth000075500000000000000000000464411205343555700201250ustar00rootroot00000000000000#!/bin/sh

cachedir="/var/cache/alterator/net-eth"
precommit_hooks_dir=/usr/lib/alterator/hooks/net-eth-precommit.d
postcommit_hooks_dir=/usr/lib/alterator/hooks/net-eth.d
ALTERATOR_DOMAIN=/usr/lib/alterator/backend3/net-domain

rdelim='[[:space:]]\+'
wdelim=' '

max_hostname_length=64

alterator_api_version=1

. alterator-sh-functions
. alterator-net-functions
. alterator-hw-functions
. shell-config

###
is_defined()
{
set|grep -qs "^$(quote_sed_regexp "$1")="
}

is_bridge()
{
local ifacedir="$1"; shift
local iface="${ifacedir##*/}"

if netdev_is_up "$iface"; then
netdev_is_bridge "$iface"
else
[ "$ifacedir" != "$iface" ] || ifacedir="/etc/net/ifaces/$iface"
[ "$(read_iface_option "$ifacedir" TYPE)" = bri ]
fi
}

real_iface()
{
local ifacedir="$1"; shift
local iface="${ifacedir##*/}"

[ "$ifacedir" != "$iface" ] || ifacedir="/etc/net/ifaces/$iface"
if is_bridge "$ifacedir";then
if netdev_is_up "$iface"; then
netdev_list_brif "$iface"|head -n1
else
read_iface_option "$ifacedir" HOST | sed -rn "s;^['\"]?([[:alnum:]]+).*;\1;p"
fi
else
echo "$iface"
fi
}

name_with_bridge()
{
local name="$1"; shift
local ifacedir=

if [ -d "$cachedir/br$name" ] && [ "$(real_iface "$cachedir/br$name")" = "$name" ]; then
echo "br$name"
elif [ -d "$cachedir/${name#br}" ]; then
echo "${name#br}"
else
echo "$name"
fi
}

### cache
init_cache()
{
local name="$1"; shift
local bridge="${1-}"
local ifacedir="/etc/net/ifaces/$name"
local dstdir="$cachedir/$name"
local srcname=

if [ ! -d "$dstdir" ] ;then
if [ -n "$bridge" ]; then
if test_bool "$bridge"; then
srcname="${name#br}"
if [ -d "$cachedir/$srcname" ]; then
mv -f -- "$cachedir/$srcname" "$dstdir"
elif [ -d "$ifacedir" ]; then
cp -a "$ifacedir" "$cachedir"
elif [ -d "/etc/net/ifaces/$srcname" ]; then
cp -a "/etc/net/ifaces/$srcname" "$dstdir"
fi
else
srcname="br$name"
if [ -d "$cachedir/$srcname" ]; then
mv -f -- "$cachedir/$srcname" "$dstdir"
elif [ -d "/etc/net/ifaces/$srcname" ]; then
cp -a "/etc/net/ifaces/$srcname" "$dstdir"
elif [ -d "$ifacedir" ]; then
cp -a "$ifacedir" "$cachedir"
fi
fi
else
[ -d "$ifacedir" ] && cp -a "$ifacedir" "$cachedir"
fi
mkdir -p -- "$dstdir"
fi

[ ! -f /etc/sysconfig/network -o -f "$cachedir/network" ] || cp /etc/sysconfig/network "$cachedir/network"
}

clear_cache()
{
rm -rf "$cachedir"
mkdir -p "$cachedir"
}

commit_hostname()
{
[ -f "$cachedir/network" ] || return
! cmp -s /etc/sysconfig/network "$cachedir/network" || return

local old_value="$(shell_config_get /etc/sysconfig/network HOSTNAME)"
local new_value="$(shell_config_get "$cachedir/network" HOSTNAME)"

mv -f "$cachedir/network" /etc/sysconfig/network
hostname "$new_value"
run-parts /etc/hooks/hostname.d "$old_value" "$new_value"
}

commit_cache()
{
#little run-parts: check configuration before apply it
set_locale
local answer=
for f in "$precommit_hooks_dir"/*; do
[ -f "$f" -a -x "$f" ] || continue
[ "${f%.rpm*}" = "$f" -a "${f%\~}" = "$f" ] || continue

if ! answer="$("$f")";then
[ -n "$answer" ] || answer="$f failed"
write_error "$answer"
return 1
fi
done

commit_hostname

find $cachedir -maxdepth 1 -mindepth 1 -type d|
while read iface; do

[ -n "$iface" ] || exit

local ifname="${iface##*/}"

#try to stop and remove old bridge
if [ -d "/etc/net/ifaces/br$ifname" ] && is_bridge "/etc/net/ifaces/br$ifname"; then
[ -n "$DURING_INSTALL" ] || iface_down "br$ifname"
rm -rf -- "/etc/net/ifaces/br$ifname"
fi

[ -n "$DURING_INSTALL" ] || iface_down "$ifname"

# IPv4 configuration
local old_config_ipv4="$(read_config_ipv "/etc/net/ifaces/$ifname" 4)"
local new_config_ipv4="$(read_config_ipv "$iface" 4)"

local old_ipv4addresses="$(read_iface_addresses "/etc/net/ifaces/$ifname" 4)"
local new_ipv4addresses="$(read_iface_addresses "$iface" 4)"

local old_ipv4configuration="$(read_configuration "/etc/net/ifaces/$ifname" 4)"
local new_ipv4configuration="$(read_configuration "$iface" 4)"

# IPv6 configuration
local old_config_ipv6="$(read_config_ipv "/etc/net/ifaces/$ifname" 6)"
local new_config_ipv6="$(read_config_ipv "$iface" 6)"

local old_ipv6addresses="$(read_iface_addresses "/etc/net/ifaces/$ifname" 6)"
local new_ipv6addresses="$(read_iface_addresses "$iface" 6)"

local old_ipv6configuration="$(read_configuration "/etc/net/ifaces/$ifname" 6)"
local new_ipv6configuration="$(read_configuration "$iface" 6)"

#update configs
rm -rf -- "/etc/net/ifaces/$ifname"
mv -f -- "$cachedir/$ifname" "/etc/net/ifaces/$ifname"

#add config for bridge members
if is_bridge "$ifname";then
local real_fname="$(real_iface "$ifname")"
if [ -n "$real_fname" ]; then
[ -n "$DURING_INSTALL" ] || iface_down "$real_fname"
rm -rf -- "/etc/net/ifaces/$real_fname"
mkdir -p -- "/etc/net/ifaces/$real_fname"
printf 'TYPE=eth\nBOOTPROTO=static\n' >"/etc/net/ifaces/$real_fname/options"
fi
fi

#try to restart
[ -n "$DURING_INSTALL" ] && netdev_is_up "$ifname" || iface_up "$ifname"

if [ "$old_config_ipv4" != "$new_config_ipv4" -o \
"$old_ipv4addresses" != "$new_ipv4addresses" -o \
"$old_ipv4configuration" != "$new_ipv4configuration" -o \
"$old_config_ipv6" != "$new_config_ipv6" -o \
"$old_ipv6addresses" != "$new_ipv6addresses" -o \
"$old_ipv6configuration" != "$new_ipv6configuration" ];then
# Deprecated. For backward compatibility only.
local old_addresses="$old_ipv4addresses"
local new_addresses="$new_ipv4addresses"
local old_configuration="$old_ipv4configuration"
local new_configuration="$new_ipv4configuration"
export old_addresses new_addresses old_configuration new_configuration
###
export old_config_ipv4 new_config_ipv4 old_ipv4addresses new_ipv4addresses \
old_ipv4configuration new_ipv4configuration \
old_config_ipv6 new_config_ipv6 old_ipv6addresses new_ipv6addresses \
old_ipv6configuration new_ipv6configuration

run-parts "$postcommit_hooks_dir" "$ifname"
fi
done

clear_cache
/sbin/update_chrooted conf >&2 || :
}

### hostname
check_hostname()
{
local hn="$1"
local length=

length=${#hn}
if [ $length -gt $max_hostname_length ]; then
write_error "`_ "Host name is too long"`"
return 1
fi
return 0
}

read_hostname()
{
local netconfig="/etc/sysconfig/network"
[ -f "$cachedir/network" ] && netconfig="$cachedir/network"

local value="$(shell_config_get "$netconfig" HOSTNAME)"

[ -n "$value" ] || value="localhost.localdomain"
if [ $(expr index "$value" .) -eq 0 ]; then
local domain="$(shell_config_get "$netconfig" DOMAINNAME)"
[ -n "$domain" ] || domain="localdomain"
value="$value"."$domain"
fi
echo "$value"
}

write_hostname()
{
local netconfig="$cachedir/network"

check_hostname "$1" || return
shell_config_set "$netconfig" HOSTNAME "$1"
shell_config_del "$netconfig" DOMAINNAME
}

### computer name

read_computer_name()
{
local value="$(read_hostname)"
if [ -f "$ALTERATOR_DOMAIN" ];then
echo "${value%%.*}"
else
echo "$value"
fi
}

read_computer_domain()
{
local host=$1
[ $(expr index "$host" .) -eq 0 ] && unset host
local value="${host:-$(read_hostname)}"
local domain="${value#*.}"
echo "$domain"
}

write_computer_name()
{
write_hostname "${1%%.*}.$(read_computer_domain $1)"
}

### interface work
list_ipv()
{
write_enum_item "4" "`_ "IPv4"`"
write_enum_item "6" "`_ "IPv6"`"
}

list_eth_cached()
{
list_eth | while read name; do
if [ -d "$cachedir/br$name" ] && [ "$(real_iface "$cachedir/br$name")" = "$name" ]; then
name="br$name"
elif [ -d "$cachedir/${name#br}" ]; then
name="${name#br}"
elif [ -d "/etc/net/ifaces/br$name" ] && [ "$(real_iface "br$name")" = "$name" ]; then
name="br$name"
fi
echo "$name" 2>/dev/null
done
}

list_mask()
{
local ipv="$1"
if [ "$ipv" = 4 ]; then
for i in `seq 32 -1 0`; do
write_enum_item "$i" "/$i ($(ipv4addr_prefix_to_mask "$i"))"
done
else
for i in `seq 128 -1 0`; do
write_enum_item "$i" "/$i"
done
fi
}

list_controlled()
{
local bridge="$1"; shift
write_enum_item "etcnet" "Etcnet"
if [ -f "/usr/sbin/NetworkManager" ] && ! test_bool "$bridge"; then
write_enum_item "NetworkManager" "NetworkManager"
fi
write_enum_item "nothing" "`_ "not under control"`"
}

list_configuration()
{
local ipv="$1"
[ "$ipv" = 6 ] && write_enum_item "ra" "`_ "Use RA only"`"
write_enum_item "dhcp" "`_ "Use DHCP"`"
[ "$ipv" = 4 ] && write_enum_item "ipv4ll" "`_ "Use Zeroconf"`"
write_enum_item "static" "`_ "Manually"`"
}

read_info()
{
local name="$1";shift
[ -n "$name" ] || return 0

local info="`_ "Network adaptor:"`"
info="$info
$(netdev_read_info "$name")"

if ! netdev_is_wireless "$name"; then
if netdev_is_plugged "$name";then
info="$info
`_ "plugged"`"
else
info="$info
`_ "unplugged"`"
fi
fi
echo "$info"
}

read_controlled()
{
local nm_controlled="$(read_iface_option "$1" NM_CONTROLLED)"
local disabled="$(read_iface_option "$1" DISABLED)"

if [ $(write_bool "$nm_controlled") = "#t" ];then
echo 'NetworkManager'
elif [ $(write_bool "$disabled") = "#f" ];then
echo 'etcnet'
else
echo "nothing"
fi
}

read_configuration()
{
local bootproto="$(read_iface_option "$1" BOOTPROTO)"
local ipv="$2"
local config=

case "$bootproto" in
static)
# If there is no IPv6 static configuration
# then it is RA really.
if [ "$ipv" = 6 ] &&
[ ! -s "$1/ipv6address" ] &&
[ ! -s "$1/ipv6route" ]; then
config='ra'
else
config='static'
fi
;;
ipv4ll)
if [ "$ipv" = 6 ]; then
config='ra'
else
config='ipv4ll'
fi
;;
dhcp|dhcp[-,\ ]*)
if [ "$ipv" = 4 ]; then
config='dhcp'
else
# Very strange logic in etcnet
config='ra'
fi
;;
dhcp6|dhcp6[-,\ ]*)
if [ "$ipv" = 4 ]; then
# Very strange logic in etcnet
config='static'
else
config='dhcp'
fi
;;
*)
if [ "$ipv" = 4 ]; then
config='dhcp'
else
config='ra'
fi
;;
esac

echo "$config"
}

read_config_ipv()
{
local ifacedir="$1"; shift
local v="$1"; shift
local enabled="$(read_iface_option "$ifacedir" CONFIG_IPV$v)"

case "$enabled" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|[Yy]|1) echo yes ;;
*) echo no ;;
esac
}

get_ifacedir()
{
local name="$1"; shift

if [ -d "$cachedir/$name" ];then
echo "$cachedir/$name"
else
echo "/etc/net/ifaces/$name"
fi
}

read_iface()
{
local name="$1"; shift
local ipv="$1"; shift
local ifacedir="$(get_ifacedir "$name")"
local bridge=no

#collect general information
local real_name="$(real_iface "$ifacedir")"
write_string_param real_name "$real_name"

write_bool_param ipv_enabled "$(read_config_ipv "$ifacedir" "$ipv")"
write_string_param adaptor "$(read_info "$real_name")"
write_string_param configuration "$(read_configuration "$ifacedir" "$ipv")"
write_string_param controlled "$(read_controlled "$ifacedir")"
write_bool_param wireless "$(netdev_is_wireless "$real_name" && echo "yes" || echo "no")"

write_string_param dns "$(read_iface_dns "$ifacedir")"
write_string_param search "$(read_iface_search "$ifacedir")"

write_string_param default "$(read_iface_default_gw "$ifacedir" "$ipv")"

is_bridge "$ifacedir" && bridge=yes
write_bool_param bridge "$bridge"
}

write_controlled()
{
local ifacedir="$1";shift
local controlled="$1";shift

case "$controlled" in
NetworkManager)
write_iface_option "$ifacedir" DISABLED yes
write_iface_option "$ifacedir" NM_CONTROLLED yes
;;
etcnet)
write_iface_option "$ifacedir" DISABLED no
write_iface_option "$ifacedir" NM_CONTROLLED no
;;
nothing)
write_iface_option "$ifacedir" DISABLED yes
write_iface_option "$ifacedir" NM_CONTROLLED no
;;
esac
}

# Try to determine BOOTPROTO according with
# that brain-damaged logic in etcnet
get_etcnet_bootproto()
{
local ipv4config="$1"; shift
local ipv6config="$1"; shift
local bootproto=

if [ -z "$ipv4config" ]; then
case "$ipv6config" in
dhcp) bootproto=dhcp6 ;;
*) bootproto=static ;; # static | ra
esac
elif [ -z "$ipv6config" ]; then
bootproto="$ipv4config"
else
case "$ipv4config" in
static)
if [ "$ipv6config" = dhcp ]; then
bootproto=dhcp6
else # static | ra
bootproto=static
fi
;;
ipv4ll)
if [ "$ipv6config" = ra ]; then
bootproto=ipv4ll
else # static | dhcp
# Cannot be defined
bootproto=
fi
;;
dhcp)
if [ "$ipv6config" = ra ]; then
bootproto=dhcp
else # static | dhcp
# Cannot be defined
bootproto=
fi
;;
esac
fi

echo "$bootproto"
}

write_configuration()
{
local ifacedir="$1";shift
local configuration="$1";shift
local ipv="$1"; shift
local bootproto=
local ipv4config= ipv6config=

if [ "$ipv" = 4 ]; then
ipv4config="$configuration"
[ "$(read_config_ipv "$ifacedir" 6)" = yes ] &&
ipv6config="$(read_configuration "$ifacedir" 6)"
else
ipv6config="$configuration"
[ "$(read_config_ipv "$ifacedir" 4)" = yes ] &&
ipv4config="$(read_configuration "$ifacedir" 4)"
fi

bootproto="$(get_etcnet_bootproto "$ipv4config" "$ipv6config")"

if [ -n "$bootproto" ]; then
write_iface_option "$ifacedir" BOOTPROTO "$bootproto"
if [ "$ipv" = 6 -a "$ipv6config" = ra ]; then
# Actually RA-only it is static without configuration.
# So remove ipv6* config files.
rm -f "$ifacedir/ipv6address" "$ifacedir/ipv6route"
fi
else
write_error "`_ "IPv4 and IPv6 configurations are incompatible:"` $ipv4config and $ipv6config"
return 1
fi

return 0
}

write_config_ipv()
{
local ifacedir="$1"; shift
local v="$1"; shift
local enabled="$1"; shift
local config_ipv=

test_bool "$enabled" && config_ipv=yes || config_ipv=no
write_iface_option "$ifacedir" CONFIG_IPV$v "$config_ipv"
}

check_dns()
{
local ifacedir="$1"; shift
local ns_list="$1"; shift
local config_ipv4="$(read_config_ipv "$ifacedir" 4)"
local config_ipv6="$(read_config_ipv "$ifacedir" 6)"

for ns in $ns_list; do
if [ "$config_ipv4" = no ] && check_ip "$ns" 4; then
return 1
elif [ "$config_ipv6" = no ] && check_ip "$ns" 6; then
return 1
fi
done

return 0
}

write_iface()
{
local name="$1"; shift
local bridge="${1-}"
local ifacedir="$cachedir/$name"
local real_name= is_wireless=

if [ -z "$bridge" ]; then
is_bridge "$ifacedir" && bridge="#t" || bridge="#f"
fi
if test_bool "$bridge"; then
# During the creation a new bridge HOST not setted yet
local host="$(real_iface "$ifacedir")"
[ "$name" != "$host" ] || host="${name#br}"
write_iface_option "$ifacedir" TYPE bri
write_iface_option "$ifacedir" HOST "$host"
[ "$in_controlled" != NetworkManager ] || in_controlled=etcnet
real_name="$host"
else
write_iface_option "$ifacedir" TYPE eth
shell_config_del "$ifacedir/options" HOST
real_name="$name"
fi

netdev_is_wireless "$real_name" && is_wireless=yes || is_wireless=no
write_iface_option "$ifacedir" CONFIG_WIRELESS "$is_wireless"

[ -n "$in_ipv_enabled" ] &&
write_config_ipv "$ifacedir" "$in_ipv" "$in_ipv_enabled"

is_defined "in_default" &&
test_bool "$in_ipv_enabled" &&
write_iface_default_gw "$ifacedir" "$in_default" "$in_ipv"

[ -n "$in_controlled" ] &&
write_controlled "$ifacedir" "$in_controlled"

[ -n "$in_configuration" ] &&
test_bool "$in_ipv_enabled" &&
write_configuration "$ifacedir" "$in_configuration" "$in_ipv"

if is_defined "in_dns"; then
check_dns "$ifacedir" "$in_dns" &&
write_iface_dns "$ifacedir" "$in_dns" ||
write_error "`_ "Invalid DNS list"`"
fi

is_defined "in_search" &&
write_iface_search "$ifacedir" "$in_search"
}

check_ip()
{
local ip="$1"
local ipv="$2"

if [ "$ipv" = 4 ]; then
valid_ipv4 "$ip"
else
valid_ipv6addr "$ip"
fi
}

check_prefix()
{
local prefix="$1"
local ipv="$2"
local max=

[ "$ipv" = 4 ] &&
max=32 ||
max=128

[ -n "$prefix" -a $prefix -ge 0 -a $prefix -le $max ]
}

add_iface_address()
{
local iface="$1"
local addr="$2"
local mask="$3"
local v="$4"


if ! check_ip "$addr" "$v" || ! check_prefix "$mask" "$v"; then
write_error "`_ "Invalid IP address:"` $addr/$mask"
return 1
fi
if [ -n "$iface" -a -n "$addr" -a -n "$mask" ] ; then
echo "$addr/$mask" >> "$cachedir/$iface/ipv${v}address"
fi
}

del_iface_address()
{
local iface="$1"
local addr="$2"
local v="$3"
if [ -n "$iface" -a -n "$addr" ] ; then
sed -i -e "s|^${addr}$||" -e '/^$/d' "$cachedir/$iface/ipv${v}address"
fi
}

list_iface_addresses()
{
local name="$1"; shift
local v="$1"; shift
[ -n "$name" ] || name="$(list_eth_cached|head -n1)"

local ifacedir="$(get_ifacedir "$name")"

[ -s "$ifacedir/ipv${v}address" ] && cat "$ifacedir/ipv${v}address" | write_enum
}

#initial actions
iface_up lo
clear_cache


# do not setup domain name if alterator-net-domain installed to current system
if [ -f "$ALTERATOR_DOMAIN" ];then
NAME_CHECK=system-computer-name
else
NAME_CHECK=hostname
fi

alterator_export_var \
computer_name $NAME_CHECK \
search hostname-list \
dns ip-address-list
# default ipv4-address \
# addresses ipv4-addrwmask-list \

on_message()
{
case "$in_action" in

add_iface_address)
init_cache "$in_name" "$in_bridge"
add_iface_address "$in_name" "${in_addip}" "${in_addmask}" "$in_ipv"
;;
del_iface_address)
init_cache "$in_name" "$in_bridge"
del_iface_address "$in_name" "$in_addresses" "$in_ipv"
;;
list)
case "${in__objects##*/}" in
avail_ipv) list_ipv;;
avail_masks) list_mask "$in_ipv";;
avail_configurations) list_configuration "$in_ipv";;
avail_controlled) list_controlled "$in_bridge";;
avail_iface_address) list_iface_addresses "$(name_with_bridge "$in_name")" "$in_ipv";;
*) list_eth_cached|write_enum;;
esac
;;
read)
local name="${in_name}"
[ -n "$name" ] || name="$(list_eth_cached|head -n1)"
name="$(name_with_bridge "$name")"
case "$in__objects" in
/)
[ -n "$name" ] && read_iface "$name" "$in_ipv"

write_string_param name "$name"

write_string_param computer_name "$(read_computer_name)"
write_string_param computer_domain "$(read_computer_domain)"
;;
controlled)
local controlled="$(read_controlled "$(get_ifacedir "$name")")"
if test_bool "$in_bridge" && [ "$controlled" = 'NetworkManager' ]; then
controlled='etcnet';
fi
write_string_param controlled "$controlled"
;;
esac
;;
write)
if [ -n "$in_reset" ]; then
clear_cache
return
fi
local name="${in_name}"
[ -n "$name" ] || name="$(list_eth_cached|head -n1)"
init_cache "$name" "$in_bridge"

[ -n "$name" ] && write_iface "$name" "$in_bridge"

[ -n "$in_computer_name" ] && write_computer_name "$in_computer_name"

if [ -n "$in_commit" ]; then
commit_cache || return
fi
;;
esac
}

message_loop
alterator-net-eth-4.16.0/hook/000075500000000000000000000000001205343555700161105ustar00rootroot00000000000000alterator-net-eth-4.16.0/hook/hosts-hook-hostname000064400000000000000000000011441205343555700217450ustar00rootroot00000000000000#!/bin/sh -eu

old_hostname="$1"
new_hostname="$2"

[ -n "$new_hostname" ] || exit 1

grep -qs "^[^#]*\<$new_hostname\>" /etc/hosts ||
printf '127.0.0.1\t%s %s\n' "$new_hostname" "${new_hostname%%.*}" >> /etc/hosts

short_old_hostname="${old_hostname%%.*}"

[ -z "$old_hostname" -o "$old_hostname" = "$new_hostname" \
-o "$short_old_hostname" = 'localhost' ] ||
sed -ri -e "/^127\.0\.0\.1[[:blank:]]+$old_hostname[[:blank:]]+$short_old_hostname/d" \
-e "/^127\.0\.0\.1[[:blank:]]+$old_hostname[[:blank:]]*$/d" \
-e "/^127\.0\.0\.1[[:blank:]]+$short_old_hostname[[:blank:]]*$/d" \
/etc/hosts
alterator-net-eth-4.16.0/ui/000075500000000000000000000000001205343555700155655ustar00rootroot00000000000000alterator-net-eth-4.16.0/ui/net-eth/000075500000000000000000000000001205343555700171315ustar00rootroot00000000000000alterator-net-eth-4.16.0/ui/net-eth/advanced/000075500000000000000000000000001205343555700206765ustar00rootroot00000000000000alterator-net-eth-4.16.0/ui/net-eth/advanced/ajax.scm000064400000000000000000000027421205343555700223320ustar00rootroot00000000000000(define-module (ui net-eth advanced ajax)
:use-module (alterator ajax)
:use-module (alterator woo)
:export (init))

(define (ui-read name)
(catch/message
(lambda()
(let* ((cmd (woo-read-first "/net-eth" 'name name))
(is_bridge (woo-get-option cmd 'bridge)))
(form-update-enum "controlled" (woo-list "/net-eth/avail_controlled" 'bridge is_bridge))
(form-update-value "iface" name)
(form-update-value-list '("name" "controlled" "bridge") cmd)))))


(define (ui-exit)
(form-replace (format #f "/net-eth?iface=~A" (form-value "name"))))

(define (ui-write)
(catch/message
(lambda()
(woo-write "/net-eth"
'name (form-value "name")
'controlled (form-value "controlled")
'bridge (form-value "bridge"))
(ui-exit))))

(define (bridge-changed)
(let* ((name (form-value "name"))
(is_bridge (form-value "bridge"))
(new-name (if is_bridge
(string-append "br" name)
(substring name 2)))
(cmd (woo-read-first "/net-eth/controlled" 'name name 'bridge is_bridge)))
(form-update-value "name" new-name)
(form-update-value "iface" new-name)
(form-update-enum "controlled" (woo-list "/net-eth/avail_controlled" 'bridge is_bridge))
(form-update-value "controlled" (woo-get-option cmd 'controlled))))

(define (init)
(ui-read (form-value "iface"))
(form-bind "bridge" "change" bridge-changed)
(form-bind "ok" "click" ui-write)
(form-bind "cancel" "click" ui-exit))
alterator-net-eth-4.16.0/ui/net-eth/advanced/index.html000064400000000000000000000020101205343555700226640ustar00rootroot00000000000000<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<!-- tcp connections module -->
<html wf="none">
<body>
<form method="POST" id="ajax-select">
<input type="hidden" name="name"/>
<table class="form-table">
<tr>
<td><span translate="_">Interface:</span></td>
<td><span name="iface" class="alterator-label"/></td>
</tr>
<tr>
<td><span translate="_">Network subsystem:</span></td>
<td><select name="controlled" enumref="/net-eth/avail_controlled"></select></td>
</tr>
<tr>
<td><span translate="_" name="bridge">Use interface as bridge</span></td>
<td><input type="checkbox" name="bridge" value="#t"/></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="button" name="ok" value="OK" class="btn"/>
&nbsp;
<input type="button" name="cancel" value="Cancel" class="btn"/>
</td>
</tr>
</table>
</form>
</body>
</html>
alterator-net-eth-4.16.0/ui/net-eth/advanced/index.scm000064400000000000000000000034621205343555700225160ustar00rootroot00000000000000(document:surround "/std/frame")

(define *name* (global 'name))

;;; Functions
(define (ui-read)
(catch/message
(lambda()
(let* ((cmd (woo-read-first "/net-eth" 'name *name*))
(is_bridge (woo-get-option cmd 'bridge)))
(form-update-enum "controlled" (woo-list "/net-eth/avail_controlled" 'bridge is_bridge))

(form-update-value-list '("name" "controlled" "bridge") cmd)))))

(define (ui-exit)
(document:end))

(define (ui-write)
(catch/message
(lambda()
(woo-write "/net-eth"
'name (form-value "name")
'controlled (form-value "controlled")
'bridge (form-value "bridge"))
(ui-exit))))

(define (bridge-changed)
(let* ((name (form-value "name"))
(is_bridge (form-value "bridge"))
(new-name (if is_bridge
(string-append "br" name)
(substring name 2)))
(cmd (woo-read-first "/net-eth/controlled" 'name name 'bridge is_bridge)))
(form-update-value "name" new-name)
(form-update-enum "controlled" (woo-list "/net-eth/avail_controlled" 'bridge is_bridge))
(form-update-value "controlled" (woo-get-option cmd 'controlled))))

;;; UI

width 600
height 300

(gridbox
columns "0;100"
margin "10"

;;
(label text (_ "Interface:") align "right")
(label name "name")

;;
(label text (_ "Network subsystem:") align "right" name "controlled")
(combobox name "controlled")
;;
(label text (_ "Use interface as bridge") align "right" name "bridge")
(checkbox name "bridge")
;;
(label colspan 2)

;;
(spacer)
(hbox align "left"
(button (_ "OK") name "ok")
(button (_ "Cancel") name "cancel")))

;;
(document:root
(when loaded
(ui-read)
(form-bind "bridge" "change" bridge-changed)
(form-bind "ok" "click" ui-write)
(form-bind "cancel" "click" ui-exit)))
alterator-net-eth-4.16.0/ui/net-eth/ajax.scm000064400000000000000000000117311205343555700205630ustar00rootroot00000000000000(define-module (ui net-eth ajax)
:use-module (srfi srfi-1)
:use-module (alterator ajax)
:use-module (alterator algo)
:use-module (alterator woo)
:export (init))

;;; low level

(define *prev_ipv* (make-cell ""))

(define (update-configuration-activity configuration)
(form-update-activity
'("addresses" "ip" "add-mask" "add-ip" "default" "btn-add-ip" "btn-del-ip" "ipl_label"
"search_comment" "dns" "search")
(and (form-value "ipv_enabled") (string=? configuration "static"))))

(define (update-ipv-activity)
(form-update-activity "configuration" (form-value "ipv_enabled"))
(update-configuration-activity (form-value "configuration")))

(define (ipv_changed)
(let ((name (form-value "name"))
(ipv (form-value "ipv"))
(prev_ipv (cell-ref *prev_ipv*)))
(if (not (string=? ipv prev_ipv))
(begin
(cell-set! *prev_ipv* ipv)
; write configuration for previous ipv
(catch/message
(lambda()
(write-interface name prev_ipv)))
; and read for current ipv
(catch/message
(lambda()
(reset-enums ipv)
(read-interface name ipv)))))))

(define (read-interface-address name)
(catch/message (lambda()
(form-update-enum "addresses"
(woo-list "/net-eth/avail_iface_address" 'name name 'ipv (form-value "ipv"))))))

(define (read-interface name ipv)
(let ((cmd (woo-read-first "/net-eth" 'name name 'ipv ipv 'language (form-value "language"))))
(form-update-visibility
"wireless"
(and (woo-get-option cmd 'wireless)
(string=? (woo-get-option cmd 'controlled) "etcnet")))
(form-update-value-list
'("name" "real_name" "ipv_enabled")
cmd)
(form-update-value-list
'("computer_name" "dns" "search")
cmd)
(read-interface-address name)
(form-update-value-list
'("adaptor" "add-mask" "default" "configuration")
cmd)
(update-ipv-activity)))

(define (write-interface name ipv)
(apply woo-write
"/net-eth"
'name name
'ipv ipv
(form-value-list '("language" "ipv_enabled"
"computer_name" "dns" "search"
"default" "configuration"))))

;;; high level

(define (update-interface)
(or (catch/message
(lambda()
(let ((name (form-value "name"))
(ipv (form-value "ipv")))
(write-interface (form-value "prev_name") ipv)
(read-interface name ipv)
(form-update-value "prev_name" name))))
(form-update-value "name" (form-value "prev_name"))))

(define (advanced-interface)
(let ((name (form-value "name"))
(ipv (form-value "ipv")))
(and (catch/message
(lambda()
(write-interface name ipv)))
(form-replace "/net-eth/advanced" 'iface name))))

(define (wireless-interface)
(format #t "wireless-interface:real_name=~S~%" (form-value "real_name"))
(form-replace "/net-wifi/" 'iface (form-value "real_name")))

(define (commit-interface)
(begin
(catch/message
(lambda()
(write-interface (or (form-value "name") "") (form-value "ipv"))
(woo-write "/net-eth" 'commit #t))))
)

(define (reset-enums ipv)
(form-update-enum "add-mask" (woo-list "/net-eth/avail_masks" 'ipv ipv 'language (form-value "language")))
(form-update-value "add-mask" (if (string=? ipv "4") "24" "64"))
(form-update-enum "configuration" (woo-list "/net-eth/avail_configurations" 'ipv ipv 'language (form-value "language")))
(form-update-enum "name" (woo-list "/net-eth/avail_ifaces" 'language (form-value "language"))))

(define (reset-interface)
(catch/message
(lambda()
(let ((ipv (form-value "ipv")))
(woo-write "/net-eth" 'reset #t)

(reset-enums ipv)
(read-interface "" ipv)
(form-update-value "prev_name" "")))))

(define (init-interface)
(form-update-enum "ipv" (woo-list "/net-eth/avail_ipv"))
(form-update-value "ipv" "4")
(cell-set! *prev_ipv* "4")
(catch/message
(lambda()
(reset-enums "4")
(read-interface (or (form-value "iface") "") "4")
(form-update-value "prev_name" (or (form-value "iface") "")))))

(define (ui-append-address)
(and (catch/message (lambda()
(apply woo "add_iface_address" "/net-eth"
(form-value-list '("language" "ipv" "name" "add-ip" "add-mask")))))
(read-interface-address (form-value "name"))
(form-update-value "add-ip" "")))

(define (ui-delete-address)
(catch/message (lambda()
(apply woo "del_iface_address" "/net-eth"
(form-value-list '("language" "ipv" "name" "addresses")))))
(read-interface-address (form-value "name"))
)

(define (init)
(init-interface)
(form-bind "name" "change" update-interface)
(form-bind "ipv" "change" ipv_changed)
(form-bind "ipv_enabled" "change" update-ipv-activity)
(form-bind "configuration" "change" (lambda() (update-configuration-activity (form-value "configuration"))))
(form-bind "advanced" "click" advanced-interface)
(form-bind "wireless" "click" wireless-interface)
(form-bind "btn-del-ip" "click" ui-delete-address)
(form-bind "btn-add-ip" "click" ui-append-address)

(form-bind "commit" "click" commit-interface)
(form-bind "reset" "click" reset-interface))
alterator-net-eth-4.16.0/ui/net-eth/index.html000064400000000000000000000073031205343555700211310ustar00rootroot00000000000000<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<!-- tcp connections module -->
<html wf="none">
<body>
<form method="POST">
<table>
<tr>
<td colspan="2">
<table class="form-table">
<tr>
<td><span translate="_" nameref="computer_name">Computer name:</span></td>
<td><input type="text" class="text" name="computer_name"/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="2"><strong><span translate="_">Interfaces</span></strong></td>
</tr>
<tr>
<td>
<select name="name" enumref="/net-eth" size="16" style="width:150px"/>
<input type="hidden" name="prev_name"/>
<input type="hidden" name="real_name"/>
</td>
<td>
<table class="form-table">
<tr>
<td colspan="2">
<textarea rows="3" readonly="yes" name="adaptor" style="width:98%"/>
</td>
</tr>
<tr>
<td align="right"><span translate="_">Select IP version:</span></td>
<td>
<select name="ipv"/>
<input type="checkbox" name="ipv_enabled" value="#t"/>
<b><span translate="_">Enable</span></b>
</td>
</tr>
<tr>
<td><span translate="_">Configuration:</span></td>
<td><select name="configuration" enumref="/net-eth/avail_configurations"></select></td>
</tr>

<tr><td/><td><hr/></td></tr>

<tr>
<td><span translate="_" nameref="addresses">IP addresses:</span></td>
<td>
<table style="width:98%">
<tr>
<td style="width:98%"><select name="addresses" size="4" style="width:98%"/></td>
<td><input type="button" name="btn-del-ip" value="Delete" class="btn"/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td></td>
<td>
<span translate="_" nameref="add-ip">IP:</span>
<input type="text" class="text" name="add-ip"></input>
<select name="add-mask" enumref="/net-eth/avail_masks"></select>
<input type="button" name="btn-add-ip" value="Add" class="btn"/>
</td>
</tr>

<tr><td/><td><hr/></td></tr>

<tr>
<td><span translate="_" nameref="default">Default gateway:</span></td>
<td><input type="text" class="text" name="default"></input></td>
</tr>

<tr>
<td><span translate="_" nameref="dns">DNS servers:</span></td>
<td><input type="text" class="text" name="dns"/></td>
</tr>
<tr>
<td><span translate="_" nameref="search">Search domains:</span></td>
<td><input type="text" class="text" name="search"/></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<small><span name="search_comment" translate="_">(multiple values should be space separated)</span></small>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="button" name="wireless" value="Wireless settings..." class="btn" style="display:none;text-align:right"/></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="button" name="advanced" value="Advanced..." class="btn" style="text-align:right"/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">
<input type="button" name="commit" value="Apply" class="btn"/>
&nbsp;
<input type="button" name="reset" value="Reset" class="btn"/>
</td>
</tr>
</table>
</form>
</body>
</html>
alterator-net-eth-4.16.0/ui/net-eth/index.scm000064400000000000000000000160201205343555700207430ustar00rootroot00000000000000(document:surround "/std/frame")

;;; Functions

(define *prev_ipv* (make-cell "4"))

(define (update-configuration-activity configuration)
(form-update-activity
'("addresses" "default" "btn-del-ip" "ipl_label" "dns" "search" "search_comment")
(and (form-value "ipv_enabled") (string=? configuration "static"))))

(define (update-ipv-activity)
(form-update-activity "configuration" (form-value "ipv_enabled"))
(update-configuration-activity (form-value "configuration")))

(define (ipv_changed)
(let ((name (form-value "name"))
(ipv (form-value "ipv"))
(prev_ipv (cell-ref *prev_ipv*)))
(if (not (string=? ipv prev_ipv))
(begin
(cell-set! *prev_ipv* ipv)
; write configuration for previous ipv
(catch/message
(lambda()
(write-interface name prev_ipv)))
; and read for current ipv
(catch/message
(lambda()
(reset-enums ipv)
(read-interface name ipv)))))))

(define (read-interface-address name)
(catch/message (lambda()
(form-update-enum "addresses"
(woo-list "/net-eth/avail_iface_address" 'name name 'ipv (form-value "ipv"))))))

(define (read-interface name ipv)
(let ((cmd (woo-read-first "/net-eth" 'name name 'ipv ipv)))
(form-update-visibility
"wireless"
(and (woo-get-option cmd 'wireless)
(string=? (woo-get-option cmd 'controlled) "etcnet")))
(form-update-value-list
'("name" "real_name" "ipv_enabled")
cmd)
(form-update-value-list
'("computer_name" "dns" "search")
cmd)
(form-update-value-list
'("add-mask" "adaptor" "default" "configuration")
cmd)
(read-interface-address name)
(form-update-value-list
'("configuration")
cmd)
(update-ipv-activity)
)
)

(define (write-interface name ipv)
(apply woo-write
"/net-eth"
'name name
'ipv ipv
(form-value-list '("ipv_enabled" "computer_name" "dns" "search" "default" "configuration"))
))

(define (commit-interface)
(catch/message
(lambda()
(write-interface (or (form-value "name") "") (form-value "ipv"))
(woo-write "/net-eth" 'commit #t))))

(define (reset-enums ipv)
(form-update-enum "add-mask" (woo-list "/net-eth/avail_masks" 'ipv ipv))
(form-update-value "add-mask" (if (string=? ipv "4") "24" "64"))
(form-update-enum "configuration" (woo-list "/net-eth/avail_configurations" 'ipv ipv))
(form-update-enum "name" (woo-list "/net-eth/avail_ifaces")))

(define (reset-interface)
(catch/message
(lambda()
(let ((ipv (form-value "ipv")))
(woo-write "/net-eth" 'reset #t 'ipv ipv)
(reset-enums ipv)
(read-interface "" ipv)
(form-update-value "prev_name" (form-value "name"))))))

(define (init-interface)
(form-update-enum "ipv" (woo-list "/net-eth/avail_ipv"))
(form-update-value "ipv" "4")
(reset-interface))

(define (update-interface)
(or (catch/message
(lambda()
(let ((name (form-value "name"))
(ipv (form-value "ipv")))
(write-interface (form-value "prev_name") ipv)
(read-interface name ipv)
(form-update-value "prev_name" name))))
(form-update-value "name" (form-value "prev_name"))))

(define (advanced-interface)
(let ((name (form-value "name"))
(ipv (form-value "ipv")))
(and (catch/message
(lambda()
(write-interface name ipv)))
(begin
(form-popup "/net-eth/advanced" 'name name)
(form-update-enum "name" (woo-list "/net-eth/avail_ifaces"))
(read-interface name ipv)
(form-update-value "prev_name" (or (form-value "name") ""))))))

(define (wireless-interface)
(format #t "wireless-interface:real_name=~S~%" (form-value "real_name"))
(form-popup "/net-wifi/" 'iface (form-value "real_name")))

(define (ui-append-address)
(and (catch/message (lambda()
(apply woo "add_iface_address" "/net-eth"
(form-value-list '("language" "ipv" "name" "add-ip" "add-mask")))))
(read-interface-address (form-value "name"))
(form-update-value "add-ip" "")))

(define (ui-delete-address)
(catch/message (lambda()
(apply woo "del_iface_address" "/net-eth"
(form-value-list '("language" "ipv" "name" "addresses")))))
(read-interface-address (form-value "name"))
)

;;; UI

(edit name "prev_name" text "" visibility #f)
(edit name "real_name" text "" visibility #f)
(gridbox
columns "0;100"
margin 10

(gridbox
colspan 2
columns "0;40;60"

;;
(label text (_ "Computer name:") nameref "computer_name" align "right")
(edit name "computer_name")
(spacer)
)

(separator colspan 2)

(label colspan 2 text (bold (_ "Interfaces")))

(listbox name "name" max-width 155)
(gridbox
columns "0;100"

;;
(textbox colspan 2 name "adaptor" max-height 70 alterability #f)

;;
(hbox align "left" colspan 2
(label text (_ "Select IP version:"))
(combobox name "ipv")
(checkbox name "ipv_enabled" text (_ "Enable")))
;;
(label text (_ "Configuration:") align "right" nameref "configuration")
(combobox name "configuration")

;;
;(spacer)(separator)

;;
(label name "ipl_label" text (_ "IP addresses:") align "right" nameref "addresses")
(gridbox columns "100;0"
(document:id ui-addresses (listbox name "addresses" max-height 70))
(button (_ "Delete") name "btn-del-ip" nameref "addresses")
)
(spacer)
(gridbox columns "0;50;50;0" nameref "addresses"
(label text (_ "IP:"))
(document:id ui-add-ip (edit name "add-ip"))
(document:id ui-add-mask (combobox name "add-mask"))
(button (_ "Add") name "btn-add-ip")
)

;;
;(spacer)(separator)

;;
(label text (_ "Default gateway:") align "right" nameref "default")
(edit name "default")

;;
(label text (_ "DNS servers:") nameref "dns" align "right")
(edit name "dns")

;;
(label text (_ "Search domains:") nameref "search" align "right")
(edit name "search")

;;
(spacer)(label name "search_comment" text (small (_ "(multiple values should be space separated)")))

;;
(button text (_ "Wireless settings...") name "wireless" align "right" visibility #f)
(button text (_ "Advanced...") name "advanced" align "right"))

;;
(or (global 'frame:next)
(label colspan 2))

;;
(or (global 'frame:next)
(hbox align "left"
colspan 2
(button (_ "Apply") name "apply")
(button (_ "Reset") name "reset"))))

;;;;;;;;;;;;;;;;;;

(document:root
(when loaded
(init-interface)
(form-bind "name" "change" update-interface)
(form-bind "ipv" "change" ipv_changed)
(form-bind "ipv_enabled" "change" update-ipv-activity)
(form-bind "configuration" "change" (lambda() (update-configuration-activity (form-value "configuration"))))
(form-bind "advanced" "click" advanced-interface)
(form-bind "wireless" "click" wireless-interface)
(form-bind "btn-del-ip" "click" ui-delete-address)
(form-bind "btn-add-ip" "click" ui-append-address)
(or (global 'frame:next)
(begin (form-bind "apply" "click" commit-interface)
(form-bind "reset" "click" reset-interface)))))

(frame:on-back (lambda() (or (commit-interface) 'cancel)))
(frame:on-next (lambda() (or (commit-interface) 'cancel)))
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009