| Server IP : 188.114.96.2 / Your IP : 104.23.197.231 Web Server : Apache/2.4.59 (Debian) System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64 User : edlftp ( 1002) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/guillaumea/script/admin/ |
Upload File : |
# .==================.
# / Codes.Solutions /
# .==================.
#________________________________________
# *This script add a new domain email
#$1 : option
#$2 : domain
#$3 : user
#$4 : password / $4 : destination alias
#________________________________________
#!/bin/bash
if [ $1 = "1" ]
then
#domain creation
mkdir /home/vmail/$2
chown -R vmail:vmail /home/vmail
# echo -e "$domain\n" >> /etc/postfix/domain-list
mysql --user=root -v postfix <<EOF
INSERT INTO \`Domains_tbl\` (\`domainId\`, \`DomainName\`) VALUES ('', '$2');
EOF
service postfix reload
elif [ $1 = "2" ]
then
#user creation
#mkdir /home/vmail/$2/$3
chown -R vmail:vmail /home/vmail
id=$(mysql --user=root postfix -se "SELECT DomainId from \`Domains_tbl\` WHERE \`DomainName\` = '$2';")
#echo $id
passSha=$(doveadm pw -s SHA512-CRYPT -p $4)
pass=$(echo $passSha|tail -c +15)
#echo $pass
email=$3@$2
echo $email
mysql --user=root -v postfix <<EOF2
INSERT INTO \`Users_tbl\` (\`DomainId\`, \`password\`, \`Email\`) VALUES ('$id','$pass','$email');
EOF2
mysql --user=root -v postfix <<EOF3
INSERT INTO \`Alias_tbl\` (\`DomainId\`, \`Source\`, \`Destination\`) VALUES ('$id','$email','$email');
EOF3
service postfix reload
elif [ $1 = "3" ]
then
#alias creation
id=$(mysql --user=root postfix -se "SELECT DomainId from \`Domains_tbl\` WHERE \`DomainName\` = '$2';")
#echo $id
email=$3@$2
destination=$4
echo $email'>>'$destination
mysql --user=root -v postfix <<EOF4
INSERT INTO \`Alias_tbl\` (\`DomainId\`, \`Source\`, \`Destination\`) VALUES ('$id','$email','$destination');
EOF4
service postfix reload
else
echo "Please select a correct option"
fi