Permalink
Browse files

move lots of nginx functions into explicit bin scripts

  • Loading branch information...
1 parent 36e2c60 commit c3c4101e85e8efde7647807ae6f64e16ade8cf7a @drnic drnic committed Oct 20, 2011
View
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+trace_filter nginx || set -o xtrace
+if command exists vim
+then
+ ${EDITOR:=vim}
+else
+ ${EDITOR:=vi}
+fi
+export EDITOR
+
+${EDITOR} "${service_config_path}/nginx.conf"
View
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+trace_filter nginx || set -o xtrace
+"${service_binary}" -t -c "${service_config_path}/nginx.conf"
View
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+trace_filter nginx || set -o xtrace
+
+if ! (( force_flag )) && path exists "/etc/nginx"
+then
+ error "/etc/nginx exists; To force re-configure use the 'force'"
+fi
+
+if path exists /etc/nginx
+then
+ path move \
+ from /etc/nginx \
+ to /etc/nginx.${timestamp}
+fi
+
+files link symbolic \
+ from "${install_path}/etc/nginx" \
+ to /etc/nginx
View
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+trace_filter nginx || set -o xtrace
+if command exists vim
+then
+ ${EDITOR:=vim}
+else
+ ${EDITOR:=vi}
+fi
+
+${EDITOR} "${service_config_path}/servers/${project:-"${extension_args[0]}"}.conf"
View
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+trace_filter nginx || set -o xtrace
+local domain="${project}"
+
+if ! templates exist "nginx/server.conf"
+then
+ fail "$FUNCNAME: $extension_templates_path/server.conf template is missing."
+fi
+
+paths create "${service_config_path}/servers"
+
+# If this is running as root, ensure that Nginx can read from the
+# application directory.
+if user is root && path exists "/home/${project}"
+then
+ path chmod 'g+rx' recursive "/home/${project}"
+fi
+
+project_config="${service_config_path}/servers/${project}.conf"
+
+if (( force_flag == 1 )) && file_exists "${project_config}"
+then
+ remove_file "${project_config}"
+fi
+
+if ! files exist "${project_config}"
+then
+ templates install "nginx/server.conf" \
+ to "${project_config}"
+fi
+
+if ! [[ "${domain}" =~ "." ]]
+then
+ domain="${domain}.com"
+fi
+
+if array is empty domains
+then
+ domains=("${domain}" "*.${domain}")
+fi
+
+if files exist "${project_config}"
+then
+ templates seed "${project_config}" \
+ modules_path "${modules_path}" \
+ service "${service}" \
+ project "${project}" \
+ domain "${domain}" \
+ domains "${domains[*]}" \
+ project_path ${project_path:="/home/${project_user:-${project}}"} \
+ project_user "${project_user}" \
+ service_config_path "${service_config_path}" \
+ service_pid_file "${service_pid_file}" \
+ service_log_path "${service_log_path}"
+fi
View
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+trace_filter nginx || set -o xtrace
+local line header
+typeset -a master_list worker_list
+header="$(ps auxww | head -1)"
+
+(( master_pid > 0 )) || succeed "No Nginx master processes was found."
+
+while read -r line
+do
+ if [[ "$line" =~ nginx ]]
+ then
+ if [[ "$line" =~ master ]]
+ then
+ master_list+=("${line}")
+ elif [[ "$line" =~ worker ]]
+ then
+ worker_list+=("${line}")
+ fi
+ fi
+done < <(ps auxww | awk '/[n]ginx/')
+
+echo "$header"
+
+for line in "${master_list[@]}"
+do
+ echo "${line}"
+done
+
+for line in "${worker_list[@]}"
+do
+ echo "${line}"
+done
+
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+trace_filter nginx || set -o xtrace
+if (( master_pid > 0 ))
+then
+ kill -HUP $master_pid
+else
+ service restart
+fi
View
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+nginx_service_setup
View
@@ -1,14 +1,5 @@
-list=nginx_list()
-conf/edit=nginx_conf_edit()
-config=nginx_config_check()
-config/check=nginx_config_check()
-configure/system=configure/nginx_configure_system_etc()
-server/add=server/nginx_server_new()
-server/disable=server/disable
-server/edit=server/nginx_server_conf_edit()
-server/enable=server/enable
-server/help=server/help
-server/list=server/list
-server/new=server/nginx_server_new()
-service/setup=service/nginx_service_setup()
-service/list=nginx_list()
+list=service/list
+config=config/check
+configure/system=config/system
+server/add=server/new
+restart=service/restart
Oops, something went wrong.

0 comments on commit c3c4101

Please sign in to comment.