Plinth now hosted on (server)/plinth.

Plinth has been moved from plinth.(server).local to (server)/plinth.
*plinth.py* has been updated to take a new *--server_dir* argument,
which *share/init.d/plinth* now provides.  *plinth.sample.config* has
also been updated.

Actually, the whole package has been moved to a more Debian-friendly
configuration.  *share/apache2/plinth.conf* has been updated to
reflect the standard Debian directories.  It seems to make more sense
this way, as (other than FreedomMaker, which now uses this package
anyway) no other tools or derivatives use this system.  The
configuration can be patched out by other distributions easily enough.
This commit is contained in:
Nick Daly 2013-10-27 16:01:28 -05:00
parent 1da32164e5
commit 421f20005e
4 changed files with 61 additions and 42 deletions

View File

@ -83,24 +83,41 @@ def load_modules():
def parse_arguments():
parser = argparse.ArgumentParser(description='Plinth web interface for the FreedomBox.')
parser.add_argument('--pidfile', default="",
parser.add_argument('--pidfile',
help='specify a file in which the server may write its pid')
parser.add_argument('--directory', default="/",
help='specify a subdirectory to host the server.')
# FIXME make this work with basehref for static files.
parser.add_argument('--server_dir',
help='specify where to host the server.')
args=parser.parse_args()
if args.pidfile:
cfg.pidfile = args.pidfile
else:
set_config(args, "pidfile", "plinth.pid")
set_config(args, "server_dir", "/")
return cfg
def set_config(args, element, default):
"""Sets *cfg* elements based on *args* values, or uses a reasonable default.
- If values are passed in from *args*, use those.
- If values are read from the config file, use those.
- If no values have been given, use default.
"""
try:
# cfg.(element) = args.(element)
setattr(cfg, element, getattr(args, element))
except AttributeError:
# if it fails, we didn't receive that argument.
try:
if not cfg.pidfile:
cfg.pidfile = "plinth.pid"
# if not cfg.(element): cfg.(element) = default
if not getattr(cfg, element):
setattr(cfg, element, default)
except AttributeError:
cfg.pidfile = "plinth.pid"
return args
# it wasn't in the config file, but set the default anyway.
setattr(cfg, element, default)
def setup():
args = parse_arguments()
cfg = parse_arguments()
try:
if cfg.pidfile:
@ -146,12 +163,11 @@ def setup():
'/favicon.ico':{'tools.staticfile.on': True,
'tools.staticfile.filename':
"%s/static/theme/favicon.ico" % cfg.file_root}}
cherrypy.tree.mount(cfg.html_root, args.directory, config=config)
cherrypy.tree.mount(cfg.html_root, cfg.server_dir, config=config)
cherrypy.engine.signal_handler.subscribe()
def main():
setup()
print "%s %d" % (cfg.host, cfg.port)
cherrypy.engine.start()
cherrypy.engine.block()

View File

@ -12,6 +12,7 @@ status_log_file = %(data_dir)s/status.log
access_log_file = %(data_dir)s/access.log
users_dir = %(data_dir)s/users
pidfile = %(data_dir)s/pidfile.pid
server_dir = plinth/
[Network]
host = 127.0.0.1

View File

@ -1,53 +1,53 @@
<VirtualHost *:80>
## Use this rule to hang plinth off of plinth.(servername)
## The DocumentRoot is set by fabric
## Shared options.
DocumentRoot /dev/null
ServerName plinth
ServerAlias plinth.*
## Force SSL
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
## Use this rule to hang plinth off of plinth.(servername)
# ServerName plinth
# ServerAlias plinth.*
</VirtualHost>
<VirtualHost *:443>
## Shared options.
ProxyPreserveHost on
DocumentRoot /usr/share/plinth/static
ProxyPass /static !
## Enable SSL
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
## Use this rule to hang plinth off of plinth.(servername)
## The DocumentRoot is set by fabric
DocumentRoot /home/fbx/plinth/static
ServerName plinth
ServerAlias plinth.*
ProxyPreserveHost on
ProxyPass /static !
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/
<Proxy *>
Order Deny,Allow
Deny from All
Allow from 10.0.0.0/8
Allow from 172.16.0.0/12
Allow from 192.168.0.0/16
</Proxy>
## Use this rule to hang plinth off a subdir.
## Make sure to provide plinth with a default directory: /plinth
# <Location /plinth>
# ProxyPass http://localhost:8000/plinth
# ProxyPassReverse http://localhost:8000/plinth
#
# ServerName plinth
# ServerAlias plinth.*
# ProxyPass / http://localhost:8000/
# ProxyPassReverse / http://localhost:8000/
# <Proxy *>
# Order Deny,Allow
# Deny from All
# Allow from 10.0.0.0/8
# Allow from 172.16.0.0/12
# Allow from 192.168.0.0/16
# </Location>
# </Proxy>
## Use this rule to hang plinth off a subdir.
## Make sure to provide plinth with a default directory: /plinth
<Location /plinth>
ProxyPass http://localhost:8000/plinth
ProxyPassReverse http://localhost:8000/plinth
Order Deny,Allow
Deny from All
Allow from 10.0.0.0/8
Allow from 172.16.0.0/12
Allow from 192.168.0.0/16
</Location>
</VirtualHost>

View File

@ -17,6 +17,7 @@ NAME=plinth
DAEMON=/usr/bin/plinth
PID_FILE=/var/run/plinth.pid
SERVER_DIR=/plinth
PLINTH_USER=plinth
PLINTH_GROUP=plinth
@ -28,7 +29,8 @@ test -x $DAEMON || exit 0
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
start_daemon -p $PID_FILE $DAEMON --pidfile=$PID_FILE
start_daemon -p $PID_FILE $DAEMON --pidfile=$PID_FILE \
--server_dir=$SERVER_DIR
log_end_msg $?
;;
stop)