blob: 814027c6375bb4658491aaf89212b170b31daa50 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#! /bin/sh
#
# vpnuser Add/Del user to chap-secrets for VPN
# Version 1.0 beta by Richard de Vroede - Linvision BV
# Ideas or worshipping to: richard@linvision.com
#
config="/etc/ppp/chap-secrets"
ERROR="Usage:\n$0 add <username> <passwd> or\n$0 del <username> or\n$0 show [<username>] or\n$0 domain <username> <domain>"
# See how we were called.
case "$1" in
add)
if [ "$(echo $2)" != "" ] & [ "$(echo $3)" != "" ]; then
echo -e "$2\t*\t$3\t*" >> $config
chmod 600 $config
else
echo -e $ERROR
exit 1
fi
;;
del)
if [ "$(echo $2)" != "" ]; then
grep -vw "$2" $config > /tmp/vpnblaat
mv /tmp/vpnblaat $config
chmod 600 $config
else
echo -e $ERROR
exit 1
fi
;;
show)
echo -e "User\tServer\tPasswd\tIPnumber"
echo "---------------------------------"
if [ "$(echo $2)" != "" ]; then
grep -w $2 $config
else
cat $config
fi
;;
domain)
if [ "$(echo $2)" != "" ] & [ "$(echo $3)" != "" ]; then
grep -vw "$2" $config > /tmp/vpnblaat
DATA=`grep -w "$2" $config`
mv /tmp/vpnblaat $config
DOM=`echo $3 | tr a-z A-Z`
dom=`echo $3 | tr A-Z a-z`
echo "$DOM\\\\$DATA" >> $config
echo "$dom\\\\$DATA" >> $config
chmod 600 $config
else
echo -e $ERROR
exit 1
fi
;;
*)
echo -e $ERROR
exit 1
esac
|