if [ -f "$domain_file" ]; then
# don't destroy, just shuffle.
\mv -f "$domain_file" "/tmp/$(basename ${domain_file})-old-${RANDOM}"
- test_or_die "removing domain file: $domain_file"
+ exit_on_error "removing domain file: $domain_file"
else
echo "Did not see a domain file to remove: $domain_file"
fi
" >"$domain_file"
# our personalized configuration approach wants the real owner to own the file.
- chown "$(logname):$(logname)" $domain_file
- test_or_die "setting ownership on: $domain_file"
+ chown "$(fm_username):$(fm_username)" $domain_file
+ exit_on_error "setting ownership on: $domain_file"
}
# takes a zone back out of the local conf file for bind
" >> /etc/bind/named.conf.local
# keep ownership for the real user.
- chown "$(logname):$(logname)" /etc/bind/named.conf.local
- test_or_die "setting ownership on: /etc/bind/named.conf.local"
+ chown "$(fm_username):$(fm_username)" /etc/bind/named.conf.local
+ exit_on_error "setting ownership on: /etc/bind/named.conf.local"
}
# zaps a subdomain out of the containing domain file.
" >> /etc/bind/${containing_domain}.conf
# keep ownership for real user.
- chown "$(logname):$(logname)" "/etc/bind/${containing_domain}.conf"
- test_or_die "setting ownership on: /etc/bind/${containing_domain}.conf"
+ chown "$(fm_username):$(fm_username)" "/etc/bind/${containing_domain}.conf"
+ exit_on_error "setting ownership on: /etc/bind/${containing_domain}.conf"
}
function restart_bind()
echo "The bind service did not restart properly. Please check the error logs."
exit 1
fi
- echo DNS server restarted.
+ echo DNS service restarted.
+}
+
+############################################################################
+
+# samba server helper functions...
+
+function restart_samba
+{
+ echo restarting samba server.
+ service smbd restart
+ if [ $? -ne 0 ]; then
+ echo "The samba service did not restart properly. Please check the error logs."
+ exit 1
+ fi
+ service nmbd restart
+ if [ $? -ne 0 ]; then
+ echo "The samba name service (nmbd) did not restart properly. This may not always be fatal, so we are ignoring it, but you may want to check the error logs."
+ fi
+ echo samba service restarted.
}
############################################################################
# removes a config file for apache given the app name and site name.
function remove_apache_config()
{
- local appname="$1"; shift
local sitename="$1"; shift
local site_config="/etc/apache2/sites-available/${sitename}.conf"
if [ -f "$site_config" ]; then
# don't destroy, just shuffle.
\mv -f "$site_config" "/tmp/$(basename ${site_config})-old-${RANDOM}"
- test_or_die "removing site config: $site_config"
+ exit_on_error "removing site config: $site_config"
else
echo "Did not see a site config to remove: $site_config"
fi
</VirtualHost>
" >"$site_config"
- chown "$(logname):$(logname)" "$site_config"
- test_or_die "setting ownership on: $site_config"
+ chown "$(fm_username):$(fm_username)" "$site_config"
+ exit_on_error "setting ownership on: $site_config"
}
# stops apache from serving up the site.
echo "Please consult the apache error logs for more details."
exit 1
fi
+ echo Apache2 service restarted.
}
# sets up the serverpilot storage location for a user hosted web site.
local full_path="$BASE_APPLICATION_PATH/$our_app"
if [ ! -d "$full_path" ]; then
mkdir -p $full_path
- test_or_die "The app storage path could not be created.\n Path in question is: $full_path"
+ exit_on_error "The app storage path could not be created.\n Path in question is: $full_path"
fi
# now give the web server some access to the folder. this is crucial since the folders
chmod -R g+rx "$chow_path"
# walk backwards up the path and fix perms.
while [[ $chow_path != $HOME ]]; do
-echo chow path is now $chow_path
+#echo chow path is now $chow_path
chmod g+rx "$chow_path"
- test_or_die "Failed to add group permissions on the path: $chow_path"
+ exit_on_error "Failed to add group permissions on the path: $chow_path"
# reassert the user's ownership of any directories we might have just created.
- chown $(logname) "$chow_path"
- test_or_die "changing ownership to user failed on the path: $chow_path"
+ chown "$(fm_username):$(fm_username)" "$chow_path"
+ exit_on_error "changing ownership to user failed on the path: $chow_path"
chow_path="$(dirname "$chow_path")"
done
}