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