Commit eaa0ed97 authored by Benoît's avatar Benoît
Browse files

Adapted script for gitlab migration

parent c1355c92
...@@ -7,26 +7,40 @@ ...@@ -7,26 +7,40 @@
# These will be visible inside your config files # These will be visible inside your config files
companyname="HaiSoft" companyname="HaiSoft"
companyshortname="HaiSoft"
companylowercasename="haisoft" companylowercasename="haisoft"
companyurl="haisoft.net" companyurl="haisoft.net"
docurl="http://help.haisoft.net/" docurl="https://wiki.haisoft.fr/index.php?title=E-mail#Configuration_automatique"
hostname="$(hostname)" hostname="$(hostname)"
applewebpagelanguage="fr" applewebpagelanguage="fr"
# Git repo, useful if you want to fork it # Git Platform - github and gitlab are supported
gituser="HaiSoftSARL" gitplatform="gitlab"
gitrepo="plesk_mail_autoconfig"
# When forking this repo, you can set your own git info
gitlaburl="https://gitlab.haisoft.net"
githuburl="https://raw.githubusercontent.com"
gituser="pub"
gitrepo="Plesk_MailAutoconfig"
gitbranch="master" gitbranch="master"
## Edit with care or don't
if [ ${gitplatform} = gitlab ]; then
gitrawfullurl="${gitlaburl}/${gituser}/${gitrepo}/raw/${gitbranch}"
elif [ ${gitplatform} = github ]; then
gitrawfullurl="${githuburl}/${gituser}/${gitrepo}/${gitbranch}"
else
fn_logecho "[ Warning ] Selected git platform ${gitplatform} not supported."
exit
fi
## Edit with care or don't
# Hosting directory # Hosting directory
# The place where we host our configuration files # The place where we host our configuration files
defaulthostingdir="/var/www/vhosts/default/htdocs" defaulthostingdir="/var/www/vhosts/default/htdocs"
# Thunderbird autoconfig paths # Thunderbird autoconfig paths
autoconfigpath="${defaulthostingdir}/mail" autoconfigpath="${defaulthostingdir}/mail"
autoconfigfile="config-v1.1.xml" autoconfigpathfile="${autoconfigpath}/config-v1.1.xml"
autoconfigpathfile="${autoconfigpath}/${autoconfigfile}"
# Outlook autodiscover paths # Outlook autodiscover paths
autodiscoverpath="${defaulthostingdir}/mail" autodiscoverpath="${defaulthostingdir}/mail"
...@@ -39,7 +53,7 @@ applepath="${defaulthostingdir}/mail" ...@@ -39,7 +53,7 @@ applepath="${defaulthostingdir}/mail"
applewebpagepath="${applepath}/apple.xml" applewebpagepath="${applepath}/apple.xml"
applemobileconfpathfile="${autodiscoverpath}/apple.mobileconfig" applemobileconfpathfile="${autodiscoverpath}/apple.mobileconfig"
appleweblogo="logo.png" appleweblogo="logo.png"
appleweblogourl="https://raw.githubusercontent.com/${gituser}/${gitrepo}/${gitbranch}/${appleweblogo}" appleweblogourl="${gitrawfullurl}/${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"
...@@ -156,15 +170,13 @@ echo "" ...@@ -156,15 +170,13 @@ echo ""
fn_logecho "[ INFO ] Writing Thunderbird autoconfig config file" fn_logecho "[ INFO ] Writing Thunderbird autoconfig config file"
sleep 1 sleep 1
echo "" echo ""
curl "https://raw.githubusercontent.com/${gituser}/${gitrepo}/${gitbranch}/config-v1.1.xml" > "${autoconfigpathfile}" curl "${gitrawfullurl}/config-v1.1.xml" > "${autoconfigpathfile}"
# Replace values with settings # Replace values with settings
fn_logecho "[ ... ] Populating Thunderbird autoconfig file" fn_logecho "[ ... ] Populating Thunderbird autoconfig file"
sleep 0.5 sleep 0.5
sed -i -e "s/HOSTNAME/${hostname}/g" "${autoconfigpathfile}" sed -i -e "s/HOSTNAME/${hostname}/g" "${autoconfigpathfile}"
sed -i -e "s/COMPANYURL/${companyurl}/g" "${autoconfigpathfile}" sed -i -e "s/COMPANYURL/${companyurl}/g" "${autoconfigpathfile}"
sed -i -e "s/COMPANYNAME/${companyname}/g" "${autoconfigpathfile}"
sed -i -e "s/COMPANYSHORTNAME/${companyshortname}/g" "${autoconfigpathfile}"
sed -i -e "s@DOCURL@${docurl}@g" "${autoconfigpathfile}" sed -i -e "s@DOCURL@${docurl}@g" "${autoconfigpathfile}"
# DNS for autoconfig # DNS for autoconfig
...@@ -185,7 +197,7 @@ done ...@@ -185,7 +197,7 @@ done
echo "" echo ""
fn_logecho "[ INFO ] Writing Outlook autodiscover file" fn_logecho "[ INFO ] Writing Outlook autodiscover file"
sleep 1 sleep 1
curl "https://raw.githubusercontent.com/${gituser}/${gitrepo}/${gitbranch}/autodiscover.xml" > "${autodiscoverpathfile}" curl "${gitrawfullurl}/autodiscover.xml" > "${autodiscoverpathfile}"
# Outlook settings # Outlook settings
fn_logecho "[ ... ] Populating Outlook autodiscover file" fn_logecho "[ ... ] Populating Outlook autodiscover file"
...@@ -199,14 +211,14 @@ fn_logecho "[ INFO ] Writing Apple config files" ...@@ -199,14 +211,14 @@ fn_logecho "[ INFO ] Writing Apple config files"
echo "" echo ""
sleep 0.5 sleep 0.5
if [ ${applewebpagelanguage} = fr ]; then if [ ${applewebpagelanguage} = fr ]; then
curl "https://raw.githubusercontent.com/${gituser}/${gitrepo}/${gitbranch}/apple_fr.xml" > "${applewebpagepath}" curl "${gitrawfullurl}/apple_fr.xml" > "${applewebpagepath}"
elif [ ${applewebpagelanguage} = en ]; then elif [ ${applewebpagelanguage} = en ]; then
curl "https://raw.githubusercontent.com/${gituser}/${gitrepo}/${gitbranch}/apple_en.xml" > "${applewebpagepath}" curl "${gitrawfullurl}/apple_en.xml" > "${applewebpagepath}"
else else
fn_logecho "[ Warning ] Selected language ${applewebpagelanguage} is not available. Reverting to english." fn_logecho "[ Warning ] Selected language ${applewebpagelanguage} is not available. Reverting to english."
curl "https://raw.githubusercontent.com/${gituser}/${gitrepo}/${gitbranch}/apple_en.xml" > "${applewebpagepath}" curl "${gitrawfullurl}/apple_en.xml" > "${applewebpagepath}"
fi fi
curl "https://raw.githubusercontent.com/${gituser}/${gitrepo}/${gitbranch}/apple.mobileconfig" > "${applemobileconfpathfile}" curl "${gitrawfullurl}/apple.mobileconfig" > "${applemobileconfpathfile}"
# Apple web page Logo # Apple web page Logo
fn_logecho "[ ... ] Downloading ${appleweblogo} logo for Apple web page" fn_logecho "[ ... ] Downloading ${appleweblogo} logo for Apple web page"
...@@ -283,4 +295,4 @@ else ...@@ -283,4 +295,4 @@ else
fn_logecho "[ Warning ] Apple ${appleconfigurl} 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"
\ No newline at end of file
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