1212# - Importing certificates fails at the moment. Due to format changes of CPanel side
1313# - It doesn't update DKIM
1414
15- # shellcheck source=/etc/hestiacp/hestia.conf
16- source /etc/hestiacp/hestia.conf
1715# shellcheck source=/usr/local/hestia/func/main.sh
1816source $HESTIA /func/main.sh
17+ # shellcheck source=/etc/hestiacp/hestia.conf
18+ source /etc/hestiacp/hestia.conf
19+ # load config file
20+ source_conf " $HESTIA /conf/hestia.conf"
1921
2022if [ $# -lt 1 ]; then
2123 echo " usage: bash $0 cpanel-backup.tar.gz"
107109# Create a new user
108110tmp_passwd=$( generate_password)
109111email=$( cat ./cp/$new_user | grep CONTACTEMAIL= | cut -f2 -d' =' )
112+ if [ -z " $email " ]; then
113+ # Hestia does not like email to be set to an empty string
114+ email=" info@" $( hostname)
115+ fi
110116$BIN /v-add-user " $new_user " " $tmp_passwd " " $email " " $hestia_package "
117+ if [ " $? " -ne 0 ]; then
118+ echo " Unable to create user"
119+ exit 1
120+ fi
111121# Restore user password
112122update_user_value " $new_user " ' MD5' " $( cat shadow) "
113123$BIN /v-rebuild-user " $new_user "
@@ -174,12 +184,11 @@ echo "Converting addons domains, subdomains and some other fun"
174184cp sds hst_sds
175185cp sds2 hst_sds2
176186sed -i ' s/_/./g' hst_sds
177- cat addons | while read ddon_domain addon_sub
178- do
179- echo " Converting default subdomain: $addon_sub in domain: $addon_domain "
180- sed -i -e " s/$addon_sub /$addon_domain /g" hst_sds
181- sed -i -e " s/$addon_sub /$addon_domain /g" hst_sds2
182- mv userdata/$addon_sub userdata/${addon_domain}
187+ cat addons | while read ddon_domain addon_sub; do
188+ echo " Converting default subdomain: $addon_sub in domain: $addon_domain "
189+ sed -i -e " s/$addon_sub /$addon_domain /g" hst_sds
190+ sed -i -e " s/$addon_sub /$addon_domain /g" hst_sds2
191+ mv userdata/$addon_sub userdata/${addon_domain}
183192done
184193sed -i ' s/public_html/public@html/g; s/_/./g; s/public@html/public_html/g; s/=/ /g' hst_sds2
185194
@@ -190,7 +199,11 @@ function get_domain_path() {
190199 while read cp_domain path; do
191200 echo " Import $cp_domain "
192201 if [ -e userdata/$cp_domain ]; then
202+ echo $cp_domain
193203 $BIN /v-add-domain " $new_user " " $cp_domain "
204+ if [ $? -ne 0 ]; then
205+ check_result " 1" " Unable to create domain it allready exists"
206+ fi
194207 rm -f /home/$new_user /web/$cp_domain /public_html/index.html
195208 rm -f /home/$new_user /web/$cp_domain /public_html/robots.txt
196209 sync_count=0
@@ -206,7 +219,13 @@ function get_domain_path() {
206219}
207220get_domain_path < hst_sds2
208221
209- /usr/local/hestia/bin/v-add-domain $new_user $main_domain1
222+ echo $main_domain1
223+ $BIN /v-add-domain $new_user $main_domain1
224+
225+ if [ $? -ne 0 ]; then
226+ check_result " 1" " Unable to create domain it allready exists"
227+ fi
228+
210229# need it for restore main domain
211230if [ ! -e exclude_path ]; then
212231 touch exclude_path
@@ -238,7 +257,7 @@ for folder in *; do
238257 echo " Domain: $folder "
239258 cd $folder
240259 for mail_account in * ; do
241- echo " Import mail account: $mail_account @# $folder "
260+ echo " Import mail account: $mail_account @$folder "
242261 # Doesn't really matter but we don't know the unhashed one
243262 tmp_pass=$( generate_password)
244263 $BIN /v-add-mail-account $new_user $folder $mail_account $tmp_pass
0 commit comments