Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
HaiSoft (public)
Plesk - Mail Autoconfig
Commits
855001c5
Unverified
Commit
855001c5
authored
May 18, 2018
by
MegaS0ra
Committed by
GitHub
May 18, 2018
Browse files
Updated "ios" terms to "apple - and added fr or en choice
parent
a68ac061
Changes
1
Hide whitespace changes
Inline
Side-by-side
plesk_mail_autoconfig.sh
View file @
855001c5
#!/bin/bash
#!/bin/bash
# Deploy mail autoconfig for Plesk
# Deploy mail autoconfig for Plesk
# Support for Thunderbird autoconfig, Outlook autodiscover &
iOS
config generator
# Support for Thunderbird autoconfig, Outlook autodiscover &
Apple
config generator
# Website: haisoft.net
# Website: haisoft.net
## Settings
## Settings
...
@@ -12,6 +12,7 @@ companylowercasename="haisoft"
...
@@ -12,6 +12,7 @@ companylowercasename="haisoft"
companyurl
=
"haisoft.net"
companyurl
=
"haisoft.net"
docurl
=
"http://help.haisoft.net/"
docurl
=
"http://help.haisoft.net/"
hostname
=
"
$(
hostname
)
"
hostname
=
"
$(
hostname
)
"
applewebpagelanguage
=
"fr"
# Git repo, useful if you want to fork it
# Git repo, useful if you want to fork it
gituser
=
"HaiSoftSARL"
gituser
=
"HaiSoftSARL"
...
@@ -33,18 +34,18 @@ autodiscoverpathfile="${autodiscoverpath}/autodiscover.xml"
...
@@ -33,18 +34,18 @@ autodiscoverpathfile="${autodiscoverpath}/autodiscover.xml"
autodiscoverpathfilealt
=
"
${
autodiscoverpath
}
/Autodiscover.xml"
autodiscoverpathfilealt
=
"
${
autodiscoverpath
}
/Autodiscover.xml"
autodiscoverhtaccess
=
"
${
autodiscoverpath
}
/.htaccess"
autodiscoverhtaccess
=
"
${
autodiscoverpath
}
/.htaccess"
#
iOS
configurator paths
#
Apple
configurator paths
ios
path
=
"
${
defaulthostingdir
}
/mail"
apple
path
=
"
${
defaulthostingdir
}
/mail"
iphonepathfile
=
"
${
ios
path
}
/
iphon
e.xml"
applewebpagepath
=
"
${
apple
path
}
/
appl
e.xml"
iphon
emobileconfpathfile
=
"
${
autodiscoverpath
}
/
iphon
e.mobileconfig"
appl
emobileconfpathfile
=
"
${
autodiscoverpath
}
/
appl
e.mobileconfig"
ios
logo
=
"logo.png"
appleweb
logo
=
"logo.png"
ios
logourl
=
"https://raw.githubusercontent.com/
${
gituser
}
/
${
gitrepo
}
/
${
gitbranch
}
/
${
ios
logo
}
"
appleweb
logourl
=
"https://raw.githubusercontent.com/
${
gituser
}
/
${
gitrepo
}
/
${
gitbranch
}
/
${
appleweb
logo
}
"
# URLs used for tests
# URLs used for tests
autoconfigurl
=
"http://autoconfig.
${
hostname
}
/mail/config-v1.1.xml"
autoconfigurl
=
"http://autoconfig.
${
hostname
}
/mail/config-v1.1.xml"
autodiscoverurl
=
"https://
${
hostname
}
/autodiscover/autodiscover.xml"
autodiscoverurl
=
"https://
${
hostname
}
/autodiscover/autodiscover.xml"
autodiscoverurlalt
=
"https://
${
hostname
}
/Autodiscover/Autodiscover.xml"
autodiscoverurlalt
=
"https://
${
hostname
}
/Autodiscover/Autodiscover.xml"
ios
configurl
=
"http://
${
hostname
}
/
ios
"
apple
configurl
=
"http://
${
hostname
}
/
apple
"
##############
##############
### Script ###
### Script ###
...
@@ -115,37 +116,37 @@ if [ ! -f "${autodiscoverpathfile}" ]; then
...
@@ -115,37 +116,37 @@ if [ ! -f "${autodiscoverpathfile}" ]; then
fi
fi
if
[
!
-L
"
${
autodiscoverpathfilealt
}
"
]
;
then
if
[
!
-L
"
${
autodiscoverpathfilealt
}
"
]
;
then
fn_logecho
"[
INFO
] Symlinking autodiscover alternative config file"
fn_logecho
"[
...
] Symlinking autodiscover alternative config file"
fn_logecho
"
${
autodiscoverpathfile
}
->
${
autodiscoverpathfilealt
}
"
fn_logecho
"
${
autodiscoverpathfile
}
->
${
autodiscoverpathfilealt
}
"
ln
-s
"
${
autodiscoverpathfile
}
"
"
${
autodiscoverpathfilealt
}
"
ln
-s
"
${
autodiscoverpathfile
}
"
"
${
autodiscoverpathfilealt
}
"
fi
fi
if
[
!
-d
"
${
ios
path
}
"
]
;
then
if
[
!
-d
"
${
apple
path
}
"
]
;
then
fn_logecho
"[
...
] Creating
iOS
mail configurator directory"
fn_logecho
"[
INFO
] Creating
Apple
mail configurator directory"
fn_logecho
"
${
ios
path
}
"
fn_logecho
"
${
apple
path
}
"
mkdir
-p
"
${
ios
path
}
"
mkdir
-p
"
${
apple
path
}
"
fi
fi
if
[
!
-f
"
${
iphon
epath
file
}
"
]
;
then
if
[
!
-f
"
${
applewebpag
epath
}
"
]
;
then
fn_logecho
"[
...
] Creating
iOS config fil
e"
fn_logecho
"[
INFO
] Creating
Apple web pag
e"
fn_logecho
"
${
iphon
epath
file
}
"
fn_logecho
"
${
applewebpag
epath
}
"
touch
"
${
iphon
epath
file
}
"
touch
"
${
applewebpag
epath
}
"
fi
fi
if
[
!
-f
"
${
iphon
emobileconfpathfile
}
"
]
;
then
if
[
!
-f
"
${
appl
emobileconfpathfile
}
"
]
;
then
fn_logecho
"[INFO] Creating
iOS
mobile
config file"
fn_logecho
"[
INFO
] Creating
Apple
mobileconfig file"
fn_logecho
"
${
iphon
emobileconfpathfile
}
"
fn_logecho
"
${
appl
emobileconfpathfile
}
"
touch
"
${
iphon
emobileconfpathfile
}
"
touch
"
${
appl
emobileconfpathfile
}
"
fi
fi
if
[
!
-f
"
${
autodiscoverhtaccess
}
"
]
;
then
if
[
!
-f
"
${
autodiscoverhtaccess
}
"
]
;
then
fn_logecho
"[INFO] Creating autodiscover .htaccess file"
fn_logecho
"[
INFO
] Creating autodiscover .htaccess file"
fn_logecho
"
${
autodiscoverhtaccess
}
"
fn_logecho
"
${
autodiscoverhtaccess
}
"
touch
"
${
autodiscoverhtaccess
}
"
touch
"
${
autodiscoverhtaccess
}
"
fi
fi
if
[
!
-f
"
${
apacheautodiscoverconf
}
"
]
;
then
if
[
!
-f
"
${
apacheautodiscoverconf
}
"
]
;
then
fn_logecho
"[INFO] Creating autodiscover Apache configuration file"
fn_logecho
"[
INFO
] Creating autodiscover Apache configuration file"
fn_logecho
"
${
apacheautodiscoverconf
}
"
fn_logecho
"
${
apacheautodiscoverconf
}
"
touch
"
${
apacheautodiscoverconf
}
"
touch
"
${
apacheautodiscoverconf
}
"
fi
fi
...
@@ -192,26 +193,30 @@ sleep 0.5
...
@@ -192,26 +193,30 @@ sleep 0.5
sed
-i
-e
"s/HOSTNAME/
${
hostname
}
/g"
"
${
autodiscoverpathfile
}
"
sed
-i
-e
"s/HOSTNAME/
${
hostname
}
/g"
"
${
autodiscoverpathfile
}
"
sed
-i
-e
"s/COMPANYNAME/
${
companyname
}
/g"
"
${
autodiscoverpathfile
}
"
sed
-i
-e
"s/COMPANYNAME/
${
companyname
}
/g"
"
${
autodiscoverpathfile
}
"
##
iOS
config
##
Apple
config
echo
""
echo
""
fn_logecho
"[ INFO ] Writing
iOS
config files"
fn_logecho
"[ INFO ] Writing
Apple
config files"
echo
""
echo
""
sleep
0.5
sleep
0.5
curl
"https://raw.githubusercontent.com/
${
gituser
}
/
${
gitrepo
}
/
${
gitbranch
}
/iphone.xml"
>
"
${
iphonepathfile
}
"
if
[
${
applewebpagelanguage
}
=
fr
]
;
then
curl
"https://raw.githubusercontent.com/
${
gituser
}
/
${
gitrepo
}
/
${
gitbranch
}
/iphone.mobileconfig"
>
"
${
iphonemobileconfpathfile
}
"
curl
"https://raw.githubusercontent.com/
${
gituser
}
/
${
gitrepo
}
/
${
gitbranch
}
/apple_fr.xml"
>
"
${
applewebpagepath
}
"
elif
[
${
applewebpagelanguage
}
=
en
]
;
then
curl
"https://raw.githubusercontent.com/
${
gituser
}
/
${
gitrepo
}
/
${
gitbranch
}
/apple_en.xml"
>
"
${
applewebpagepath
}
"
fi
curl
"https://raw.githubusercontent.com/
${
gituser
}
/
${
gitrepo
}
/
${
gitbranch
}
/apple.mobileconfig"
>
"
${
applemobileconfpathfile
}
"
#
iOS
Logo
#
Apple web page
Logo
fn_logecho
"[ ... ] Downloading
${
ios
logo
}
logo for
iOS
"
fn_logecho
"[ ... ] Downloading
${
appleweb
logo
}
logo for
Apple web page
"
sleep
0.5
sleep
0.5
wget
-O
"
${
ios
path
}
/
${
ios
logo
}
"
"
${
ios
logourl
}
"
wget
-O
"
${
apple
path
}
/
${
appleweb
logo
}
"
"
${
appleweb
logourl
}
"
#
iOS
Settings
#
Apple
Settings
fn_logecho
"[ ... ] Populating
iOS
config files"
fn_logecho
"[ ... ] Populating
Apple
config files"
sleep
0.5
sleep
0.5
sed
-i
-e
"s/
IOS
LOGO/
${
ios
logo
}
/g"
"
${
iphon
epath
file
}
"
sed
-i
-e
"s/
APPLE
LOGO/
${
appleweb
logo
}
/g"
"
${
applewebpag
epath
}
"
sed
-i
-e
"s/COMPANYNAME/
${
companyname
}
/g"
"
${
iphon
epath
file
}
"
sed
-i
-e
"s/COMPANYNAME/
${
companyname
}
/g"
"
${
applewebpag
epath
}
"
sed
-i
-e
"s/HOSTNAME/
${
hostname
}
/g"
"
${
iphon
emobileconfpathfile
}
"
sed
-i
-e
"s/HOSTNAME/
${
hostname
}
/g"
"
${
appl
emobileconfpathfile
}
"
sed
-i
-e
"s/COMPANYLOWERCASENAME/
${
companylowercasename
}
/g"
"
${
iphon
emobileconfpathfile
}
"
sed
-i
-e
"s/COMPANYLOWERCASENAME/
${
companylowercasename
}
/g"
"
${
appl
emobileconfpathfile
}
"
## .htaccess config
## .htaccess config
echo
""
echo
""
...
@@ -219,10 +224,10 @@ fn_logecho "[ INFO ] Writing htaccess file"
...
@@ -219,10 +224,10 @@ fn_logecho "[ INFO ] Writing htaccess file"
sleep
0.5
sleep
0.5
echo
"AddHandler php-script .php .xml
echo
"AddHandler php-script .php .xml
RewriteEngine on
RewriteEngine on
RewriteCond %{REQUEST_URI} !
iphon
e.xml
RewriteCond %{REQUEST_URI} !
appl
e.xml
RewriteCond %{REQUEST_URI} !
${
ios
logo
}
RewriteCond %{REQUEST_URI} !
${
appleweb
logo
}
RewriteCond %{REQUEST_URI}
ios
RewriteCond %{REQUEST_URI}
apple
RewriteRule .* /
ios/iphon
e.xml [R]"
>
"
${
autodiscoverhtaccess
}
"
RewriteRule .* /
apple/appl
e.xml [R]"
>
"
${
autodiscoverhtaccess
}
"
## Apache aliases config
## Apache aliases config
echo
""
echo
""
...
@@ -230,7 +235,7 @@ fn_logecho "[ INFO ] Writing autodiscover Apache configuration file"
...
@@ -230,7 +235,7 @@ fn_logecho "[ INFO ] Writing autodiscover Apache configuration file"
sleep
0.5
sleep
0.5
echo
"Alias /autodiscover
\"
${
autodiscoverpath
}
\"
echo
"Alias /autodiscover
\"
${
autodiscoverpath
}
\"
Alias /Autodiscover
\"
${
autodiscoverpath
}
\"
Alias /Autodiscover
\"
${
autodiscoverpath
}
\"
Alias /
ios
\"
${
ios
path
}
\"
"
>
"
${
apacheautodiscoverconf
}
"
Alias /
apple
\"
${
apple
path
}
\"
"
>
"
${
apacheautodiscoverconf
}
"
echo
""
echo
""
fn_logecho
"[ INFO ] Restarting Apache"
fn_logecho
"[ INFO ] Restarting Apache"
...
@@ -268,11 +273,11 @@ else
...
@@ -268,11 +273,11 @@ else
fi
fi
echo
""
echo
""
sleep
0.5
sleep
0.5
# Test Apple
iOS
configurator
# Test Apple configurator
if
[
-n
"
$(
curl
-L
"
${
ios
configurl
}
"
|
grep
"<form method=
\"
post
\"
action=
\"
iphone.xml
\"
>"
)
"
]
;
then
if
[
-n
"
$(
curl
-L
"
${
apple
configurl
}
"
|
grep
"<form method=
\"
post
\"
action=
\"
iphone.xml
\"
>"
)
"
]
;
then
fn_logecho
"[ OK ]
iOS
${
ios
configurl
}
is accessible"
fn_logecho
"[ OK ]
Apple
${
apple
configurl
}
is accessible"
else
else
fn_logecho
"[ Warning ]
iOS
${
ios
configurl
}
does not seem to be accessible"
fn_logecho
"[ Warning ]
Apple
${
apple
configurl
}
does not seem to be accessible"
fi
fi
fn_logecho
"[ OK ] Done"
fn_logecho
"[ OK ] Done"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment