mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
Merge pull request #1 from SunilMohanAdapa/file-structure
Re-organize file structure
This commit is contained in:
commit
0b5af37610
14
.gitignore
vendored
14
.gitignore
vendored
@ -1,12 +1,11 @@
|
||||
current-*.tar.gz
|
||||
*.pyc
|
||||
*.py.bak
|
||||
*.swp
|
||||
*.tiny.css
|
||||
data/*.log
|
||||
data/cherrypy_sessions
|
||||
data/sessions
|
||||
data/store.sqlite3
|
||||
data/var/log/plinth/*.log
|
||||
data/var/lib/plinth/*.sqlite3
|
||||
data/var/lib/plinth/sessions/*
|
||||
data/var/run/*.pid
|
||||
doc/*.tex
|
||||
doc/*.pdf
|
||||
doc/*.html
|
||||
@ -20,13 +19,12 @@ doc/README.mdwn
|
||||
doc/TODO.mdwn
|
||||
doc/oneline.txt
|
||||
doc/plinth.1
|
||||
plinth.config
|
||||
TODO
|
||||
\#*
|
||||
.#*
|
||||
*~
|
||||
data/plinth.sqlite3
|
||||
predepend
|
||||
build/
|
||||
*.pid
|
||||
.emacs.desktop*
|
||||
*.egg-info/
|
||||
dist/
|
||||
|
||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -1,6 +0,0 @@
|
||||
[submodule "vendor/withsqlite"]
|
||||
path = vendor/withsqlite
|
||||
url = git://github.com/jvasile/withsqlite.git
|
||||
[submodule "vendor/exmachina"]
|
||||
path = vendor/exmachina
|
||||
url = git://github.com/jvasile/exmachina.git
|
||||
60
COPYING
60
COPYING
@ -1199,63 +1199,3 @@ recommend releasing these examples in parallel under your choice of
|
||||
free software license, such as the GNU General Public License,
|
||||
to permit their use in free software.
|
||||
|
||||
## FileDict License.
|
||||
|
||||
Copyright (c) 2009, Erez
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of the <ORGANIZATION> nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
## Cherrpy License
|
||||
|
||||
Copyright (c) 2002-2008, CherryPy Team (team@cherrypy.org)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of the CherryPy Team nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
123
HACKING
Normal file
123
HACKING
Normal file
@ -0,0 +1,123 @@
|
||||
# Hacking
|
||||
|
||||
## Installing for Development
|
||||
|
||||
1. Instead of running "setup.py install" after every source modification, run
|
||||
the following command:
|
||||
|
||||
$ sudo python setup.py develop
|
||||
|
||||
This will install the python package in a special development mode. Run it
|
||||
normally. Any updates to the code (and core pakcage data files) do not
|
||||
require re-installation after every modification.
|
||||
|
||||
CherryPy web server also monitors changes to the source files and reloads
|
||||
the server as soon as a file is modified. Hence it is usually sufficient
|
||||
to modify the source and refresh the browser page to see the changes.
|
||||
|
||||
2. Plinth also support running without installing (as much as possible).
|
||||
Simply run it as:
|
||||
|
||||
$ sudo python -m plinth --no-daemon --debug
|
||||
|
||||
In this mode, Plinth runs in working directory without need for
|
||||
installation. It uses a different config file (plinth.conf in working
|
||||
directory) instead of the regular config file (/etc/plinth/plinth.conf). It
|
||||
creates all that data and runtime files in data/var/*. To make Plinth
|
||||
pickup the config file in working directory, simply delete
|
||||
/etc/plinth/plinth.config.
|
||||
|
||||
*Note:* This mode is supported only in a limited manner. The following are
|
||||
the unknown issues with it:
|
||||
|
||||
1. It does not work without the --debug and --no-daemon flags.
|
||||
|
||||
2. Help pages are also not built. Run 'make -C doc' manaully.
|
||||
|
||||
3. Actions do not work when running as normal user without 'sudo' prefix.
|
||||
You need to add 'actions' directory to be allowed for 'sudo' commands.
|
||||
See data/etc/sudoers.d/plinth for a hint.
|
||||
|
||||
## Running Tests
|
||||
|
||||
1. Run tests:
|
||||
|
||||
$ python setup.py test
|
||||
|
||||
## Testing Inside a Virtual Machine
|
||||
|
||||
1. Checkout source on the host.
|
||||
|
||||
2. Share the source folder and mount it on virtual machine. This could be done
|
||||
over NFS, SSH-fs or 'Shared Folders' feature on VirtualBox.
|
||||
|
||||
3. Run 'setup.py develop' or 'setup.py install' as described above on guest
|
||||
machine.
|
||||
|
||||
4. Access the guest machine's Plinth web UI from host after setting bridging or
|
||||
NATing for guest virtual machine.
|
||||
|
||||
## Building the Documentation Separately
|
||||
|
||||
Documentation has been collected into a PDF. It also gets built into smaller
|
||||
files and other formats, including one suitable for install as a man page.
|
||||
|
||||
1. To build the documentation separately, run:
|
||||
|
||||
$ make -C doc
|
||||
|
||||
## Repository
|
||||
|
||||
Plinth is available from [GitHub](https://github.com/freedombox/plinth).
|
||||
|
||||
## Bugs & TODO
|
||||
|
||||
You can report bugs on Plinth's
|
||||
[issue tracker](https://github.com/freedombox/Plinth/issues).
|
||||
|
||||
Feel free to pickup a task by announcing it on the issue. Once you are done,
|
||||
request a merge. For information on placing a merge request, consult GitHub
|
||||
documentation.
|
||||
|
||||
## Coding Practices
|
||||
|
||||
Plinth confirms to [PEP 8](http://www.python.org/dev/peps/pep-0008/) Python
|
||||
coding standard. You should check your code with *pep8* and *pylint* tools
|
||||
before placing a merge request.
|
||||
|
||||
## Internationalization
|
||||
|
||||
Every module should `from gettext import gettext as _` and wrap
|
||||
displayed strings with _(). We don't have the language stuff in place
|
||||
yet (we have no translation files), but we need to put the
|
||||
infrastructure in place for it from the start. Use it like this:
|
||||
|
||||
log.error(_("Couldn't import %s: %s"), path, e)
|
||||
|
||||
## Dependencies
|
||||
|
||||
* *Bootstrap Form* - Render Django forms for Twitter Bootstrap
|
||||
|
||||
* *CherryPy3* - WSGI web server since Django does not have proper web server
|
||||
|
||||
* *Django* - Web application framework for Plinth
|
||||
|
||||
* *JQuery* - Javascript framework used for convenience
|
||||
|
||||
* *Modernizer* - HTML5 and CSS3 feature detection
|
||||
|
||||
* *Python* - tested with version 2.7
|
||||
|
||||
* *Twitter Bootstrap* - A responsive, mobile first front-end framework
|
||||
|
||||
* *Withsqlite* - Python library that stores dictionaries in sqlite3
|
||||
|
||||
The documentation has the following dependencies:
|
||||
|
||||
* *Markdown* - format and style docs
|
||||
|
||||
* *Pandoc* - Convert markdown to various formats
|
||||
|
||||
* *PDFLatex* - Generate PDF versions of the documentation
|
||||
|
||||
* *GNU Make* - Process doc/Makefile.
|
||||
51
INSTALL
51
INSTALL
@ -1,47 +1,24 @@
|
||||
# Quick Start
|
||||
# Installing Plinth
|
||||
|
||||
## Installing Plinth
|
||||
1. Install the dependencies:
|
||||
|
||||
Install the dependencies:
|
||||
On a Debian based system, run:
|
||||
|
||||
apt-get install pandoc psmisc python2.7 python-bcrypt python-cherrypy3 python-django python-passlib python-bootstrapform libjs-twitter-bootstrap sudo
|
||||
$ sudo apt-get install libjs-jquery libjs-modernizer \
|
||||
libjs-twitter-bootstrap make pandoc python2.7 python-cherrypy3 \
|
||||
python-django python-bootstrapform python-withsqlite
|
||||
|
||||
Unzip and untar the source into a directory. Change to the directory
|
||||
containing the program. Run:
|
||||
2. Install Plinth:
|
||||
|
||||
$ make
|
||||
Unzip the source into a directory. Change to the directory containing the
|
||||
program and run:
|
||||
|
||||
To start Plinth, run:
|
||||
$ sudo python setup.py install
|
||||
|
||||
$ ./start.sh
|
||||
3. Run Plinth:
|
||||
|
||||
and point your web browser at `localhost:8000`. The default username is "admin"
|
||||
and the default password is "secret".
|
||||
$ sudo plinth
|
||||
|
||||
## Dependencies
|
||||
4. Access Plinth UI:
|
||||
|
||||
* cherrypy - python web engine v3+
|
||||
|
||||
* python - tested with version 2.6.6
|
||||
|
||||
* *GNU Make* is used to build the templates and such.
|
||||
|
||||
* *libjs-twitter-bootstrap* - A responsive, mobile first front-end framework
|
||||
|
||||
* *python-bootstrapform* - Render django forms for Twitter Bootstrap
|
||||
|
||||
The documentation has some dependencies too.
|
||||
|
||||
* *Markdown* is used to format and style docs.
|
||||
|
||||
* *Pandoc* converts the markdown to different formats.
|
||||
|
||||
* *PDFLatex* generates pdf versions of the documentation.
|
||||
|
||||
* *GNU Make* processes /doc/Makefile.
|
||||
|
||||
## Building the Documentation
|
||||
|
||||
Documentation has been collected into a pdf that can be built using
|
||||
`make doc`. It also gets built into smaller files and other formats,
|
||||
including one suitable for install as a man page.
|
||||
Plinth UI should be accessible at http://localhost:8000
|
||||
|
||||
121
LICENSES
121
LICENSES
@ -4,27 +4,12 @@ For each of the files listed, the copyright specified for the file is
|
||||
listed. "-" means "no license specified in the file," licenses are
|
||||
specified and linked otherwise.
|
||||
|
||||
- actions.py :: -
|
||||
- cfg.py :: -
|
||||
- COPYING :: N/A
|
||||
- COPYRIGHTS :: N/A
|
||||
- fabfile.py :: -
|
||||
- INSTALL :: -
|
||||
- logger.py :: -
|
||||
- Makefile :: -
|
||||
- menu.py :: -
|
||||
- NOTES :: -
|
||||
- plinth :: -
|
||||
- plinth.config :: -
|
||||
- plinth.py :: [[file:plinth.py::__license__%20%3D%20"GPLv3%20or%20later"]["GPLv3 or later"]]
|
||||
- plinth.sample.config :: -
|
||||
- README :: -
|
||||
- start.sh :: -
|
||||
- test.sh :: -
|
||||
- TODO :: -
|
||||
- util.py :: different parts under different licenses:
|
||||
- [[file:util.py::def%20mkdir(newdir):][def mkdir(newdir):]] :: [[http://code.activestate.com/recipes/82465/][mkdir]] (PSF license), should be replaced with =os.makedirs()=
|
||||
- other parts :: -
|
||||
- actions/echo :: -
|
||||
- actions/hostname-change :: -
|
||||
- actions/id :: -
|
||||
@ -32,6 +17,11 @@ specified and linked otherwise.
|
||||
- actions/timezone-change :: -
|
||||
- actions/xmpp-register :: -
|
||||
- actions/xmpp-setup :: -
|
||||
- data/usr/lib/freedombox/setup.d/86_plinth :: -
|
||||
- data/etc/apache2/plinth.conf :: -
|
||||
- data/etc/apache2/plinth-ssl.conf :: -
|
||||
- data/etc/init.d/plinth :: -
|
||||
- data/etc/sudoers.d/plinth :: -
|
||||
- doc/colophon.mdwn :: -
|
||||
- doc/faq.mdwn :: -
|
||||
- doc/footer.html :: -
|
||||
@ -42,55 +32,52 @@ specified and linked otherwise.
|
||||
- doc/scripts.mdwn :: -
|
||||
- doc/security.mdwn :: -
|
||||
- doc/themes.mdwn :: -
|
||||
- modules/apps/apps.py :: -
|
||||
- modules/config/config.py :: -
|
||||
- modules/diagnostics/diagnostics.py :: -
|
||||
- modules/expert_mode/expert_mode.py :: -
|
||||
- modules/first_boot/first_boot.py :: -
|
||||
- modules/help/help.py :: -
|
||||
- modules/lib/auth.py :: -
|
||||
- modules/owncloud/owncloud.py :: -
|
||||
- modules/packages/packages.py :: -
|
||||
- modules/santiago/santiago.py :: -
|
||||
- modules/system/system.py :: -
|
||||
- modules/tor/tor.py :: -
|
||||
- modules/users/users.py :: -
|
||||
- modules/xmpp/xmpp.py :: -
|
||||
- setup/86_plinth :: -
|
||||
- share/apache2/plinth.conf :: -
|
||||
- share/apache2/plinth-ssl.conf :: -
|
||||
- share/init.d/plinth :: -
|
||||
- sudoers/plinth :: -
|
||||
- templates/base.html :: [[file:templates/base.tmpl::the%20<a%20href%3D"http:/www.gnu.org/licenses/agpl.html"%20target%3D"_blank">GNU%20Affero%20General%20Public][GNU Affero General Public License, Version 3 or later]]
|
||||
- tests/actions_test.py :: -
|
||||
- tests/auth_test.py :: -
|
||||
- tests/testdata/users.sqlite3 :: -
|
||||
- tests/user_store_test.py :: -
|
||||
- themes/default/FreedomBox-Identity-Manual.pdf :: -
|
||||
- themes/default/FreedomBox-Logo.7z :: [[http://thread.gmane.org/gmane.linux.debian.freedombox.user/4124/focus=4439][GPL3+/CC-BY-SA]]
|
||||
- themes/default/readme.md :: [[file:themes/default/readme.md::This%20theme%20is%20free%20software%20offered%20to%20you%20under%20the%20terms%20of%20the%20GNU%20Affero%20General%20Public%20License,%20Version%203%20or%20later:][GNU Affero General Public License Version 3]]
|
||||
- themes/default/screenshot.png :: -
|
||||
- themes/default/img/apple-touch-icon-114px-precomposed.png :: -
|
||||
- themes/default/img/apple-touch-icon-57px-precomposed.png :: -
|
||||
- themes/default/img/apple-touch-icon-72px-precomposed.png :: -
|
||||
- themes/default/img/apple-touch-icon.xcf :: -
|
||||
- themes/default/img/favicon-32px.ico :: -
|
||||
- themes/default/img/favicon.ico :: -
|
||||
- themes/default/img/freedombox-logo-200px.png :: -
|
||||
- themes/default/img/freedombox-logo-250px.png :: -
|
||||
- themes/default/img/freedombox-logo-32px.png :: -
|
||||
- themes/default/img/FreedomBox-logo-grayscale-negative.png :: -
|
||||
- themes/default/img/FreedomBox-logo-grayscale-negative.svg :: -
|
||||
- themes/default/img/FreedomBox-logo-grayscale.png :: -
|
||||
- themes/default/img/FreedomBox-logo-grayscale.svg :: -
|
||||
- themes/default/img/FreedomBox-logo-lineart-negative.png :: -
|
||||
- themes/default/img/FreedomBox-logo-lineart-negative.svg :: -
|
||||
- themes/default/img/FreedomBox-logo-lineart.png :: -
|
||||
- themes/default/img/FreedomBox-logo-lineart.svg :: -
|
||||
- themes/default/img/FreedomBox-logo-standard.png :: -
|
||||
- themes/default/img/FreedomBox-logo-standard.svg :: -
|
||||
- themes/default/img/freedombox-logotype.png :: -
|
||||
- themes/default/img/glyphicons-halflings.png :: -
|
||||
- themes/default/img/glyphicons-halflings-white.png :: -
|
||||
- themes/default/js/libs/jquery.min.js :: Symlink to external target: [[file:themes/default/js/libs/jquery.min.js::*%20Dual%20licensed%20under%20the%20MIT%20or%20GPL%20Version%202%20licenses.][MIT/GPL2]]
|
||||
- themes/default/js/libs/modernizr.min.js :: Symlink to external target: MIT
|
||||
- plinth/__main__.py :: [[file:plinth.py::__license__%20%3D%20"GPLv3%20or%20later"]["GPLv3 or later"]]
|
||||
- plinth/actions.py :: -
|
||||
- plinth/cfg.py :: -
|
||||
- plinth/logger.py :: -
|
||||
- plinth/menu.py :: -
|
||||
- plinth/modules/apps/apps.py :: -
|
||||
- plinth/modules/config/config.py :: -
|
||||
- plinth/modules/diagnostics/diagnostics.py :: -
|
||||
- plinth/modules/expert_mode/expert_mode.py :: -
|
||||
- plinth/modules/first_boot/first_boot.py :: -
|
||||
- plinth/modules/help/help.py :: -
|
||||
- plinth/modules/lib/auth.py :: -
|
||||
- plinth/modules/owncloud/owncloud.py :: -
|
||||
- plinth/modules/packages/packages.py :: -
|
||||
- plinth/modules/santiago/santiago.py :: -
|
||||
- plinth/modules/system/system.py :: -
|
||||
- plinth/modules/tor/tor.py :: -
|
||||
- plinth/modules/users/users.py :: -
|
||||
- plinth/modules/xmpp/xmpp.py :: -
|
||||
- plinth/templates/base.html :: [[file:templates/base.tmpl::the%20<a%20href%3D"http:/www.gnu.org/licenses/agpl.html"%20target%3D"_blank">GNU%20Affero%20General%20Public][GNU Affero General Public License, Version 3 or later]]
|
||||
- plinth/tests/actions_test.py :: -
|
||||
- static/themes/default/FreedomBox-Identity-Manual.pdf :: -
|
||||
- static/themes/default/FreedomBox-Logo.7z :: [[http://thread.gmane.org/gmane.linux.debian.freedombox.user/4124/focus=4439][GPL3+/CC-BY-SA]]
|
||||
- static/themes/default/readme.md :: [[file:themes/default/readme.md::This%20theme%20is%20free%20software%20offered%20to%20you%20under%20the%20terms%20of%20the%20GNU%20Affero%20General%20Public%20License,%20Version%203%20or%20later:][GNU Affero General Public License Version 3]]
|
||||
- static/themes/default/screenshot.png :: -
|
||||
- static/themes/default/img/apple-touch-icon-114px-precomposed.png :: -
|
||||
- static/themes/default/img/apple-touch-icon-57px-precomposed.png :: -
|
||||
- static/themes/default/img/apple-touch-icon-72px-precomposed.png :: -
|
||||
- static/themes/default/img/apple-touch-icon.xcf :: -
|
||||
- static/themes/default/img/favicon-32px.ico :: -
|
||||
- static/themes/default/img/favicon.ico :: -
|
||||
- static/themes/default/img/freedombox-logo-200px.png :: -
|
||||
- static/themes/default/img/freedombox-logo-250px.png :: -
|
||||
- static/themes/default/img/freedombox-logo-32px.png :: -
|
||||
- static/themes/default/img/FreedomBox-logo-grayscale-negative.png :: -
|
||||
- static/themes/default/img/FreedomBox-logo-grayscale-negative.svg :: -
|
||||
- static/themes/default/img/FreedomBox-logo-grayscale.png :: -
|
||||
- static/themes/default/img/FreedomBox-logo-grayscale.svg :: -
|
||||
- static/themes/default/img/FreedomBox-logo-lineart-negative.png :: -
|
||||
- static/themes/default/img/FreedomBox-logo-lineart-negative.svg :: -
|
||||
- static/themes/default/img/FreedomBox-logo-lineart.png :: -
|
||||
- static/themes/default/img/FreedomBox-logo-lineart.svg :: -
|
||||
- static/themes/default/img/FreedomBox-logo-standard.png :: -
|
||||
- static/themes/default/img/FreedomBox-logo-standard.svg :: -
|
||||
- static/themes/default/img/freedombox-logotype.png :: -
|
||||
- static/themes/default/img/glyphicons-halflings.png :: -
|
||||
- static/themes/default/img/glyphicons-halflings-white.png :: -
|
||||
- static/themes/default/js/libs/jquery.min.js :: Symlink to external target: [[file:themes/default/js/libs/jquery.min.js::*%20Dual%20licensed%20under%20the%20MIT%20or%20GPL%20Version%202%20licenses.][MIT/GPL2]]
|
||||
- static/themes/default/js/libs/modernizr.min.js :: Symlink to external target: MIT
|
||||
|
||||
93
Makefile
93
Makefile
@ -1,93 +0,0 @@
|
||||
MAKE=make
|
||||
|
||||
PWD=`pwd`
|
||||
|
||||
# hosting variables
|
||||
SLEEP_TIME=300
|
||||
EXCLUDE=--exclude=*.tar.gz --exclude=*~ $(EXCLUDE-FILES)
|
||||
ALL_BUT_GZ=$(subst $(wildcard *.tar.gz),,$(wildcard *))
|
||||
DATADIR=/usr/share/plinth
|
||||
PYDIR=$(DATADIR)/python/plinth
|
||||
|
||||
## Catch-all targets
|
||||
default: config dirs docs
|
||||
all: default
|
||||
|
||||
predepend:
|
||||
sudo sh -c "apt-get install pandoc psmisc python2.7 python-bcrypt python-cherrypy3 python-django python-passlib python-bootstrapform libjs-twitter-bootstrap sudo"
|
||||
git submodule init
|
||||
git submodule update
|
||||
touch predepend
|
||||
|
||||
install: default apache-install freedombox-setup-install
|
||||
mkdir -p $(DESTDIR)/etc/init.d $(DESTDIR)/etc/plinth
|
||||
cp plinth.sample.config $(DESTDIR)/etc/plinth/plinth.config
|
||||
mkdir -p $(DESTDIR)$(PYDIR) $(DESTDIR)$(DATADIR) $(DESTDIR)/usr/bin \
|
||||
$(DESTDIR)/usr/share/doc/plinth $(DESTDIR)/usr/share/man/man1
|
||||
cp -a static themes $(DESTDIR)$(DATADIR)/
|
||||
cp -a actions $(DESTDIR)$(DATADIR)/
|
||||
cp -a sudoers.d $(DESTDIR)/etc/sudoers.d
|
||||
cp -a *.py modules templates $(DESTDIR)$(PYDIR)/
|
||||
cp share/init.d/plinth $(DESTDIR)/etc/init.d
|
||||
cp -a lib/* $(DESTDIR)/usr/lib
|
||||
install plinth $(DESTDIR)/usr/bin/
|
||||
mkdir -p $(DESTDIR)/var/lib/plinth/sessions $(DESTDIR)/var/log/plinth $(DESTDIR)/var/run
|
||||
mkdir -p $(DESTDIR)/var/lib/plinth/data
|
||||
rm -f $(DESTDIR)/var/lib/plinth/users/sqlite3.distrib
|
||||
|
||||
freedombox-setup-install:
|
||||
install -m755 -D setup.d/86_plinth $(DESTDIR)/usr/lib/freedombox/setup.d/86_plinth
|
||||
|
||||
uninstall:
|
||||
rm -rf $(DESTDIR)/usr/lib/python2.7/plinth $(DESTDIR)/usr/share/plinth/ \
|
||||
$(DESTDIR)/etc/plinth $(DESTDIR)/var/lib/plinth $(DESTDIR)/usr/share/doc/plinth/ \
|
||||
$(DESTDIR)/var/log/plinth
|
||||
rm -f $(DESTDIR)/usr/bin/plinth $(DESTDIR)/etc/init.d/plinth \
|
||||
$(DESTDIR)/usr/share/man/man1/plinth.1.gz $(DESTDIR)/var/run/plinth.pid
|
||||
|
||||
dirs:
|
||||
@mkdir -p data/sessions
|
||||
|
||||
config: Makefile
|
||||
@test -f plinth.config || cp plinth.sample.config plinth.config
|
||||
|
||||
docs:
|
||||
@$(MAKE) -s -C doc
|
||||
doc: docs
|
||||
|
||||
html:
|
||||
@$(MAKE) -s -C doc html
|
||||
|
||||
clean:
|
||||
@rm -f cherrypy.config data/sessions/*
|
||||
@find . -name "*~" -exec rm {} \;
|
||||
@find . -name ".#*" -exec rm {} \;
|
||||
@find . -name "#*" -exec rm {} \;
|
||||
@find . -name "*.pyc" -exec rm {} \;
|
||||
@find . -name "*.bak" -exec rm {} \;
|
||||
@$(MAKE) -s -C doc clean
|
||||
rm -f plinth.config
|
||||
rm -f predepend
|
||||
|
||||
hosting:
|
||||
bash start.sh &
|
||||
while [ 1 ]; do make current-checkout.tar.gz current-repository.tar.gz; sleep $(SLEEP_TIME); done
|
||||
|
||||
current-checkout.tar.gz: $(ALL_BUT_GZ)
|
||||
tar cz $(EXCLUDE) * > current-checkout.tar.gz
|
||||
|
||||
current-repository.tar.gz: $(ALL_BUT_GZ)
|
||||
tar cz $(EXCLUDE) * .git > current-repository.tar.gz
|
||||
|
||||
apache-install:
|
||||
install -D -m644 share/apache2/plinth.conf $(DESTDIR)/etc/apache2/sites-available/plinth.conf
|
||||
install -D -m644 share/apache2/plinth-ssl.conf $(DESTDIR)/etc/apache2/sites-available/plinth-ssl.conf
|
||||
apache-config: apache-install apache-modules
|
||||
a2ensite plinth
|
||||
a2ensite plinth-ssl
|
||||
service apache2 reload
|
||||
|
||||
apache-modules:
|
||||
# enable all required modules, create snakeoil cert.
|
||||
./setup.d/86_plinth
|
||||
service apache2 restart
|
||||
36
NOTES
36
NOTES
@ -1,36 +0,0 @@
|
||||
% PLINTH
|
||||
%
|
||||
% February 2012
|
||||
|
||||
# Edits by bnewbold
|
||||
|
||||
## 2012-07-12 "exmachina" configuration management layer
|
||||
|
||||
- this new code is very ugly and in the "just make it work" style
|
||||
- add exmachina code and test code
|
||||
- modify plinth.py to listen for shared secret on stdin at start
|
||||
(if appropriate flag is set) and try to connect to exmachina daemon
|
||||
- use exmachina to read and set /etc/hostname as a demo
|
||||
- update plinth init.d script to start exmachina and share keys
|
||||
- update docs with new deps and run instructions
|
||||
|
||||
# Edits by seandiggity
|
||||
|
||||
## 2012-02-27 new theme based upon bootstrap
|
||||
|
||||
Added Bootstrap code from Twitter's Bootstrap http://twitter.github.com/bootstrap
|
||||
Additional images, css changes
|
||||
Consolidated Bootstrap, Boilerplate, HTML5-Reset code
|
||||
Edited text and forms for some modules (as a CMS, Plinth's fetching of text and forms from static files needs rethinking)
|
||||
Changed menu javascript to work with Bootstrap styles
|
||||
|
||||
## 2012-02-24 template and theme changes
|
||||
|
||||
Added HTML5-Reset code http://html5reset.org
|
||||
Removed robots.txt (we have "noindex,nofollow" in the template meta tags, do we need this?)
|
||||
Added meta noindex,nofollow,noarchive tags for specific robots (googlebot etc.)
|
||||
Removed extraneous meta tags useful only for indexing
|
||||
Removed HTML5-Reset "_" directory. Not sure why it's useful to add an ambiguous folder to the directory tree.
|
||||
Made sure no Google-y code wasn't included (analytics, remote copy of JQuery, etc.)
|
||||
Fixed symbolic link docs/style.css
|
||||
New favicon and iOS "web clip" button
|
||||
@ -1,6 +1,4 @@
|
||||
% PLINTH(1) Version 0.1 | Plinth User Manual
|
||||
%
|
||||
% February 2011
|
||||
% Plinth User Manual
|
||||
|
||||
# Introduction
|
||||
|
||||
@ -8,10 +6,6 @@
|
||||
|
||||
plinth - a web front end for administering every aspect of a Freedom Box.
|
||||
|
||||
## Synopsis
|
||||
|
||||
plinth.py
|
||||
|
||||
## Description
|
||||
|
||||
The Freedom Box is a net appliance conceived by Eben Moglen. It
|
||||
@ -45,10 +39,14 @@ servers. Basic users should never even know those options exist.
|
||||
|
||||
## Getting Started
|
||||
|
||||
See the INSTALL file for additional details. Run:
|
||||
See the INSTALL file for additional details and dependencies. To install run:
|
||||
|
||||
$ make
|
||||
$ sudo python setup.py install
|
||||
|
||||
Once make finishes, run Plinth on the local system with:
|
||||
Run Plinth on the local system with:
|
||||
|
||||
$ bash start.sh
|
||||
$ sudo plinth
|
||||
|
||||
## Contributing
|
||||
|
||||
See the HACKING file for contributing to Plinth.
|
||||
21
bin/plinth
Normal file
21
bin/plinth
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# This file is part of Plinth.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import plinth.__main__
|
||||
|
||||
plinth.__main__.main()
|
||||
23
data/etc/plinth/plinth.config
Normal file
23
data/etc/plinth/plinth.config
Normal file
@ -0,0 +1,23 @@
|
||||
[Name]
|
||||
product_name = Plinth
|
||||
box_name = FreedomBox
|
||||
|
||||
[Path]
|
||||
# directory locations
|
||||
file_root = /usr/share/plinth
|
||||
data_dir = /var/lib/plinth
|
||||
log_dir = /var/log/plinth
|
||||
pid_dir = /var/run
|
||||
server_dir = plinth/
|
||||
actions_dir = /usr/share/plinth/actions
|
||||
doc_dir = /usr/share/doc/plinth
|
||||
|
||||
# file locations
|
||||
store_file = %(data_dir)s/store.sqlite3
|
||||
status_log_file = %(log_dir)s/status.log
|
||||
access_log_file = %(log_dir)s/access.log
|
||||
pidfile = %(pid_dir)s/plinth.pid
|
||||
|
||||
[Network]
|
||||
host = 127.0.0.1
|
||||
port = 8000
|
||||
0
data/var/log/plinth/.gitkeep
Normal file
0
data/var/log/plinth/.gitkeep
Normal file
0
data/var/run/.gitkeep
Normal file
0
data/var/run/.gitkeep
Normal file
11
doc/Makefile
11
doc/Makefile
@ -8,7 +8,8 @@ PDFLATEX=pdflatex
|
||||
# complete manual:
|
||||
SOURCES=README.mdwn INSTALL.mdwn themes.mdwn hacking.mdwn TODO.mdwn modules.mdwn scripts.mdwn security.mdwn faq.mdwn COPYING.mdwn colophon.mdwn
|
||||
OTHER=
|
||||
TODO_SOURCES=$(patsubst TODO.mdwn,,$(SOURCES))
|
||||
PYTHON_SOURCES:=$(shell find .. -name \*.py)
|
||||
TODO_SOURCES=$(patsubst TODO.mdwn,,$(SOURCES)) $(PYTHON_SOURCES)
|
||||
MAN_SOURCES=$(patsubst COPYING.mdwn,copyright_notice00,$(SOURCES))
|
||||
|
||||
NEWLINE_SOURCES=$(patsubst %,% oneline.txt,$(SOURCES))
|
||||
@ -39,9 +40,13 @@ oneline.txt: Makefile
|
||||
|
||||
$(SOURCES):
|
||||
@rm -f $@
|
||||
@ln -s ../$(patsubst %.mdwn,%,$@) $@
|
||||
if [ -f ../$(patsubst %.mdwn,%.md,$@) ]; then \
|
||||
ln -s ../$(patsubst %.mdwn,%.md,$@) $@; \
|
||||
else \
|
||||
ln -s ../$(patsubst %.mdwn,%,$@) $@; \
|
||||
fi
|
||||
|
||||
../TODO : $(TODO_SOURCES) ../*.py ../modules/*.py ../Makefile Makefile
|
||||
../TODO : $(TODO_SOURCES) Makefile
|
||||
grep -ro --exclude=.git* --exclude=plinth.1 --exclude=*.tex --exclude=*.html \
|
||||
--exclude=README.mdwn --exclude=INSTALL.mdwn \
|
||||
--exclude=TODO.mdwn --exclude=COPYING.mdwn \
|
||||
|
||||
102
doc/hacking.mdwn
102
doc/hacking.mdwn
@ -1,102 +0,0 @@
|
||||
# Hacking
|
||||
|
||||
This codebase could really use a testing framework.
|
||||
|
||||
If you are interested in helping out, writing tests is a great place
|
||||
to start-- you don't need to know much about the code or python to
|
||||
write useful tests.
|
||||
|
||||
In addition to a testing framework, the code is in need of some
|
||||
general cleanup. I've been inconsistent in capitalization conventions
|
||||
as well as in my use of underscores.
|
||||
|
||||
The plugin interface could use some attention as well. Right now,
|
||||
it's a a bit of a free-for-all until I see how the plugins actually
|
||||
code up. Channeling all that into a few plugin interface grooves
|
||||
would be a help.
|
||||
|
||||
If you're feeling more ambitious than that, the best way to improve
|
||||
Plinth is to add modules. More functionality, especially in the
|
||||
router section, could convert the Freedom Box from a good idea to a
|
||||
must-have appliance.
|
||||
|
||||
Beyond that, we need to train some expert eyes on the interaction
|
||||
between Freedom Boxes. Transparent, zero-config box-to-box backup is
|
||||
possible. We just need to build an auth and dns layer. There are
|
||||
lots of theories on how to do this well. The first theory reduced to
|
||||
practice wins!
|
||||
|
||||
There is a list of TODO items below. Some of them are discrete pieces
|
||||
that can be tackled without diving too deep into the code.
|
||||
|
||||
## Repository
|
||||
|
||||
Plinth is available from github at
|
||||
`git://github.com/jvasile/plinth.git`. The [project page on
|
||||
github](https://github.com/jvasile/plinth) is at
|
||||
`https://github.com/jvasile/plinth`.
|
||||
|
||||
## Bugs
|
||||
|
||||
There are lots of bugs. We don't have a spec or tests, so a bug is
|
||||
really just any unexpected behavior. I am not easily surprised, but
|
||||
there are still lots of bugs.
|
||||
|
||||
There's an [issue tracker](https://github.com/jvasile/Plinth/issues).
|
||||
Please add things and consult it for things to tackle.
|
||||
|
||||
<a name="hacking_code_practices" />
|
||||
|
||||
## Coding Practices
|
||||
|
||||
I try to stick to [PEP 8](http://www.python.org/dev/peps/pep-0008/)
|
||||
recommendations. That's not to say I don't deviate, just that
|
||||
deviations are usually bugs that should be fixed.
|
||||
|
||||
### Internationalization
|
||||
|
||||
Every module should `from gettext import gettext as _` and wrap
|
||||
displayed strings with _(). We don't have the language stuff in place
|
||||
yet (we have no translation files), but we need to put the
|
||||
infrastructure in place for it from the start. Use it like this:
|
||||
|
||||
cfg.log.error(_("Couldn't import %s: %s") % (path, e))
|
||||
|
||||
### Variables and Data Stores
|
||||
|
||||
Plinth needs to keep information for short and long term
|
||||
future use, and it can't just store all of that on the stack.
|
||||
|
||||
Global config information can be put in the `cfg` module namespace.
|
||||
Keep it thread and session safe, though, or you'll get undefined
|
||||
behavior as soon as multiple simultaneous users enter the picture.
|
||||
|
||||
Cherrpy has support for session variables. Use those for short term
|
||||
user-specific data.
|
||||
|
||||
For long term storage, the Plinth needs a back end
|
||||
storage solution. Databases are a bit opaque and can be hard for
|
||||
third party software or shell users to manipulate. For now, I've
|
||||
decided that persistent data should be placed in dicts and stored in
|
||||
json format. We'll need a file locking solution too.
|
||||
|
||||
The `user_store.py` module implements the `UserStoreModule` interface
|
||||
specified in `plugin_mount.py`. Any new system that respects that
|
||||
interface can be used. The existing `user_store.py` holds entire user
|
||||
files in memory and caches user files as it goes. This has two
|
||||
downsides: first, if you have lots of users and store big things in
|
||||
the user dict, you'll run out of memory. Second, it's not thread
|
||||
safe. Maybe a database is a good idea after all.
|
||||
|
||||
We do not yet have a means of storing module data for long terms. My
|
||||
current thinking is that modules can store data in their own
|
||||
directories. That makes removal easy.
|
||||
|
||||
## Todo
|
||||
|
||||
Plinth has a number of open todo items. And there are items in the
|
||||
[issue tracker](https://github.com/jvasile/Plinth/issues) that need
|
||||
tackling. Please help!
|
||||
|
||||
* Implement the functions in the submenus of router.py
|
||||
* Unify our logging and cherrypy's.
|
||||
1
doc/hacking.mdwn
Symbolic link
1
doc/hacking.mdwn
Symbolic link
@ -0,0 +1 @@
|
||||
../HACKING
|
||||
235
fabfile.py
vendored
235
fabfile.py
vendored
@ -1,235 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This is the fabric file I've been using to deploy things on my box
|
||||
# and my freedombox.
|
||||
#
|
||||
# fab install should take you from base freedom-maker install to
|
||||
# plinth box
|
||||
|
||||
import os,sys, subprocess
|
||||
import json
|
||||
import fabric.api
|
||||
from fabric.api import local, env, cd, put, get, task
|
||||
|
||||
import cfg
|
||||
|
||||
fb_ip = "10.5.53.155"
|
||||
|
||||
BINDIR = "/usr/local/bin"
|
||||
|
||||
# defaults
|
||||
env.user = 'root'
|
||||
|
||||
@task
|
||||
def fb():
|
||||
"Use this to set host to our freedombox (e.g.: fab fb deploy)"
|
||||
env.hosts = [fb_ip]
|
||||
|
||||
@task
|
||||
def all_hosts():
|
||||
"Use this to set host to both localhost and freedombox"
|
||||
env.hosts = ["localhost", "192.168.2.115"]
|
||||
|
||||
def remote_dir():
|
||||
if env.host == fb_ip:
|
||||
return "/usr/local/share/plinth"
|
||||
else:
|
||||
return "/home/james/src/plinth"
|
||||
|
||||
def run(*args, **kwargs):
|
||||
if env.host == "localhost" or env.host=="127.0.0.1":
|
||||
return local(*args, **kwargs)
|
||||
else:
|
||||
return fabric.api.run(*args, **kwargs)
|
||||
|
||||
def sudo(*args, **kwargs):
|
||||
if env.host == "localhost" or env.host=="127.0.0.1":
|
||||
return run("sudo %s" % args[0], *args[1:], **kwargs)
|
||||
elif env.user == "root":
|
||||
return run(*args, **kwargs)
|
||||
else:
|
||||
return fabric.api.sudo(*args, **kwargs)
|
||||
|
||||
@task
|
||||
def get_remote_data_dir():
|
||||
with cd(remote_dir()):
|
||||
data_dir = run('python -c "import cfg; print cfg.data_dir"')
|
||||
env.remote_data_dir = os.path.join(remote_dir(), data_dir)
|
||||
sudo('mkdir -p %s' % env.remote_data_dir)
|
||||
return env.remote_data_dir
|
||||
|
||||
@task
|
||||
def move_data():
|
||||
"Move install's data dir to where cfg specifies it should be"
|
||||
get_remote_data_dir()
|
||||
with cd(remote_dir()):
|
||||
sudo('mv data %s' % os.path.split(env.remote_data_dir)[0])
|
||||
|
||||
@task
|
||||
def make():
|
||||
"Run the makefile, which generates docs and templates"
|
||||
with cd(remote_dir()):
|
||||
sudo('make')
|
||||
|
||||
def make_link_unless_exists(src, dest):
|
||||
sudo('test -f %s || ln -s %s %s' % (dest, src, dest))
|
||||
|
||||
def link(src, dest):
|
||||
sudo('ln -fs %s %s' % (src, dest))
|
||||
|
||||
@task
|
||||
def santiago():
|
||||
"Setup the Santiago port"
|
||||
santiago_port = 52854
|
||||
sudo('ifconfig lo up') # or else tor start fails
|
||||
sudo('apt-get install -y --no-install-recommends tor curl ntp')
|
||||
|
||||
# tor needs accurate clock
|
||||
sudo('date -s "%s"' % subprocess.check_output("date").rstrip())
|
||||
|
||||
# create tor hidden service dir
|
||||
santiago_dir = os.path.join(get_remote_data_dir(), "santiago", "tor")
|
||||
tor_dir = os.path.join(santiago_dir, "general")
|
||||
sudo("mkdir -p " + tor_dir)
|
||||
sudo("chown debian-tor:debian-tor " + tor_dir)
|
||||
|
||||
# ensure hidden service config is in torrc
|
||||
local("rm -rf __fab__torrc")
|
||||
get("/etc/tor/torrc", "__fab__torrc")
|
||||
with open ("__fab__torrc", 'r') as INF:
|
||||
rc = INF.read()
|
||||
local("rm -rf __fab__torrc")
|
||||
hidden_service_config = "HiddenServiceDir %s\nHiddenServicePort 80 127.0.0.1:%d" % (tor_dir, santiago_port)
|
||||
if not hidden_service_config in rc:
|
||||
sudo("echo '%s' >> /etc/tor/torrc" % hidden_service_config)
|
||||
|
||||
sudo('service tor restart')
|
||||
|
||||
def backslash_path(f):
|
||||
if not f.startswith('/'):
|
||||
f = os.path.abs(f)
|
||||
if f == '/':
|
||||
return ''
|
||||
path, ret = os.path.split(f)
|
||||
return backslash_path(path) + '\/' + ret
|
||||
|
||||
@task
|
||||
def apache():
|
||||
"configure apache to find reverse proxy for plinth"
|
||||
sudo('apt-get install --no-install-recommends -y apache2 libapache2-mod-proxy-html apache2-utils openssl ssl-cert')
|
||||
sudo('a2enmod proxy_http rewrite ssl')
|
||||
sudo('touch /var/log/apache2/rewrite.log')
|
||||
|
||||
## ssl key and cert
|
||||
ssl_target = "/etc/apache2/ssl/apache.pem"
|
||||
sudo('mkdir -p %s' % os.path.split(ssl_target)[0])
|
||||
sudo('test -f %s || echo "US\nNY\nNYC\nFBox\n\n\n" | openssl req -new -x509 -days 999 -nodes -out %s -keyout %s' % (ssl_target, ssl_target, ssl_target))
|
||||
|
||||
conf_path = os.path.join(remote_dir(), "share/apache2/plinth.conf")
|
||||
sudo("mkdir -p " + os.path.split(conf_path)[0])
|
||||
sudo("touch "+ conf_path)
|
||||
sudo(r"sed -i 's/\(\s*\)DocumentRoot.*/\1DocumentRoot %s/g' %s" % (
|
||||
backslash_path(os.path.join(remote_dir(), "static")),
|
||||
conf_path))
|
||||
link(conf_path, "/etc/apache2/sites-enabled/plinth.conf")
|
||||
|
||||
sslconf_path = os.path.join(remote_dir(), "share/apache2/plinth-ssl.conf")
|
||||
sudo("mkdir -p " + os.path.split(sslconf_path)[0])
|
||||
sudo("touch "+ sslconf_path)
|
||||
sudo(r"sed -i 's/\(\s*\)DocumentRoot.*/\1DocumentRoot %s/g' %s" % (
|
||||
backslash_path(os.path.join(remote_dir(), "static")),
|
||||
sslconf_path))
|
||||
link(sslconf_path, "/etc/apache2/sites-enabled/plinth-ssl.conf")
|
||||
|
||||
sudo('rm -f /etc/apache2/sites-enabled/000-default')
|
||||
sudo('service apache2 restart')
|
||||
|
||||
@task
|
||||
def deps():
|
||||
"Basic plinth dependencies"
|
||||
sudo('apt-get install --no-install-recommends -y python make pandoc python-pyme python-django python-bootstrapform libjs-twitter-bootstrap')
|
||||
|
||||
@task
|
||||
def update():
|
||||
"Copy modified git-tracked files from this branch to remote"
|
||||
|
||||
with cd(remote_dir()):
|
||||
|
||||
## Get .fab contents
|
||||
sudo("touch .fab")
|
||||
fab = run("cat .fab")
|
||||
if not fab:
|
||||
fab = {}
|
||||
|
||||
## Make list of files to put
|
||||
try:
|
||||
fab = json.loads(fab)
|
||||
except:
|
||||
fab={}
|
||||
branch = [a[2:] for a in local("git branch", capture=True).split("\n") if a.startswith('*')][0]
|
||||
files = local("git ls-tree -r --name-only %s" % branch, capture=True).split("\n")
|
||||
else:
|
||||
files = local("git diff --stat " + fab['last_update_from_commit'], capture=True).split("\n")[:-1]
|
||||
files = [f.lstrip().split("|")[0].rstrip() for f in files]
|
||||
|
||||
## Put the files, one by one, respecting directories
|
||||
dirs = {}
|
||||
for pathspec in files:
|
||||
d,fname = os.path.split(pathspec)
|
||||
if not d in dirs.keys():
|
||||
dirs[d]=[]
|
||||
dirs[d].append(pathspec)
|
||||
if dirs:
|
||||
sudo('mkdir -p %s' % ' '.join([os.path.join(remote_dir(), d) for d in dirs.keys()]))
|
||||
for d in dirs:
|
||||
for f in dirs[d]:
|
||||
if os.path.islink(f):
|
||||
linked = local("ls -l %s" % f, capture=True).split("-> ")[1]
|
||||
#link(os.path.join(remote_dir(), linked), os.path.join(remote_dir(), d, os.path.basename(f)))
|
||||
put(f, os.path.join(remote_dir(), d),mirror_local_mode=True)
|
||||
if f.endswith(".py"):
|
||||
run("rm -f " + os.path.join(remote_dir(), d, os.path.basename)+"c")
|
||||
|
||||
## restart
|
||||
make()
|
||||
sudo('/etc/init.d/plinth restart')
|
||||
|
||||
## Record activity so we only put changed files next time
|
||||
commit = local("git log -n 1", capture=True).split("\n")[0].split(" ")[1]
|
||||
fab['last_update_from_commit'] = commit
|
||||
with open(".fab", 'w') as OUTF:
|
||||
OUTF.write(json.dumps(fab))
|
||||
put(".fab", os.path.join(remote_dir(),".fab"))
|
||||
local("rm -f .fab")
|
||||
|
||||
@task
|
||||
def link_bin():
|
||||
"Link executable and init.d script"
|
||||
# todo: set daemon to point to currect binary
|
||||
sudo('rm -rf ' + os.path.join(BINDIR, 'plinth.py'))
|
||||
link(os.path.join(remote_dir(), "plinth.py"), os.path.join(BINDIR, 'plinth.py'))
|
||||
sudo('rm -rf /etc/init.d/plinth')
|
||||
link(os.path.join(remote_dir(), "share/init.d/plinth"), "/etc/init.d/plinth")
|
||||
|
||||
@task
|
||||
def restart():
|
||||
"Run plinth"
|
||||
run('/etc/init.d/plinth restart')
|
||||
@task
|
||||
def stop():
|
||||
"Stop plinth"
|
||||
run('/etc/init.d/plinth stop')
|
||||
|
||||
@task
|
||||
def proxy():
|
||||
put("proxy_up.py", remote_dir())
|
||||
|
||||
@task
|
||||
def deploy():
|
||||
"Deploy plinth"
|
||||
deps()
|
||||
link_bin()
|
||||
santiago()
|
||||
update()
|
||||
apache()
|
||||
|
||||
@ -1 +0,0 @@
|
||||
../apps/
|
||||
@ -1 +0,0 @@
|
||||
../config/
|
||||
@ -1 +0,0 @@
|
||||
../diagnostics/
|
||||
@ -1 +0,0 @@
|
||||
../expert_mode/
|
||||
@ -1 +0,0 @@
|
||||
../firewall/
|
||||
@ -1 +0,0 @@
|
||||
../first_boot/
|
||||
@ -1 +0,0 @@
|
||||
../help/
|
||||
@ -1 +0,0 @@
|
||||
../lib/
|
||||
@ -1 +0,0 @@
|
||||
../owncloud/
|
||||
@ -1 +0,0 @@
|
||||
../packages/
|
||||
@ -1 +0,0 @@
|
||||
../pagekite/
|
||||
@ -1 +0,0 @@
|
||||
../system/
|
||||
@ -1 +0,0 @@
|
||||
../tor/
|
||||
@ -1 +0,0 @@
|
||||
../users/
|
||||
@ -1 +0,0 @@
|
||||
../xmpp/
|
||||
4
plinth
4
plinth
@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
export PYTHONPATH=/usr/share/plinth/python
|
||||
exec python /usr/share/plinth/python/plinth/plinth.py "$@"
|
||||
@ -5,19 +5,18 @@ box_name = FreedomBox
|
||||
[Path]
|
||||
# directory locations
|
||||
file_root = %(root)s
|
||||
data_dir = %(file_root)s/data
|
||||
log_dir = %(data_dir)s
|
||||
pid_dir = %(data_dir)s
|
||||
python_root = %(file_root)s
|
||||
server_dir = plinth/
|
||||
data_dir = %(file_root)s/data/var/lib/plinth
|
||||
log_dir = %(file_root)s/data/var/log/plinth
|
||||
pid_dir = %(file_root)s/data/var/run
|
||||
server_dir = /
|
||||
actions_dir = %(file_root)s/actions
|
||||
doc_dir = %(file_root)s/doc
|
||||
|
||||
# file locations
|
||||
store_file = %(data_dir)s/store.sqlite3
|
||||
user_db = %(data_dir)s/users.sqlite3
|
||||
status_log_file = %(log_dir)s/status.log
|
||||
access_log_file = %(log_dir)s/access.log
|
||||
pidfile = %(pid_dir)s/pidfile.pid
|
||||
pidfile = %(pid_dir)s/plinth.pid
|
||||
|
||||
[Network]
|
||||
host = 127.0.0.1
|
||||
22
plinth/__init__.py
Normal file
22
plinth/__init__.py
Normal file
@ -0,0 +1,22 @@
|
||||
#
|
||||
# This file is part of Plinth.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth package init file
|
||||
"""
|
||||
|
||||
__version__ = '0.3.2'
|
||||
29
plinth.py → plinth/__main__.py
Executable file → Normal file
29
plinth.py → plinth/__main__.py
Executable file → Normal file
@ -7,17 +7,15 @@ import django.core.wsgi
|
||||
import logging
|
||||
import os
|
||||
import stat
|
||||
import sys
|
||||
|
||||
import cherrypy
|
||||
from cherrypy import _cpserver
|
||||
from cherrypy.process.plugins import Daemonizer
|
||||
|
||||
import cfg
|
||||
import module_loader
|
||||
import service
|
||||
from plinth import cfg
|
||||
from plinth import module_loader
|
||||
from plinth import service
|
||||
|
||||
__version__ = "0.2.14"
|
||||
__author__ = "James Vasile"
|
||||
__copyright__ = "Copyright 2011-2013, James Vasile"
|
||||
__license__ = "GPLv3 or later"
|
||||
@ -64,13 +62,6 @@ def setup_logging():
|
||||
cherrypy.log.screen = False
|
||||
|
||||
|
||||
def setup_paths():
|
||||
"""Setup current directory and python import paths"""
|
||||
os.chdir(cfg.python_root)
|
||||
if not os.path.join(cfg.file_root, 'vendor') in sys.path:
|
||||
sys.path.append(os.path.join(cfg.file_root, 'vendor'))
|
||||
|
||||
|
||||
def setup_server():
|
||||
"""Setup CherryPy server"""
|
||||
LOGGER.info('Setting up CherryPy server')
|
||||
@ -99,7 +90,7 @@ def setup_server():
|
||||
cherrypy.tree.graft(application, cfg.server_dir)
|
||||
|
||||
config = {
|
||||
'/': {'tools.staticdir.root': '%s/static' % cfg.file_root,
|
||||
'/': {'tools.staticdir.root': os.path.join(cfg.file_root, 'static'),
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': '.'}}
|
||||
cherrypy.tree.mount(None, django.conf.settings.STATIC_URL, config)
|
||||
@ -141,7 +132,7 @@ def configure_django():
|
||||
'django.core.context_processors.static',
|
||||
'django.core.context_processors.tz',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'context_processors.common']
|
||||
'plinth.context_processors.common']
|
||||
|
||||
logging_configuration = {
|
||||
'version': 1,
|
||||
@ -196,12 +187,12 @@ def configure_django():
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'modules.first_boot.middleware.FirstBootMiddleware',
|
||||
'plinth.modules.first_boot.middleware.FirstBootMiddleware',
|
||||
),
|
||||
ROOT_URLCONF='urls',
|
||||
ROOT_URLCONF='plinth.urls',
|
||||
SESSION_ENGINE='django.contrib.sessions.backends.file',
|
||||
SESSION_FILE_PATH=sessions_directory,
|
||||
STATIC_URL=cfg.server_dir + '/static/',
|
||||
STATIC_URL='/'.join([cfg.server_dir, 'static/']).replace('//', '/'),
|
||||
TEMPLATE_CONTEXT_PROCESSORS=context_processors,
|
||||
TEMPLATE_DIRS=template_directories)
|
||||
|
||||
@ -224,10 +215,10 @@ def main():
|
||||
|
||||
service.init()
|
||||
|
||||
setup_paths()
|
||||
|
||||
configure_django()
|
||||
|
||||
LOGGER.info('Configuration loaded from file - %s', cfg.CONFIG_FILE)
|
||||
|
||||
module_loader.load_modules()
|
||||
|
||||
setup_server()
|
||||
@ -1,4 +1,4 @@
|
||||
from menu import Menu
|
||||
from plinth.menu import Menu
|
||||
import os
|
||||
|
||||
import ConfigParser
|
||||
@ -8,11 +8,10 @@ product_name = None
|
||||
box_name = None
|
||||
root = None
|
||||
file_root = None
|
||||
python_root = None
|
||||
data_dir = None
|
||||
store_file = None
|
||||
user_db = None
|
||||
actions_dir = None
|
||||
doc_dir = None
|
||||
status_log_file = None
|
||||
access_log_file = None
|
||||
pidfile = None
|
||||
@ -24,25 +23,36 @@ server_dir = '/'
|
||||
|
||||
main_menu = Menu()
|
||||
|
||||
CONFIG_FILE = None
|
||||
DEFAULT_CONFIG_FILE = '/etc/plinth/plinth.config'
|
||||
DEFAULT_ROOT = '/'
|
||||
|
||||
|
||||
def read():
|
||||
"""Read configuration"""
|
||||
directory = os.path.dirname(os.path.realpath(__file__))
|
||||
global CONFIG_FILE # pylint: disable-msg=W0603
|
||||
if os.path.isfile(DEFAULT_CONFIG_FILE):
|
||||
CONFIG_FILE = DEFAULT_CONFIG_FILE
|
||||
directory = DEFAULT_ROOT
|
||||
else:
|
||||
directory = os.path.dirname(os.path.realpath(__file__))
|
||||
directory = os.path.join(directory, '..')
|
||||
CONFIG_FILE = os.path.join(directory, 'plinth.config')
|
||||
|
||||
parser = SafeConfigParser(
|
||||
defaults={
|
||||
'root': directory,
|
||||
'root': os.path.realpath(directory),
|
||||
})
|
||||
parser.read(os.path.join(directory, 'plinth.config'))
|
||||
parser.read(CONFIG_FILE)
|
||||
|
||||
config_items = {('Name', 'product_name'),
|
||||
('Name', 'box_name'),
|
||||
('Path', 'root'),
|
||||
('Path', 'file_root'),
|
||||
('Path', 'python_root'),
|
||||
('Path', 'data_dir'),
|
||||
('Path', 'store_file'),
|
||||
('Path', 'user_db'),
|
||||
('Path', 'actions_dir'),
|
||||
('Path', 'doc_dir'),
|
||||
('Path', 'status_log_file'),
|
||||
('Path', 'access_log_file'),
|
||||
('Path', 'pidfile'),
|
||||
@ -64,7 +74,3 @@ def read():
|
||||
global store_file # pylint: disable-msg=W0603
|
||||
if store_file.endswith(".sqlite3"):
|
||||
store_file = os.path.splitext(store_file)[0]
|
||||
|
||||
global user_db # pylint: disable-msg=W0603
|
||||
if user_db.endswith(".sqlite3"):
|
||||
user_db = os.path.splitext(user_db)[0]
|
||||
@ -24,8 +24,8 @@ import importlib
|
||||
import logging
|
||||
import os
|
||||
|
||||
import urls
|
||||
import cfg
|
||||
from plinth import cfg
|
||||
from plinth import urls
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -39,8 +39,9 @@ def load_modules():
|
||||
"""
|
||||
module_names = []
|
||||
modules = {}
|
||||
for name in os.listdir('modules/enabled'):
|
||||
full_name = 'modules.{module}'.format(module=name)
|
||||
directory = os.path.dirname(os.path.abspath(__file__))
|
||||
for name in os.listdir(os.path.join(directory, 'modules', 'enabled')):
|
||||
full_name = 'plinth.modules.{module}'.format(module=name)
|
||||
|
||||
LOGGER.info('Importing %s', full_name)
|
||||
try:
|
||||
@ -139,7 +140,7 @@ def get_template_directories():
|
||||
core_directory = os.path.join(directory, 'templates')
|
||||
|
||||
directories = set((core_directory,))
|
||||
for name in os.listdir('modules/enabled'):
|
||||
for name in os.listdir(os.path.join(directory, 'modules', 'enabled')):
|
||||
directories.add(os.path.join(directory, 'modules', name, 'templates'))
|
||||
|
||||
return directories
|
||||
0
plinth/modules/__init__.py
Normal file
0
plinth/modules/__init__.py
Normal file
@ -1,7 +1,7 @@
|
||||
from django.template.response import TemplateResponse
|
||||
from gettext import gettext as _
|
||||
|
||||
import cfg
|
||||
from plinth import cfg
|
||||
|
||||
|
||||
def init():
|
||||
@ -23,6 +23,6 @@ from django.conf.urls import patterns, url
|
||||
|
||||
|
||||
urlpatterns = patterns( # pylint: disable-msg=C0103
|
||||
'modules.apps.apps',
|
||||
'plinth.modules.apps.apps',
|
||||
url(r'^apps/$', 'index', name='index')
|
||||
)
|
||||
@ -29,9 +29,8 @@ import logging
|
||||
import re
|
||||
import socket
|
||||
|
||||
import actions
|
||||
import cfg
|
||||
import util
|
||||
from plinth import actions
|
||||
from plinth import cfg
|
||||
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
@ -127,7 +126,7 @@ def index(request):
|
||||
def get_status():
|
||||
"""Return the current status"""
|
||||
return {'hostname': get_hostname(),
|
||||
'time_zone': util.slurp('/etc/timezone').rstrip()}
|
||||
'time_zone': open('/etc/timezone').read().rstrip()}
|
||||
|
||||
|
||||
def _apply_changes(request, old_status, new_status):
|
||||
@ -23,6 +23,6 @@ from django.conf.urls import patterns, url
|
||||
|
||||
|
||||
urlpatterns = patterns( # pylint: disable-msg=C0103
|
||||
'modules.config.config',
|
||||
'plinth.modules.config.config',
|
||||
url(r'^sys/config/$', 'index', name='index'),
|
||||
)
|
||||
@ -23,9 +23,9 @@ from django.contrib.auth.decorators import login_required
|
||||
from django.template.response import TemplateResponse
|
||||
from gettext import gettext as _
|
||||
|
||||
import actions
|
||||
import cfg
|
||||
from errors import ActionError
|
||||
from plinth import actions
|
||||
from plinth import cfg
|
||||
from plinth.errors import ActionError
|
||||
|
||||
|
||||
def init():
|
||||
@ -23,7 +23,7 @@ from django.conf.urls import patterns, url
|
||||
|
||||
|
||||
urlpatterns = patterns( # pylint: disable-msg=C0103
|
||||
'modules.diagnostics.diagnostics',
|
||||
'plinth.modules.diagnostics.diagnostics',
|
||||
url(r'^sys/diagnostics/$', 'index', name='index'),
|
||||
url(r'^sys/diagnostics/test/$', 'test', name='test'),
|
||||
)
|
||||
0
plinth/modules/enabled/apps
Normal file
0
plinth/modules/enabled/apps
Normal file
0
plinth/modules/enabled/config
Normal file
0
plinth/modules/enabled/config
Normal file
0
plinth/modules/enabled/diagnostics
Normal file
0
plinth/modules/enabled/diagnostics
Normal file
0
plinth/modules/enabled/expert_mode
Normal file
0
plinth/modules/enabled/expert_mode
Normal file
0
plinth/modules/enabled/firewall
Normal file
0
plinth/modules/enabled/firewall
Normal file
0
plinth/modules/enabled/first_boot
Normal file
0
plinth/modules/enabled/first_boot
Normal file
0
plinth/modules/enabled/help
Normal file
0
plinth/modules/enabled/help
Normal file
0
plinth/modules/enabled/lib
Normal file
0
plinth/modules/enabled/lib
Normal file
0
plinth/modules/enabled/owncloud
Normal file
0
plinth/modules/enabled/owncloud
Normal file
0
plinth/modules/enabled/packages
Normal file
0
plinth/modules/enabled/packages
Normal file
0
plinth/modules/enabled/pagekite
Normal file
0
plinth/modules/enabled/pagekite
Normal file
0
plinth/modules/enabled/system
Normal file
0
plinth/modules/enabled/system
Normal file
0
plinth/modules/enabled/tor
Normal file
0
plinth/modules/enabled/tor
Normal file
0
plinth/modules/enabled/users
Normal file
0
plinth/modules/enabled/users
Normal file
0
plinth/modules/enabled/xmpp
Normal file
0
plinth/modules/enabled/xmpp
Normal file
@ -4,8 +4,8 @@ from django.contrib.auth.decorators import login_required
|
||||
from django.template.response import TemplateResponse
|
||||
from gettext import gettext as _
|
||||
|
||||
import cfg
|
||||
from ..lib.auth import get_group
|
||||
from plinth import cfg
|
||||
from plinth.modules.lib.auth import get_group
|
||||
|
||||
|
||||
class ExpertsForm(forms.Form): # pylint: disable-msg=W0232
|
||||
@ -23,6 +23,6 @@ from django.conf.urls import patterns, url
|
||||
|
||||
|
||||
urlpatterns = patterns( # pylint: disable-msg=C0103
|
||||
'modules.expert_mode.expert_mode',
|
||||
'plinth.modules.expert_mode.expert_mode',
|
||||
url(r'^sys/expert/$', 'index', name='index'),
|
||||
)
|
||||
@ -24,9 +24,9 @@ from django.template.response import TemplateResponse
|
||||
from gettext import gettext as _
|
||||
import logging
|
||||
|
||||
import actions
|
||||
import cfg
|
||||
import service as service_module
|
||||
from plinth import actions
|
||||
from plinth import cfg
|
||||
import plinth.service as service_module
|
||||
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
@ -23,6 +23,6 @@ from django.conf.urls import patterns, url
|
||||
|
||||
|
||||
urlpatterns = patterns( # pylint: disable-msg=C0103
|
||||
'modules.firewall.firewall',
|
||||
'plinth.modules.firewall.firewall',
|
||||
url(r'^sys/firewall/$', 'index', name='index')
|
||||
)
|
||||
@ -26,10 +26,10 @@ from django.http.response import HttpResponseRedirect
|
||||
from django.template.response import TemplateResponse
|
||||
from gettext import gettext as _
|
||||
|
||||
from ..lib.auth import add_user
|
||||
from ..config import config
|
||||
from plinth import cfg
|
||||
from plinth.modules.config import config
|
||||
from plinth.modules.lib.auth import add_user
|
||||
from withsqlite.withsqlite import sqlite_db
|
||||
import cfg
|
||||
|
||||
|
||||
## TODO: flesh out these tests values
|
||||
@ -24,7 +24,7 @@ from django.core.urlresolvers import reverse
|
||||
from django.http.response import HttpResponseRedirect
|
||||
import logging
|
||||
|
||||
import cfg
|
||||
from plinth import cfg
|
||||
from withsqlite.withsqlite import sqlite_db
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ from django.conf.urls import patterns, url
|
||||
|
||||
|
||||
urlpatterns = patterns( # pylint: disable-msg=C0103
|
||||
'modules.first_boot.first_boot',
|
||||
'plinth.modules.first_boot.first_boot',
|
||||
url(r'^firstboot/$', 'index', name='index'),
|
||||
url(r'^firstboot/state0/$', 'state0', name='state0'),
|
||||
url(r'^firstboot/state1/$', 'state1', name='state1')
|
||||
@ -3,7 +3,7 @@ from gettext import gettext as _
|
||||
from django.http import Http404
|
||||
from django.template.response import TemplateResponse
|
||||
|
||||
import cfg
|
||||
from plinth import cfg
|
||||
|
||||
|
||||
def init():
|
||||
@ -36,7 +36,7 @@ def about(request):
|
||||
def helppage(request, page):
|
||||
"""Serve a help page from the 'doc' directory"""
|
||||
try:
|
||||
with open(os.path.join('doc', '%s.part.html' % page), 'r') \
|
||||
with open(os.path.join(cfg.doc_dir, '%s.part.html' % page), 'r') \
|
||||
as input_file:
|
||||
main = input_file.read()
|
||||
except IOError:
|
||||
@ -23,7 +23,7 @@ from django.conf.urls import patterns, url
|
||||
|
||||
|
||||
urlpatterns = patterns( # pylint: disable-msg=C0103
|
||||
'modules.help.help',
|
||||
'plinth.modules.help.help',
|
||||
# having two urls for one page is a hack to help the current url/menu
|
||||
# system highlight the correct menu item. Every submenu-item with the same
|
||||
# url prefix as the main-menu is highlighted automatically.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user