# HG changeset patch # User Pascal Bellard # Date 1430578375 -7200 # Node ID 22d242cf69af91eadbe384dd766ef9c5beecf23e # Parent 5b7188f5cd91b4a75b0ee1b40e62530ebed862fe ppp:add ppp.cgi diff -r 5b7188f5cd91 -r 22d242cf69af ppp/receipt --- a/ppp/receipt Sat May 02 15:04:14 2015 +0200 +++ b/ppp/receipt Sat May 02 16:52:55 2015 +0200 @@ -12,6 +12,8 @@ CONFIG_FILES="/etc/ppp" HOST_ARCH="i486 arm" +SUGGESTED="tazpanel" + # Rules to configure and make the package. compile_rules() { @@ -40,11 +42,14 @@ # Rules to gen a SliTaz package suitable for Tazpkg. genpkg_rules() { - mkdir -p $fs/usr + mkdir -p $fs/usr $fs/var/www/tazpanel/menu.d/network cp -a $install/usr/sbin $fs/usr [ -d "$install/usr/lib" ] && cp -a $install/usr/lib $fs/usr cp -a $stuff/pppnc-server $fs/usr/sbin ln $fs/usr/sbin/pppnc-server $fs/usr/sbin/pppnc-client + cp -a $stuff/ppp.cgi $fs/var/www/tazpanel + ln -s ../../ppp.cgi $fs/var/www/tazpanel/menu.d/network/ppp + # Config files. mkdir -p $fs/etc/ppp/scripts $fs/etc/ppp/ip-up.d $fs/etc/ppp/ip-down.d cp $stuff/README.scripts $fs/etc/ppp diff -r 5b7188f5cd91 -r 22d242cf69af ppp/stuff/ppp.cgi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ppp/stuff/ppp.cgi Sat May 02 16:52:55 2015 +0200 @@ -0,0 +1,338 @@ +#!/bin/sh +# +# Network/PPP configuration CGI interface +# +# Copyright (C) 2015 SliTaz GNU/Linux - BSD License +# + +# Common functions from libtazpanel +. lib/libtazpanel +get_config + + +case "$1" in + menu) + TEXTDOMAIN_original=$TEXTDOMAIN + export TEXTDOMAIN='ppp' + + cat <$(_ 'PPP Modem') +
  • $(_ 'Route shortcut')
  • +EOT + [ "$(which pptp 2>/dev/null)$(which pptpd 2>/dev/null)" ] && cat <$(_ 'VPN PPTP') +EOT + [ "$(which pppssh 2>/dev/null)" ] && cat <$(_ 'VPN PPP/SSH') +EOT + export TEXTDOMAIN=$TEXTDOMAIN_original + exit +esac + + +# +# Commands +# + +case " $(GET) " in +*\ setppprtc\ *) + if [ "$(GET start_rtc)" -a "$(GET user)" ]; then + grep -s "$(GET user)" /etc/ppp/pap-secrets || + echo "$(GET user) * $(GET pass)" >> /etc/ppp/pap-secrets + grep -s "$(GET user)" /etc/ppp/chap-secrets || + echo "$(GET user) * $(GET pass)" >> /etc/ppp/chap-secrets + sed -i 's/^name /d' /etc/ppp/options + echo "name $(GET user)" >> /etc/ppp/options + /etc/ppp/scripts/ppp-off + /etc/ppp/scripts/ppp-on & + fi + if [ "$(GET stop_rtc)" ]; then + /etc/ppp/scripts/ppp-off + fi + ;; +*\ setpppoe\ *) + if [ "$(GET start_pppoe)" -a "$(GET user)" ]; then + grep -s "$(GET user)" /etc/ppp/pap-secrets || + echo "$(GET user) * $(GET pass)" >> /etc/ppp/pap-secrets + grep -s "$(GET user)" /etc/ppp/chap-secrets || + echo "$(GET user) * $(GET pass)" >> /etc/ppp/chap-secrets + grep -qs pppoe /etc/ppp/options || cat > /etc/ppp/options <> /etc/ppp/options + ( . /etc/network.conf ; pppd $INTERFACE & ) + fi + if [ "$(GET stop_pppoe)" ]; then + killall pppd + fi + ;; +*\ setpppnc\ *) + [ "$(GET stop_pppncs)" ] && killall pppnc-server + [ "$(GET start_pppncs)" ] && + pppnc-server $(GET port) "$(GET localip):$(GET remoteip)" & + [ "$(GET stop_pppncc)" ] && killall pppnc-client + [ "$(GET start_pppncc)" ] && + pppnc-client $(GET serverip) $(GET port) "$(GET routes)" & + ;; +*\ setpppssh\ *) + cat > /etc/ppp/pppssh < /dev/null | \ + grep ^ssh | dbclient $(echo $(GET send_key) | sed \ + 's/.*\([A-Za-z0-9_\.-]*\).*/\1/') "mkdir .ssh 2> /dev/null ; \ + while read key; do for i in authorized_keys authorized_keys2; do \ + grep -qs '\$key' .ssh/\$i || echo '\$key' >> .ssh/\$i ; done ; done ; \ + chmod 700 .ssh ; chmod 600 .ssh/authorized_keys*" + fi + if [ "$(GET stop_pppssh)" ]; then + ppp="$(sed '/pppd/!d;s/.*="\([^"]*\).*/\1/' /usr/bin/pppssh)" + kill $(busybox ps x | grep "$ppp" | awk '/dbclient/{print $1}') + fi + if [ "$(GET start_pppssh)" ]; then + pppssh "$(GET ssharg) $(GET peer)" \ + "$(GET localip):$(GET remoteip) $(GET localpppopt)" \ + "$(GET remotepppopt)" & + fi + ;; +esac + +USERNAME="$(sed '/^name/!d;s/^[^ ]* *//' /etc/ppp/options)" +PASSWORD="$(awk -v key=$USERNAME "\$1==key{print \$3}" /etc/ppp/pap-secrets)" +ACCOUNT="$(sed '/^ACCOUNT=/!d;s/^.*=\([^ \t]*\).*/\1/' /etc/ppp/scripts/ppp-on)" +PASSRTC="$(sed '/^PASSWORD=/!d;s/^.*=\([^ \t]*\).*/\1/' /etc/ppp/scripts/ppp-on)" +PHONE="$(sed '/^TELEPHONE=/!d;s/^.*=\([^ \t]*\).*/\1/' /etc/ppp/scripts/ppp-on)" +TITLE="$(_ 'TazPanel - Network') - $(_ 'PPP Connections')" +header +xhtml_header | sed 's/id="content"/id="content-sidebar"/' +cat << EOT + + +
    +
    + $(_ 'RTC modem') - + $(_ 'Manage RTC Internet connections') +
    +
    +
    + + + + + + + + + + + + + +
    $(_ 'Username')
    $(_ 'Password')
    $(_ 'Phone number')
    +
    +
    +
    +EOT + +if [ "$(which pppoe 2>/dev/null)" ]; then + cat < +
    +
    + $(_ 'Cable Modem') - + $(_ 'Manage PPPoE Internet connections') +
    +
    + + + + + + + + + +
    $(_ 'Username')
    $(_ 'Password')
    +
    +
    +
    +EOT +fi + +busybox ps x | grep -v grep | grep -q pppnc_server || stops_disabled='disabled' +busybox ps x | grep -v grep | grep -q pppnc_client || stopc_disabled='disabled' +cat < +
    +
    + $(_ 'Route shortcut') - + $(_ 'Reach unreachable networks') +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    $(_ 'TCP port')
    --- $(_ 'Server only') ---
    $(_ 'Local IP address')
    $(_ 'Remote IP address')
    --- $(_ 'Client only') ---
    $(_ 'Server IP address')
    $(_ 'Server routes')
    +
    +
    +
    +EOT +if [ "$(which pppssh 2>/dev/null)" ]; then + [ -s /etc/ppp/pppssh ] && . /etc/ppp/pppssh + ppp="$(sed '/pppd/!d;s/.*="\([^"]*\).*/\1/' /usr/bin/pppssh)" + if [ "$(busybox ps x | grep "$ppp" | awk '/dbclient/{print $1}')" ]; then + start_disabled='disabled' + else + stop_disabled='disabled' + fi + cat < +
    +
    + $(_ 'Virtual Private Network') - + $(_ 'Manage private TCP/IP connections') +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    $(_ 'Peer')
    $(_ 'SSH options')
    $(_ 'Password')
    $(_ 'Local IP address')
    $(_ 'Remote IP address')
    $(_ 'Local PPP options')
    $(_ 'Remote PPP options')
    $(_ 'Peer routes')
    +
    + +
    +EOT +fi + +xhtml_footer +exit 0