X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Fsystem%2Fcommon_sysadmin.sh;h=a29dd6c050f84119f0ba98975c55bd70382a598c;hb=ec0607714e0846cbf25687be2c915eb28b521f4c;hp=435b474f9bf207ca97d3e6e5dde2cbdc639ea5e3;hpb=353d2f0887e378b38e81d61af52629369e1d8930;p=feisty_meow.git diff --git a/scripts/system/common_sysadmin.sh b/scripts/system/common_sysadmin.sh index 435b474f..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. } ############################################################################ @@ -191,7 +210,6 @@ function restart_bind() # 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" @@ -199,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 @@ -259,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. @@ -318,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. @@ -328,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 @@ -338,12 +357,12 @@ function maybe_create_site_storage() 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 }