临时

auth
require-pap
logfile /var/log/pppd.log
+ipv6
ipv6 ::1,::2
复制代码
#!/bin/sh

# These variables are for the use of the scripts run by run-parts.
PPP_IFACE="$1"
PPP_TTY="$2"
PPP_SPEED="$3"
PPP_LOCAL="$4"
PPP_REMOTE="$5"
PPP_IPPARAM="$6"
export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM

# The environment is cleared before executing this script.
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
export PATH

# If /var/log/ppp-ipupdown.log exists use it for logging.
if [ -e /var/log/ppp-ipupdown.log ]; then
  exec >> /var/log/ppp-ipupdown.log 2>&1
fi

# This script can be used to override the .d files supplied by other packages.
if [ -x /etc/ppp/ipv6-up.local ]; then
  exec /etc/ppp/ipv6-up.local "$@"
fi

run-parts /etc/ppp/ipv6-up.d \
  --arg="$1" --arg="$2" --arg="$3" --arg="$4" --arg="$5" --arg="$6"

# if pon was called with the "quick" argument, stop pppd
if [ -e /var/run/ppp-quick ]; then
  rm /var/run/ppp-quick
  wait
  kill $PPPD_PID
fi

/etc/ppp/add_radvd_conf.sh ${PPP_IFACE}
/etc/ppp/add_dibbler_conf.sh ${PPP_IFACE}
复制代码
复制代码
#!/bin/sh

# These variables are for the use of the scripts run by run-parts.
PPP_IFACE="$1"
PPP_TTY="$2"
PPP_SPEED="$3"
PPP_LOCAL="$4"
PPP_REMOTE="$5"
PPP_IPPARAM="$6"
export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM

# The environment is cleared before executing this script.
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
export PATH

# If /var/log/ppp-ipupdown.log exists use it for logging.
if [ -e /var/log/ppp-ipupdown.log ]; then
  exec >> /var/log/ppp-ipupdown.log 2>&1
fi

# This script can be used to override the .d files supplied by other packages.
if [ -x /etc/ppp/ipv6-down.local ]; then
  exec /etc/ppp/ipv6-down.local "$@"
fi

run-parts /etc/ppp/ipv6-down.d \
  --arg="$1" --arg="$2" --arg="$3" --arg="$4" --arg="$5" --arg="$6"

/etc/ppp/del_radvd_conf.sh ${PPP_IFACE}
/etc/ppp/del_dibbler_conf.sh ${PPP_IFACE}
复制代码
复制代码
#!/bin/sh

radvd_conf=/etc/radvd.conf
lockfile="/tmp/radvdlock"
tryCount=50
ifname=$1
ttyName="/dev/pts/17"

#防止多个 ppp 节点同时生成同时操作 radvd 配置文件,故设置文件锁
while [ ${tryCount} -gt 0 ]
do
    if [ -e ${lockfile} ];then
        sleep 1;
    else
    echo `date`":add radvd conf get filelock" > ${ttyName}
        touch ${lockfile};
        trap "rm -f ${lockfile}; exit" 0 1 2 3 9 15
        break;
    fi
    tryCount=$((${tryCount}-1))
done

if [ ${tryCount} -le 0 ];then
    echo `date`":add radvd conf get filelock ${lockfile} time out." > ${ttyName} 
    return
fi

#查找 radvd 配置文件中是否存在对应节点
realstartline=`grep -wn "${ifname}" ${radvd_conf} | cut -d':' -f1`
if [ "a${realstartline}" != "a" ];then
    rm -f ${lockfile};
    echo `date`":add radvd conf release filelock, because ${ifname} has exist." > ${ttyName} 
    return;
fi

# 增加动态节点到 radvd 配置文件
#addconf
echo interface ${ifname} { >> ${radvd_conf} 
echo '  AdvSendAdvert on;' >> ${radvd_conf}
echo '  MinRtrAdvInterval 3;' >> ${radvd_conf}
echo '  MaxRtrAdvInterval 10;' >> ${radvd_conf}
echo '  AdvOtherConfigFlag on;' >> ${radvd_conf}
echo '  AdvManagedFlag on;' >> ${radvd_conf}
echo '  prefix 2022:1:2:3::/64 {' >> ${radvd_conf}
echo '    AdvOnLink on;' >> ${radvd_conf}
echo '    AdvAutonomous on;' >> ${radvd_conf}
echo '    AdvRouterAddr on;' >> ${radvd_conf}
echo '    AdvValidLifetime 500;' >> ${radvd_conf}
echo '    AdvPreferredLifetime 200;' >> ${radvd_conf}
echo '  };' >> ${radvd_conf}
echo '  RDNSS 2022:dba:0:1::100 2022:dba:0:1::200' >> ${radvd_conf}
echo '  {' >> ${radvd_conf}
echo '  };' >> ${radvd_conf}
echo '};' >> ${radvd_conf}
#endconf

cat ${radvd_conf} > ${ttyName} 
service radvd restart

rm -f ${lockfile}
    echo `date`":add radvd conf release filelock on success ${ifname}" > ${ttyName}
复制代码
复制代码
#!/bin/sh

radvd_conf=/etc/radvd.conf
lockfile="/tmp/radvdlock"
tryCount=50
ifname=$1
ttyName="/dev/pts/17"

#通过 add 脚本计算一条 ppp radvd 所占行数
add_radvd_file=/etc/ppp/add_radvd_conf.sh
startline=`grep -n '#addconf' ${add_radvd_file} | cut -d':' -f1`
endline=`grep -n '#endconf' ${add_radvd_file} | cut -d':' -f1`
if [ "a${startline}" = "a" -o "a${endline}" = "a"  ];then
    return
fi
cntline=$((${endline}-${startline}-1))

#防止多个 ppp 节点同时生成同时操作 radvd 配置文件,故设置文件锁
while [ ${tryCount} -gt 0 ]
do
    if [ -e ${lockfile} ];then
        sleep 1;
    else
    echo `date`":del radvd conf get filelock" > ${ttyName} 
        touch ${lockfile};
        trap "rm -f ${lockfile}; exit" 0 1 2 3 9 15
        break;
    fi
    tryCount=$((${tryCount}-1))
done

if [ ${tryCount} -le 0 ];then
    echo `date`":${lockfile} time out." > ${ttyName} 
    return
fi

#查找 radvd 配置文件中是否存在对应节点
realstartline=`grep -wn "${ifname}" ${radvd_conf} | cut -d':' -f1`
if [ "a${realstartline}" = "a" ];then
    rm -f ${lockfile};
    echo `date`":del radvd conf release filelock, because not find startline ${ifname}" > ${ttyName} 
    return;
fi
realendline=$((${realstartline}+${cntline}-1))

#删除 radvd 配置文件中存在对应节点
echo `date`":sed -i "${realstartline},${realendline}d" ${radvd_conf}" > ${ttyName} 
sed -i "${realstartline},${realendline}d" ${radvd_conf}

cat ${radvd_conf} > ${ttyName} 
service radvd restart

rm -f ${lockfile}
    echo `date`":del radvd conf release filelock, on success ${ifname}" > ${ttyName}
复制代码
复制代码
#!/bin/sh

dibbler_conf=/etc/dibbler/server.conf
lockfile="/tmp/dibblerlock"
tryCount=50
ifname=$1

#防止多个 ppp 节点同时生成同时操作 dibbler 配置文件,故设置文件锁
while [ ${tryCount} -gt 0 ]
do
    if [ -e ${lockfile} ];then
        sleep 1;
    else
    echo `date`":add dibbler conf get filelock" > /dev/pts/7
        touch ${lockfile};
        trap "rm -f ${lockfile}; exit" 0 1 2 3 9 15
        break;
    fi
    tryCount=$((${tryCount}-1))
done

if [ ${tryCount} -le 0 ];then
    echo `date`":add dibbler conf get filelock ${lockfile} time out." > /dev/pts/7
    return
fi

#查找 dibbler 配置文件中是否存在对应节点
realstartline=`grep -wn "${ifname}" ${dibbler_conf} | cut -d':' -f1`
if [ "a${realstartline}" != "a" ];then
    rm -f ${lockfile};
    echo `date`":add dibbler conf release filelock, because ${ifname} has exist." > /dev/pts/7
    return;
fi

# 增加动态节点到 dibbler 配置文件
#addconf
echo iface \"${ifname}\" { >> ${dibbler_conf} 
echo '  t1 1800' >> ${dibbler_conf}
echo '  t2 2700' >> ${dibbler_conf}
echo '  prefered-lifetime 3600' >> ${dibbler_conf}
echo '  valid-lifetime 7200' >> ${dibbler_conf}
echo '  class {' >> ${dibbler_conf}
echo '    pool 2002:db8:0:1::129-2002:db9:0:1::254' >> ${dibbler_conf}
echo '  }' >> ${dibbler_conf}
echo '  pd-class {' >> ${dibbler_conf}
echo '    pd-pool 2001:db9:0:10::/60' >> ${dibbler_conf}
echo '    pd-length 64' >> ${dibbler_conf}
echo '  }' >> ${dibbler_conf}
echo '  option dns-server 2001:dbb:0:1::100' >> ${dibbler_conf}
echo } >> ${dibbler_conf}
echo '' >> ${dibbler_conf}
#endconf

cat ${dibbler_conf} > /dev/pts/7
rm -rf /var/lib/dibbler/*
killall dibbler-server
dibbler-server start

rm -f ${lockfile}
    echo `date`":add dibbler conf release filelock on success ${ifname}" > /dev/pts/7
复制代码
复制代码
#!/bin/sh

dibbler_conf=/etc/dibbler/server.conf
lockfile="/tmp/dibblerlock"
tryCount=50
ifname=$1

#通过 add 脚本计算一条 ppp dibbler 所占行数
add_dibbler_file=/etc/ppp/add_dibbler_conf.sh
startline=`grep -n '#addconf' ${add_dibbler_file} | cut -d':' -f1`
endline=`grep -n '#endconf' ${add_dibbler_file} | cut -d':' -f1`
if [ "a${startline}" = "a" -o "a${endline}" = "a"  ];then
    return
fi
cntline=$((${endline}-${startline}-1))

#防止多个 ppp 节点同时生成同时操作 dibbler 配置文件,故设置文件锁
while [ ${tryCount} -gt 0 ]
do
    if [ -e ${lockfile} ];then
        sleep 1;
    else
    echo `date`":del dibbler conf get filelock" > /dev/pts/7
        touch ${lockfile};
        trap "rm -f ${lockfile}; exit" 0 1 2 3 9 15
        break;
    fi
    tryCount=$((${tryCount}-1))
done

if [ ${tryCount} -le 0 ];then
    echo `date`":${lockfile} time out." > /dev/pts/7
    return
fi

#查找 dibbler 配置文件中是否存在对应节点
realstartline=`grep -wn "${ifname}" ${dibbler_conf} | cut -d':' -f1`
if [ "a${realstartline}" = "a" ];then
    rm -f ${lockfile};
    echo `date`":del dibbler conf release filelock, because not find startline ${ifname}" > /dev/pts/7
    return;
fi
realendline=$((${realstartline}+${cntline}-1))

#删除 dibbler 配置文件中存在对应节点
echo `date`":sed -i "${realstartline},${realendline}d" ${dibbler_conf}" > /dev/pts/7
sed -i "${realstartline},${realendline}d" ${dibbler_conf}

cat ${dibbler_conf} > /dev/pts/7
rm -rf /var/lib/dibbler/*
killall dibbler-server
dibbler-server start

rm -f ${lockfile}
    echo `date`":del dibbler conf release filelock, on success ${ifname}" > /dev/pts/7
复制代码

 

posted @   roverqqq  阅读(11)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示