X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Fsystem%2Fcommon_sysadmin.sh;h=a29dd6c050f84119f0ba98975c55bd70382a598c;hb=ec0607714e0846cbf25687be2c915eb28b521f4c;hp=223067f6ce7443b56f2fc929c94613ec55773910;hpb=8e574c3a0f2a4395e332f120ca05acd226d11174;p=feisty_meow.git diff --git a/scripts/system/common_sysadmin.sh b/scripts/system/common_sysadmin.sh index 223067f6..a29dd6c0 100644 --- a/scripts/system/common_sysadmin.sh +++ b/scripts/system/common_sysadmin.sh @@ -17,7 +17,7 @@ function remove_domain_file() 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 @@ -60,8 +60,8 @@ ${domain_name}. IN A ${IP_ADDRESS} " >"$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 @@ -99,8 +99,8 @@ zone \"${domain_name}\" in { " >> /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. @@ -169,8 +169,8 @@ function add_new_subdomain() " >> /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() @@ -181,7 +181,26 @@ 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. } ############################################################################ @@ -198,7 +217,7 @@ function remove_apache_config() 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 @@ -258,8 +277,8 @@ function write_apache_config() " >"$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. @@ -317,6 +336,7 @@ function restart_apache() 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. @@ -327,7 +347,7 @@ function maybe_create_site_storage() 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 @@ -339,10 +359,10 @@ function maybe_create_site_storage() while [[ $chow_path != $HOME ]]; do #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 }