Unverified Commit 855001c5 authored by MegaS0ra's avatar MegaS0ra Committed by GitHub
Browse files

Updated "ios" terms to "apple - and added fr or en choice

parent a68ac061
#!/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
iospath="${defaulthostingdir}/mail" applepath="${defaulthostingdir}/mail"
iphonepathfile="${iospath}/iphone.xml" applewebpagepath="${applepath}/apple.xml"
iphonemobileconfpathfile="${autodiscoverpath}/iphone.mobileconfig" applemobileconfpathfile="${autodiscoverpath}/apple.mobileconfig"
ioslogo="logo.png" appleweblogo="logo.png"
ioslogourl="https://raw.githubusercontent.com/${gituser}/${gitrepo}/${gitbranch}/${ioslogo}" appleweblogourl="https://raw.githubusercontent.com/${gituser}/${gitrepo}/${gitbranch}/${appleweblogo}"
# 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"
iosconfigurl="http://${hostname}/ios" appleconfigurl="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 "${iospath}" ]; then if [ ! -d "${applepath}" ]; then
fn_logecho "[ ... ] Creating iOS mail configurator directory" fn_logecho "[ INFO ] Creating Apple mail configurator directory"
fn_logecho "${iospath}" fn_logecho "${applepath}"
mkdir -p "${iospath}" mkdir -p "${applepath}"
fi fi
if [ ! -f "${iphonepathfile}" ]; then if [ ! -f "${applewebpagepath}" ]; then
fn_logecho "[ ... ] Creating iOS config file" fn_logecho "[INFO] Creating Apple web page"
fn_logecho "${iphonepathfile}" fn_logecho "${applewebpagepath}"
touch "${iphonepathfile}" touch "${applewebpagepath}"
fi fi
if [ ! -f "${iphonemobileconfpathfile}" ]; then if [ ! -f "${applemobileconfpathfile}" ]; then
fn_logecho "[INFO] Creating iOS mobile config file" fn_logecho "[ INFO ] Creating Apple mobileconfig file"
fn_logecho "${iphonemobileconfpathfile}" fn_logecho "${applemobileconfpathfile}"
touch "${iphonemobileconfpathfile}" touch "${applemobileconfpathfile}"
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 ${ioslogo} logo for iOS" fn_logecho "[ ... ] Downloading ${appleweblogo} logo for Apple web page"
sleep 0.5 sleep 0.5
wget -O "${iospath}/${ioslogo}" "${ioslogourl}" wget -O "${applepath}/${appleweblogo}" "${appleweblogourl}"
# 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/IOSLOGO/${ioslogo}/g" "${iphonepathfile}" sed -i -e "s/APPLELOGO/${appleweblogo}/g" "${applewebpagepath}"
sed -i -e "s/COMPANYNAME/${companyname}/g" "${iphonepathfile}" sed -i -e "s/COMPANYNAME/${companyname}/g" "${applewebpagepath}"
sed -i -e "s/HOSTNAME/${hostname}/g" "${iphonemobileconfpathfile}" sed -i -e "s/HOSTNAME/${hostname}/g" "${applemobileconfpathfile}"
sed -i -e "s/COMPANYLOWERCASENAME/${companylowercasename}/g" "${iphonemobileconfpathfile}" sed -i -e "s/COMPANYLOWERCASENAME/${companylowercasename}/g" "${applemobileconfpathfile}"
## .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} !iphone.xml RewriteCond %{REQUEST_URI} !apple.xml
RewriteCond %{REQUEST_URI} !${ioslogo} RewriteCond %{REQUEST_URI} !${appleweblogo}
RewriteCond %{REQUEST_URI} ios RewriteCond %{REQUEST_URI} apple
RewriteRule .* /ios/iphone.xml [R]" > "${autodiscoverhtaccess}" RewriteRule .* /apple/apple.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 \"${iospath}\"" > "${apacheautodiscoverconf}" Alias /apple \"${applepath}\"" > "${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 "${iosconfigurl}" | grep "<form method=\"post\" action=\"iphone.xml\">")" ]; then if [ -n "$(curl -L "${appleconfigurl}" | grep "<form method=\"post\" action=\"iphone.xml\">")" ]; then
fn_logecho "[ OK ] iOS ${iosconfigurl} is accessible" fn_logecho "[ OK ] Apple ${appleconfigurl} is accessible"
else else
fn_logecho "[ Warning ] iOS ${iosconfigurl} does not seem to be accessible" fn_logecho "[ Warning ] Apple ${appleconfigurl} does not seem to be accessible"
fi fi
fn_logecho "[ OK ] Done" fn_logecho "[ OK ] Done"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment