-
Notifications
You must be signed in to change notification settings - Fork 2
/
export.sh
executable file
·56 lines (44 loc) · 999 Bytes
/
export.sh
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
#!/bin/bash
users=`ls /home`
alias_domains=`ls /etc/valiases`
for user in $users
do
if [ ! -d /home/$user/etc ]
then
continue
fi
domains=`ls /home/$user/etc`
for domain in $domains
do
if [ ! -d /home/$user/etc/"$domain" ] || [ ! -f /home/$user/etc/"$domain"/shadow ]
then
continue
fi
combined=`cat /home/$user/etc/$domain/shadow | cut -d: -f1,2`
n=`echo $combined | wc -w`
for account in $combined
do
username=`echo $account | cut -d: -f1`
password=`echo $account | cut -d: -f2`
echo $username@$domain:$password
done
done
done
for domain in $alias_domains
do
aliases=`cat "/etc/valiases/$domain"`
while read -r alias
do
from=`echo "$alias" | cut -d: -f1 | tr -d ' '`
to=`echo "$alias" | cut -d: -f2- | tr -d ' '`
if [[ $to == \:* ]] || [[ $to == \"\:* ]] || [[ ! $to == *@* ]]
then
continue;
fi
if [[ ! $from == *@$domain ]]
then
from=$from@$domain
fi
echo ">$from:$to"
done < "/etc/valiases/$domain"
done