From 706324b9c61249278bcd5cfb06db75477a2f0741 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Fri, 29 Mar 2013 02:30:15 -0500 Subject: [PATCH] cleanup of whitespaces in scripts --- VERSION | 2 +- scripts/access.wsgi | 9 +- scripts/nginx_scgi.conf | 166 +++++------ scripts/setup-scheduler-centos.sh | 5 +- scripts/setup-shared-hosting-2.4.sh | 1 - ...2-04-redmine-unicorn-web2py-uwsgi-nginx.sh | 260 +++++++++--------- scripts/setup-virtualenv-web2py.sh | 45 ++- scripts/setup-web2py-fedora-ami.sh | 1 - scripts/setup-web2py-nginx-uwsgi-on-centos.sh | 2 - scripts/setup-web2py-nginx-uwsgi-ubuntu.sh | 26 +- scripts/setup-web2py-ubuntu.sh | 1 - scripts/update-web2py.sh | 29 +- scripts/web2py.archlinux.sh | 1 - scripts/web2py.fedora.sh | 73 +++-- scripts/web2py.ubuntu.sh | 217 ++++++++------- 15 files changed, 411 insertions(+), 427 deletions(-) diff --git a/VERSION b/VERSION index b87e3bfc..30f50fc4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.5-stable+timestamp.2013.03.29.02.12.57 +Version 2.4.5-stable+timestamp.2013.03.29.02.29.39 diff --git a/scripts/access.wsgi b/scripts/access.wsgi index ede90a11..86285070 100644 --- a/scripts/access.wsgi +++ b/scripts/access.wsgi @@ -46,9 +46,9 @@ def allow_access(environ,host): filename = os.path.join(os.path.dirname(__file__),'access.wsgi.log') f = open(filename,'a') try: - f.write('\n'+header+'\n'+pprint+'\n') + f.write('\n'+header+'\n'+pprint+'\n') finally: - f.close() + f.close() app = environ['REQUEST_URI'].split('/')[1] keys = [key for key in environ if key.startswith('HTTP_')] headers = {} @@ -58,8 +58,7 @@ def allow_access(environ,host): try: data = urllib.urlencode({'request_uri':environ['REQUEST_URI']}) request = urllib2.Request(URL_CHECK_ACCESS % dict(app=app),data,headers) - response = urllib2.urlopen(request).read().strip().lower() - if response.startswith('true'): return True + response = urllib2.urlopen(request).read().strip().lower() + if response.startswith('true'): return True except: pass return False - diff --git a/scripts/nginx_scgi.conf b/scripts/nginx_scgi.conf index 662c708b..f96bb1f2 100644 --- a/scripts/nginx_scgi.conf +++ b/scripts/nginx_scgi.conf @@ -4,112 +4,112 @@ worker_processes 1; error_log /var/log/nginx/error_log info; events { - worker_connections 1024; - use epoll; + worker_connections 1024; + use epoll; } http { - include /etc/nginx/mime.types; - default_type application/octet-stream; + include /etc/nginx/mime.types; + default_type application/octet-stream; - log_format main - '$remote_addr - $remote_user [$time_local] ' - '"$request" $status $bytes_sent ' - '"$http_referer" "$http_user_agent" ' - '"$gzip_ratio"'; + log_format main + '$remote_addr - $remote_user [$time_local] ' + '"$request" $status $bytes_sent ' + '"$http_referer" "$http_user_agent" ' + '"$gzip_ratio"'; - client_header_timeout 10m; - client_body_timeout 10m; - send_timeout 10m; + client_header_timeout 10m; + client_body_timeout 10m; + send_timeout 10m; - connection_pool_size 256; - client_header_buffer_size 1k; - large_client_header_buffers 4 2k; - request_pool_size 4k; + connection_pool_size 256; + client_header_buffer_size 1k; + large_client_header_buffers 4 2k; + request_pool_size 4k; - gzip on; - gzip_min_length 1100; - gzip_buffers 4 8k; - gzip_types text/plain; + gzip on; + gzip_min_length 1100; + gzip_buffers 4 8k; + gzip_types text/plain; - output_buffers 1 32k; - postpone_output 1460; + output_buffers 1 32k; + postpone_output 1460; - sendfile on; - tcp_nopush on; - tcp_nodelay on; + sendfile on; + tcp_nopush on; + tcp_nodelay on; - keepalive_timeout 75 20; + keepalive_timeout 75 20; - ignore_invalid_headers on; + ignore_invalid_headers on; - ssl_session_cache shared:SSL:10m; + ssl_session_cache shared:SSL:10m; - index index.html; + index index.html; - server { - listen 127.0.0.1; - server_name localhost; + server { + listen 127.0.0.1; + server_name localhost; - access_log /var/log/nginx/localhost.access_log main; - error_log /var/log/nginx/localhost.error_log info; + access_log /var/log/nginx/localhost.access_log main; + error_log /var/log/nginx/localhost.error_log info; - root /var/www/localhost/htdocs; - } + root /var/www/localhost/htdocs; + } - # SSL example - server { - listen 127.0.0.1:443; - server_name localhost; + # SSL example + server { + listen 127.0.0.1:443; + server_name localhost; - ssl on; - ssl_certificate /etc/ssl/nginx/nginx-server.pem; - ssl_client_certificate /etc/ssl/nginx/cacert.pem; - ssl_certificate_key /etc/ssl/nginx/nginx.key; - ssl_verify_client optional; + ssl on; + ssl_certificate /etc/ssl/nginx/nginx-server.pem; + ssl_client_certificate /etc/ssl/nginx/cacert.pem; + ssl_certificate_key /etc/ssl/nginx/nginx.key; + ssl_verify_client optional; - access_log /var/log/nginx/localhost.ssl_access_log main; - error_log /var/log/nginx/localhost.ssl_error_log info; + access_log /var/log/nginx/localhost.ssl_access_log main; + error_log /var/log/nginx/localhost.ssl_error_log info; - root /var/www/localhost/htdocs; + root /var/www/localhost/htdocs; - set $web2pyroot /home/Desktop/source/michelecomitini-facebookaccess; - - - location /pki/ { - root /var/www/localhost/html; - } + set $web2pyroot /home/Desktop/source/michelecomitini-facebookaccess; - location ^/(.*)/static/(.*) { - alias $web2pyroot/applications/$1/static/$2; - } - - location / { - include /etc/nginx/scgi_params; - scgi_pass 127.0.0.1:4000; + location /pki/ { + root /var/www/localhost/html; + } - #Module ngx_http_ssl_module supports the following built-in variables: - #$ssl_cipher returns the cipher suite being used for the currently established SSL/TLS connection - #$ssl_client_serial returns the serial number of the client certificate for the currently established SSL/TLS connection — if applicable, i.e., if client authentication is activated in the connection - #$ssl_client_s_dn returns the subject Distinguished Name (DN) of the client certificate for the currently established SSL/TLS connection — if applicable, i.e., if client authentication is activated in the connection - #$ssl_client_i_dn returns the issuer DN of the client certificate for the currently established SSL/TLS connection — if applicable, i.e., if client authentication is activated in the connection - #$ssl_protocol returns the protocol of the currently established SSL/TLS connection — depending on the configuration and client available options it's one of SSLv2, SSLv3 or TLSv1 - #$ssl_session_id the Session ID of the established secure connection — requires Nginx version greater or equal to 0.8.20 - #$ssl_client_cert - #$ssl_client_raw_cert - #$ssl_client_verify takes the value "SUCCESS" when the client certificate is successfully verified - scgi_param SSL_PROTOCOL $ssl_protocol; - scgi_param HTTPS on; - scgi_param SSL_CIPHER $ssl_cipher; - scgi_param SSL_CLIENT_SERIAL $ssl_client_serial; - scgi_param SSL_CLIENT_S_DN $ssl_client_s_dn; - scgi_param SSL_CLIENT_I_DN $ssl_client_i_dn; - scgi_param SSL_SESSION_ID $ssl_session_id; - scgi_param SSL_CLIENT_CERT $ssl_client_cert; - scgi_param SSL_CLIENT_RAW_CERT $ssl_client_raw_cert; - scgi_param SSL_CLIENT_VERIFY $ssl_client_verify; - } - } + location ^/(.*)/static/(.*) { + alias $web2pyroot/applications/$1/static/$2; + } + + location / { + include /etc/nginx/scgi_params; + scgi_pass 127.0.0.1:4000; + + #Module ngx_http_ssl_module supports the following built-in variables: + + #$ssl_cipher returns the cipher suite being used for the currently established SSL/TLS connection + #$ssl_client_serial returns the serial number of the client certificate for the currently established SSL/TLS connection — if applicable, i.e., if client authentication is activated in the connection + #$ssl_client_s_dn returns the subject Distinguished Name (DN) of the client certificate for the currently established SSL/TLS connection — if applicable, i.e., if client authentication is activated in the connection + #$ssl_client_i_dn returns the issuer DN of the client certificate for the currently established SSL/TLS connection — if applicable, i.e., if client authentication is activated in the connection + #$ssl_protocol returns the protocol of the currently established SSL/TLS connection — depending on the configuration and client available options it's one of SSLv2, SSLv3 or TLSv1 + #$ssl_session_id the Session ID of the established secure connection — requires Nginx version greater or equal to 0.8.20 + #$ssl_client_cert + #$ssl_client_raw_cert + #$ssl_client_verify takes the value "SUCCESS" when the client certificate is successfully verified + scgi_param SSL_PROTOCOL $ssl_protocol; + scgi_param HTTPS on; + scgi_param SSL_CIPHER $ssl_cipher; + scgi_param SSL_CLIENT_SERIAL $ssl_client_serial; + scgi_param SSL_CLIENT_S_DN $ssl_client_s_dn; + scgi_param SSL_CLIENT_I_DN $ssl_client_i_dn; + scgi_param SSL_SESSION_ID $ssl_session_id; + scgi_param SSL_CLIENT_CERT $ssl_client_cert; + scgi_param SSL_CLIENT_RAW_CERT $ssl_client_raw_cert; + scgi_param SSL_CLIENT_VERIFY $ssl_client_verify; + } + } } diff --git a/scripts/setup-scheduler-centos.sh b/scripts/setup-scheduler-centos.sh index ec21525b..713f6999 100644 --- a/scripts/setup-scheduler-centos.sh +++ b/scripts/setup-scheduler-centos.sh @@ -11,11 +11,11 @@ # # chkconfig: 2345 90 10 # # description: web2py-scheduler # -# 4) make it executable with +# 4) make it executable with # # chmod 755 web2py-scheduler # -# 5) add it to startup with +# 5) add it to startup with # # chkconfig --add web2py-scheduler # @@ -64,4 +64,3 @@ case "$1" in ;; esac exit 0 - diff --git a/scripts/setup-shared-hosting-2.4.sh b/scripts/setup-shared-hosting-2.4.sh index fef25245..00d4d0d0 100644 --- a/scripts/setup-shared-hosting-2.4.sh +++ b/scripts/setup-shared-hosting-2.4.sh @@ -9,4 +9,3 @@ unzip web2py_src.zip cd web2py # start web2py using command-line script w2env/bin/python web2py.py -i 0.0.0.0 -p 8123 -a 'adminpasswd' - diff --git a/scripts/setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh b/scripts/setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh index 84a0b0f2..5c13c83d 100644 --- a/scripts/setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh +++ b/scripts/setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh @@ -3,8 +3,8 @@ # ------------------------------------------------------------------------------ # Description : Installation and basic configuration of web2py, uWSGI, Redmine, # Unicorn, Nginx and PostgreSQL. -# Usage : Copy the script in /home/username and run it as root, you may -# need to allow exectuion (chmod +x). Ex.: +# Usage : Copy the script in /home/username and run it as root, you may +# need to allow exectuion (chmod +x). Ex.: # sudo ./setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh # File : setup-ubuntu-12-04-redmine-unicorn-web2py-uwsgi-nginx.sh # Author : Richard V?zina @@ -58,8 +58,8 @@ wget http://rubyforge.org/frs/download.php/76628/redmine-2.2.0.tar.gz.md5 md5sum --check redmine-2.2.0.tar.gz.md5 > redmine_md5_checked_successfully if [ -f redmine_md5_checked_successfully ] then - tar xvfz redmine-2.2.0.tar.gz - rm redmine_md5_checked_successfully + tar xvfz redmine-2.2.0.tar.gz + rm redmine_md5_checked_successfully else echo "Redmine md5 check sum failed..." exit 1 @@ -98,9 +98,9 @@ echo 'production: rake generate_secret_token RAILS_ENV=production rake db:migrate RAILS_ENV=production rake redmine:load_default_data -mkdir /opt/redmine-2.2.0/tmp/pids +mkdir /opt/redmine-2.2.0/tmp/pids #mkdir /opt/redmine-2.2.0/log # if not there -cd /opt/redmine-2.2.0/config +cd /opt/redmine-2.2.0/config # Create Unicorn specific Redmine config in /opt/redmine-2.2.0/config/unicorn.rb echo '#unicorn.rb Starts here worker_processes 1 @@ -115,8 +115,8 @@ timeout 45 # This is where we specify the socket. # We will point the upstream Nginx module to this socket later on -listen "/tmp/unicorn_rails.socket", :backlog => 64 #directory structure needs to be created. -pid "/opt/redmine-2.2.0/tmp/pids/unicorn_rails.pid" # make sure this points to a valid directory. Make sure it is named the same as the real process name in order to allow init.d script start-stop-daemon command to kill unicorn process properly +listen "/tmp/unicorn_rails.socket", :backlog => 64 #directory structure needs to be created. +pid "/opt/redmine-2.2.0/tmp/pids/unicorn_rails.pid" # make sure this points to a valid directory. Make sure it is named the same as the real process name in order to allow init.d script start-stop-daemon command to kill unicorn process properly # Set the path of the log files inside the log folder of the testapp stderr_path "/opt/redmine-2.2.0/log/unicorn_rails.stderr.log" @@ -139,7 +139,7 @@ ActiveRecord::Base.establish_connection worker.user('\''www-data'\'', '\''www-data'\'') if Process.euid == 0 end #unicorn.rb Ends here' > unicorn.rb -chown www-data:www-data unicorn.rb +chown www-data:www-data unicorn.rb chown -R www-data:www-data /opt/redmine-2.2.0/tmp mkdir /etc/unicorn # Set some config for Unicorn in /etc/unicorn/redmine @@ -161,7 +161,7 @@ echo '#! /bin/sh # ------------------------------------------------------------------------------ # Author: Richard V?zina # Base on Ubuntu 12.04 : /etc/init.d/skeleton -# ven 21 d?c 2012 11:08:31 EST +# ven 21 d?c 2012 11:08:31 EST # ------------------------------------------------------------------------------ # Do NOT "set -e" @@ -195,18 +195,18 @@ SCRIPTNAME=/etc/init.d/redmine # do_start() { - # Return - # 0 if daemon has been started - # 1 if daemon was already running - # 2 if daemon could not be started - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ - || return 1 - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ - $DAEMON_ARGS \ - || return 2 - # Add code here, if necessary, that waits for the process to be ready - # to handle requests from services started subsequently which depend - # on this one. As a last resort, sleep for some time. + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ + $DAEMON_ARGS \ + || return 2 + # Add code here, if necessary, that waits for the process to be ready + # to handle requests from services started subsequently which depend + # on this one. As a last resort, sleep for some time. } # @@ -214,108 +214,108 @@ do_start() # do_stop() { - # Return - # 0 if daemon has been stopped - # 1 if daemon was already stopped - # 2 if daemon could not be stopped - # other if a failure occurred - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME - RETVAL="$?" - [ "$RETVAL" = 2 ] && return 2 - # Wait for children to finish too if this is a daemon that forks - # and if the daemon is only ever run from this initscript. - # If the above conditions are not satisfied then add some other code - # that waits for the process to drop all resources that could be - # needed by services started subsequently. A last resort is to - # sleep for some time. - start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON - [ "$?" = 2 ] && return 2 - # Many daemons don'\''t delete their pidfiles when they exit. - rm -f $PIDFILE - return "$RETVAL" + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + # Wait for children to finish too if this is a daemon that forks + # and if the daemon is only ever run from this initscript. + # If the above conditions are not satisfied then add some other code + # that waits for the process to drop all resources that could be + # needed by services started subsequently. A last resort is to + # sleep for some time. + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + [ "$?" = 2 ] && return 2 + # Many daemons don'\''t delete their pidfiles when they exit. + rm -f $PIDFILE + return "$RETVAL" } # # Function that sends a SIGHUP to the daemon/service # do_reload() { - # - # If the daemon can reload its configuration without - # restarting (for example, when it is sent a SIGHUP), - # then implement that here. - # - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME - return 0 + # + # If the daemon can reload its configuration without + # restarting (for example, when it is sent a SIGHUP), + # then implement that here. + # + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + return 0 } case "$1" in start) - [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" - do_start - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; stop) - [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" - do_stop - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; status) status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? ;; #reload|force-reload) - # - # If do_reload() is not implemented then leave this commented out - # and leave '\''force-reload'\'' as an alias for '\''restart'\''. - # - #log_daemon_msg "Reloading $DESC" "$NAME" - #do_reload - #log_end_msg $? - #;; + # + # If do_reload() is not implemented then leave this commented out + # and leave '\''force-reload'\'' as an alias for '\''restart'\''. + # + #log_daemon_msg "Reloading $DESC" "$NAME" + #do_reload + #log_end_msg $? + #;; restart|force-reload) - # - # If the "reload" option is implemented then remove the - # '\''force-reload'\'' alias - # - log_daemon_msg "Restarting $DESC" "$NAME" - do_stop - case "$?" in - 0|1) - do_start - case "$?" in - 0) log_end_msg 0 ;; - 1) log_end_msg 1 ;; # Old process is still running - *) log_end_msg 1 ;; # Failed to start - esac - ;; - *) - # Failed to stop - log_end_msg 1 - ;; - esac - ;; + # + # If the "reload" option is implemented then remove the + # '\''force-reload'\'' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; *) - #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 - echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 - exit 3 - ;; + #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; esac :' > /etc/init.d/redmine chmod +x /etc/init.d/redmine -# Backup default Nginx site and replace it +# Backup default Nginx site and replace it cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default_original rm /etc/nginx/sites-available/default # Create configuration file /etc/nginx/sites-available/default -echo 'upstream unicorn_server { - # This is the socket we configured in unicorn.rb - server unix:/tmp/unicorn_rails.socket - fail_timeout=0; +echo 'upstream unicorn_server { + # This is the socket we configured in unicorn.rb + server unix:/tmp/unicorn_rails.socket + fail_timeout=0; } server { listen 80; @@ -323,8 +323,8 @@ server { charset utf-8; server_name localhost; # $hostname; root /var/www; - access_log /var/log/nginx/yoursite.access.log; - error_log /var/log/nginx/yoursite.error.log; + access_log /var/log/nginx/yoursite.access.log; + error_log /var/log/nginx/yoursite.error.log; #to enable correct use of response.static_version #location ~* /(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ { # alias /home/www-data/web2py/applications/$1/static/$2; @@ -342,16 +342,16 @@ server { uwsgi_param UWSGI_SCHEME $scheme; uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; } - location / { - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_redirect off; - - if (!-f $request_filename) { - proxy_pass http://unicorn_server; - break; - } - } + location / { + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + + if (!-f $request_filename) { + proxy_pass http://unicorn_server; + break; + } + } } server { listen 443 default_server ssl; @@ -360,12 +360,12 @@ server { root /var/www; ssl_certificate /etc/nginx/ssl/self_signed.cert; ssl_certificate_key /etc/nginx/ssl/self_signed.key; - ssl_prefer_server_ciphers on; - ssl_session_cache shared:SSL:10m; - ssl_session_timeout 10m; - ssl_ciphers ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA; - ssl_protocols SSLv3 TLSv1; - keepalive_timeout 70; + ssl_prefer_server_ciphers on; + ssl_session_cache shared:SSL:10m; + ssl_session_timeout 10m; + ssl_ciphers ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA; + ssl_protocols SSLv3 TLSv1; + keepalive_timeout 70; location ~^\/(?!redmine(.*)) { #uwsgi_pass 127.0.0.1:9001; uwsgi_pass unix:///tmp/web2py.socket; @@ -373,16 +373,16 @@ server { uwsgi_param UWSGI_SCHEME $scheme; uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; } - location / { - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_redirect off; - - if (!-f $request_filename) { - proxy_pass http://unicorn_server; - break; - } - } + location / { + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + + if (!-f $request_filename) { + proxy_pass http://unicorn_server; + break; + } + } }' >/etc/nginx/sites-available/default @@ -392,8 +392,8 @@ server { # We copy ssl files we previously created if [ -f /etc/nginx/ssl ] then - cp ~/self_signed.* /etc/nginx/ssl/ - rm ~/self_signed.* + cp ~/self_signed.* /etc/nginx/ssl/ + rm ~/self_signed.* else mkdir /etc/nginx/ssl cp ~/self_signed.* /etc/nginx/ssl/ diff --git a/scripts/setup-virtualenv-web2py.sh b/scripts/setup-virtualenv-web2py.sh index 8901a423..2141d277 100644 --- a/scripts/setup-virtualenv-web2py.sh +++ b/scripts/setup-virtualenv-web2py.sh @@ -1,33 +1,33 @@ # -# Author: Christopher Steel -# Organization: Voice of Access -# Date: 2010-11-24 -# License: Same as Web2py, MIT / GNU -# Email: Christopher DOT Steel AT Voice of Access DOT org +# Author: Christopher Steel +# Organization: Voice of Access +# Date: 2010-11-24 +# License: Same as Web2py, MIT / GNU +# Email: Christopher DOT Steel AT Voice of Access DOT org # # This script will : -# download and install virtualenv -# start a virtual environment -# move into the virtual environment -# download and install latest stable version of web2py -# start web2py in the virtual environment +# download and install virtualenv +# start a virtual environment +# move into the virtual environment +# download and install latest stable version of web2py +# start web2py in the virtual environment # # To disactivate the virtual environment, shut down web2py # and type 'disactivate' at the command line. # # Testing: -# OS X -# should work on POSIX systems +# OS X +# should work on POSIX systems # # Usage: -# create a directory to hold your virtual environments, for example -# /home/user_name/virtual_environments -# place this script in the directory and make it executable -# chmod +x web2py-install-virtualenv.sh - customize the variables below to meet your needs -# execute from terminal -# ./web2py-install-virtualenv.sh -# relax... +# create a directory to hold your virtual environments, for example +# /home/user_name/virtual_environments +# place this script in the directory and make it executable +# chmod +x web2py-install-virtualenv.sh + customize the variables below to meet your needs +# execute from terminal +# ./web2py-install-virtualenv.sh +# relax... ################ VARIABLES # Change to reflect version changes etc. @@ -94,8 +94,3 @@ read -p "Press any key to start web2py…" echo 'starting web2py' echo '===============' ../bin/python2.5 web2py.py - - - - - diff --git a/scripts/setup-web2py-fedora-ami.sh b/scripts/setup-web2py-fedora-ami.sh index a42d5edb..48b78a9f 100755 --- a/scripts/setup-web2py-fedora-ami.sh +++ b/scripts/setup-web2py-fedora-ami.sh @@ -398,4 +398,3 @@ cd ${current_directory} echo " - Complete!" echo - diff --git a/scripts/setup-web2py-nginx-uwsgi-on-centos.sh b/scripts/setup-web2py-nginx-uwsgi-on-centos.sh index c10e3951..74461aac 100644 --- a/scripts/setup-web2py-nginx-uwsgi-on-centos.sh +++ b/scripts/setup-web2py-nginx-uwsgi-on-centos.sh @@ -346,5 +346,3 @@ reboot as superuser " - - diff --git a/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh b/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh index 2f48a349..725f220d 100644 --- a/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh +++ b/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh @@ -48,7 +48,7 @@ echo 'server { # expires max; #} ### - + ###if you use something like myapp = dict(languages=['en', 'it', 'jp'], default_language='en') in your routes.py #location ~* /(\w+)/(en|it|jp)/static/(.*)$ { # alias /home/www-data/web2py/applications/$1/; @@ -70,14 +70,14 @@ echo 'server { include uwsgi_params; uwsgi_param UWSGI_SCHEME $scheme; uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; - + ###remove the comments to turn on if you want gzip compression of your pages # include /etc/nginx/conf.d/web2py/gzip.conf; ### end gzip section ### remove the comments if you use uploads (max 10 MB) #client_max_body_size 10m; - ### + ### } } server { @@ -102,28 +102,28 @@ server { ### end gzip section ### remove the comments if you want to enable uploads (max 10 MB) #client_max_body_size 10m; - ### + ### } ## if you serve static files through https, copy here the section ## from the previous server instance to manage static files - + }' >/etc/nginx/sites-available/web2py - + ln -s /etc/nginx/sites-available/web2py /etc/nginx/sites-enabled/web2py rm /etc/nginx/sites-enabled/default mkdir /etc/nginx/ssl cd /etc/nginx/ssl - + openssl genrsa 1024 > web2py.key chmod 400 web2py.key openssl req -new -x509 -nodes -sha1 -days 1780 -key web2py.key > web2py.crt openssl x509 -noout -fingerprint -text < web2py.crt > web2py.info - - + + # Prepare folders for uwsgi sudo mkdir /etc/uwsgi sudo mkdir /var/log/uwsgi - + # Create configuration file /etc/uwsgi/web2py.xml echo '[uwsgi] @@ -145,11 +145,11 @@ gid = www-data cron = 0 0 -1 -1 -1 python /home/www-data/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -o no-orphans = true ' >/etc/uwsgi/web2py.ini - + #Create a configuration file for uwsgi in emperor-mode #for Upstart in /etc/init/uwsgi-emperor.conf echo '# Emperor uWSGI script - + description "uWSGI Emperor" start on runlevel [2345] stop on runlevel [06] @@ -177,7 +177,7 @@ cd /home/www-data/web2py sudo -u www-data python -c "from gluon.main import save_password; save_password('$PW',443)" start uwsgi-emperor /etc/init.d/nginx restart - + ## you can reload uwsgi with # restart uwsgi-emperor ## and stop it with diff --git a/scripts/setup-web2py-ubuntu.sh b/scripts/setup-web2py-ubuntu.sh index ffcbf552..eca6e838 100755 --- a/scripts/setup-web2py-ubuntu.sh +++ b/scripts/setup-web2py-ubuntu.sh @@ -175,4 +175,3 @@ cd /home/www-data/web2py sudo -u www-data python -c "from gluon.widget import console; console();" sudo -u www-data python -c "from gluon.main import save_password; save_password(raw_input('admin password: '),443)" echo "done!" - diff --git a/scripts/update-web2py.sh b/scripts/update-web2py.sh index f7747a85..2ad88403 100755 --- a/scripts/update-web2py.sh +++ b/scripts/update-web2py.sh @@ -13,13 +13,13 @@ TARGET=web2py if [ ! -d $TARGET ]; then - # in case we're in web2py/ - if [ -f ../$TARGET/VERSION ]; then - cd .. - # in case we're in web2py/scripts - elif [ -f ../../$TARGET/VERSION ]; then - cd ../.. - fi + # in case we're in web2py/ + if [ -f ../$TARGET/VERSION ]; then + cd .. + # in case we're in web2py/scripts + elif [ -f ../../$TARGET/VERSION ]; then + cd ../.. + fi fi read a VERSION c < $TARGET/VERSION SAVE=$TARGET-$VERSION @@ -32,14 +32,14 @@ SAVED="" # but don't overwrite a previous save of the same version. # if [ -f $SAVE.zip ]; then - echo "Remove or rename $SAVE.zip first" >&2 - exit 1 + echo "Remove or rename $SAVE.zip first" >&2 + exit 1 fi if [ -d $TARGET ]; then - echo -n ">>Save old version: " >&2 - cat $TARGET/VERSION >&2 - zip -q -r $SAVE.zip $TARGET - SAVED=$SAVE.zip + echo -n ">>Save old version: " >&2 + cat $TARGET/VERSION >&2 + zip -q -r $SAVE.zip $TARGET + SAVED=$SAVE.zip fi # # Download the new version. @@ -54,6 +54,5 @@ rm $ZIP echo -n ">>New version: " >&2 cat $TARGET/VERSION >&2 if [ "$SAVED" != "" ]; then - echo ">>Old version saved as $SAVED" + echo ">>Old version saved as $SAVED" fi - diff --git a/scripts/web2py.archlinux.sh b/scripts/web2py.archlinux.sh index 85439ee0..b6c56ea3 100755 --- a/scripts/web2py.archlinux.sh +++ b/scripts/web2py.archlinux.sh @@ -55,4 +55,3 @@ case "$1" in esac exit 0 - diff --git a/scripts/web2py.fedora.sh b/scripts/web2py.fedora.sh index c2f42f41..bb3a2534 100644 --- a/scripts/web2py.fedora.sh +++ b/scripts/web2py.fedora.sh @@ -28,55 +28,54 @@ PYTHON=python cd $DAEMON_DIR start() { - echo -n $"Starting $DESC ($NAME): " - daemon --check $NAME $PYTHON $DAEMON_DIR/web2py.py -Q --nogui -a $ADMINPASS -d $PIDFILE -p $PORT & - RETVAL=$? - if [ $RETVAL -eq 0 ]; then - touch /var/lock/subsys/$NAME - fi - echo - return $RETVAL + echo -n $"Starting $DESC ($NAME): " + daemon --check $NAME $PYTHON $DAEMON_DIR/web2py.py -Q --nogui -a $ADMINPASS -d $PIDFILE -p $PORT & + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + touch /var/lock/subsys/$NAME + fi + echo + return $RETVAL } stop() { - echo -n $"Shutting down $DESC ($NAME): " - killproc -p "$PIDFILE" -d 3 "$NAME" - echo - if [ $RETVAL -eq 0 ]; then - rm -f /var/lock/subsys/$NAME - rm -f $PIDFILE - fi - return $RETVAL + echo -n $"Shutting down $DESC ($NAME): " + killproc -p "$PIDFILE" -d 3 "$NAME" + echo + if [ $RETVAL -eq 0 ]; then + rm -f /var/lock/subsys/$NAME + rm -f $PIDFILE + fi + return $RETVAL } restart() { - stop - start + stop + start } status() { - if [ -r "$PIDFILE" ]; then - pid=`cat $PIDFILE` - fi - if [ $pid ]; then - echo "$NAME (pid $pid) is running..." - else - echo "$NAME is stopped" - fi + if [ -r "$PIDFILE" ]; then + pid=`cat $PIDFILE` + fi + if [ $pid ]; then + echo "$NAME (pid $pid) is running..." + else + echo "$NAME is stopped" + fi } case "$1" in - start) start;; - stop) stop;; - status) status;; - restart) restart;; - condrestart) [ -e /var/lock/subsys/$NAME ] && restart - RETVAL=$? - ;; - *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" - RETVAL=1 - ;; + start) start;; + stop) stop;; + status) status;; + restart) restart;; + condrestart) [ -e /var/lock/subsys/$NAME ] && restart + RETVAL=$? + ;; + *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" + RETVAL=1 + ;; esac exit $RETVAL - diff --git a/scripts/web2py.ubuntu.sh b/scripts/web2py.ubuntu.sh index 8852fdc5..d3dc19ea 100755 --- a/scripts/web2py.ubuntu.sh +++ b/scripts/web2py.ubuntu.sh @@ -48,26 +48,26 @@ DAEMON_USER=web2py # do_start() { - # Return - # 0 if daemon has been started - # 1 if daemon was already running - # 2 if daemon could not be started + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started - # The PIDDIR should normally be created during installation. This - # fixes things just in case. - [ -d $PIDDIR ] || mkdir -p $PIDDIR + # The PIDDIR should normally be created during installation. This + # fixes things just in case. + [ -d $PIDDIR ] || mkdir -p $PIDDIR [ -n "$DAEMON_USER" ] && chown --recursive $DAEMON_USER $PIDDIR - # Check to see if the daemon is already running. - start-stop-daemon --stop --test --quiet --pidfile $PIDFILE \ - && return 1 + # Check to see if the daemon is already running. + start-stop-daemon --stop --test --quiet --pidfile $PIDFILE \ + && return 1 - start-stop-daemon --start --quiet --pidfile $PIDFILE \ - ${DAEMON_USER:+--chuid $DAEMON_USER} --chdir $DAEMON_DIR \ - --background --exec $DAEMON -- $DAEMON_ARGS \ - || return 2 + start-stop-daemon --start --quiet --pidfile $PIDFILE \ + ${DAEMON_USER:+--chuid $DAEMON_USER} --chdir $DAEMON_DIR \ + --background --exec $DAEMON -- $DAEMON_ARGS \ + || return 2 - return 0; + return 0; } # @@ -75,17 +75,17 @@ do_start() # do_stop() { - # Return - # 0 if daemon has been stopped - # 1 if daemon was already stopped - # 2 if daemon could not be stopped - # other if a failure occurred + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE - RETVAL=$? - # Many daemons don't delete their pidfiles when they exit. - rm -f $PIDFILE - return "$RETVAL" + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE + RETVAL=$? + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + return "$RETVAL" } # @@ -93,37 +93,37 @@ do_stop() # do_restart() { - # Return - # 0 if daemon was (re-)started - # 1 if daemon was not strated or re-started + # Return + # 0 if daemon was (re-)started + # 1 if daemon was not strated or re-started - do_stop - case "$?" in - 0|1) - do_start - case "$?" in - 0) RETVAL=0 ;; - 1) RETVAL=1 ;; # Old process is still running - *) RETVAL=1 ;; # Failed to start - esac - ;; - *) RETVAL=1 ;; # Failed to stop - esac + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) RETVAL=0 ;; + 1) RETVAL=1 ;; # Old process is still running + *) RETVAL=1 ;; # Failed to start + esac + ;; + *) RETVAL=1 ;; # Failed to stop + esac - return "$RETVAL" + return "$RETVAL" } # # Function that sends a SIGHUP to the daemon/service # do_reload() { - # - # If the daemon can reload its configuration without - # restarting (for example, when it is sent a SIGHUP), - # then implement that here. - # - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE - return 0 + # + # If the daemon can reload its configuration without + # restarting (for example, when it is sent a SIGHUP), + # then implement that here. + # + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE + return 0 } # @@ -131,79 +131,79 @@ do_reload() { # do_status() { - # Return - # 0 if daemon is responding and OK - # 1 if daemon is not responding, but PIDFILE exists - # 2 if daemon is not responding, but LOCKFILE exists - # 3 if deamon is not running - # 4 if daemon status is unknown + # Return + # 0 if daemon is responding and OK + # 1 if daemon is not responding, but PIDFILE exists + # 2 if daemon is not responding, but LOCKFILE exists + # 3 if deamon is not running + # 4 if daemon status is unknown - # Check to see if the daemon is already running. - start-stop-daemon --stop --test --quiet --pidfile $PIDFILE \ - && return 0 - [ -f $PIDFILE ] && return 1 - return 3 + # Check to see if the daemon is already running. + start-stop-daemon --stop --test --quiet --pidfile $PIDFILE \ + && return 0 + [ -f $PIDFILE ] && return 1 + return 3 } case "$1" in start) - [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" - do_start - RETVAL=$? - [ "$VERBOSE" != no ] && - case "$RETVAL" in - 0|1) log_end_msg 0 ;; - *) log_end_msg 1 ;; - esac - exit "$RETVAL" - ;; + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + RETVAL=$? + [ "$VERBOSE" != no ] && + case "$RETVAL" in + 0|1) log_end_msg 0 ;; + *) log_end_msg 1 ;; + esac + exit "$RETVAL" + ;; stop) - [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" - do_stop - RETVAL=$? - [ "$VERBOSE" != no ] && - case "$RETVAL" in - 0|1) log_end_msg 0 ;; - *) log_end_msg 1 ;; - esac - exit "$RETVAL" - ;; + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + RETVAL=$? + [ "$VERBOSE" != no ] && + case "$RETVAL" in + 0|1) log_end_msg 0 ;; + *) log_end_msg 1 ;; + esac + exit "$RETVAL" + ;; #reload|force-reload) - # - # If do_reload() is not implemented then leave this commented out - # and leave 'force-reload' as an alias for 'restart'. - # - #[ "$VERBOSE" != no ] && log_daemon_msg "Reloading $DESC" "$NAME" - #do_reload - #RETVAL=$? - #[ "$VERBOSE" != no ] && log_end_msg $? - #exit "$RETVAL" - #;; + # + # If do_reload() is not implemented then leave this commented out + # and leave 'force-reload' as an alias for 'restart'. + # + #[ "$VERBOSE" != no ] && log_daemon_msg "Reloading $DESC" "$NAME" + #do_reload + #RETVAL=$? + #[ "$VERBOSE" != no ] && log_end_msg $? + #exit "$RETVAL" + #;; restart|force-reload) - # - # If the "reload" option is implemented then remove the - # 'force-reload' alias - # - [ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME" - do_restart - RETVAL=$? - [ "$VERBOSE" != no ] && log_end_msg "$RETVAL" - exit "$RETVAL" - ;; + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + [ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME" + do_restart + RETVAL=$? + [ "$VERBOSE" != no ] && log_end_msg "$RETVAL" + exit "$RETVAL" + ;; status) do_status - RETVAL=$? + RETVAL=$? [ "$VERBOSE" != no ] && - case "$RETVAL" in - 0) log_success_msg "$NAME is running" ;; - *) log_failure_msg "$NAME is not running" ;; - esac + case "$RETVAL" in + 0) log_success_msg "$NAME is running" ;; + *) log_failure_msg "$NAME is not running" ;; + esac exit "$RETVAL" - ;; + ;; *) - echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 - exit 3 - ;; + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 + exit 3 + ;; esac : @@ -220,4 +220,3 @@ esac # http://refspecs.linux-foundation.org/LSB_3.2.0/LSB-Core-generic/LSB-Core-generic.pdf # Debian Policy SysV init: http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit # Examine files in /usr/share/doc/sysv-rc/ -