Skip to content

Commit

Permalink
Merge pull request #65 from DocCyblade/development
Browse files Browse the repository at this point in the history
Turnkey Mayan-EDMS v14.2 - Ready
  • Loading branch information
DocCyblade authored May 9, 2017
2 parents e9404e2 + 821f4a2 commit 70c4a74
Show file tree
Hide file tree
Showing 26 changed files with 634 additions and 3 deletions.
Binary file added .art/about.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .art/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .art/login_form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .art/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .art/setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .art/tools.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
WEBMIN_FW_TCP_INCOMING = 22 80 443 12320 12321 12322

CREDIT_ANCHORTEXT = Turnkey Mayan EDMS Appliance

COMMON_OVERLAYS += adminer nginx
COMMON_CONF += adminer-pgsql


# Include the PostgreSQL/PHP make file
include $(FAB_PATH)/common/mk/turnkey/pgsql.mk
include $(FAB_PATH)/common/mk/turnkey.mk


5 changes: 2 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ or repository for electronic documents.

This appliance includes all the standard features in `TurnKey Core`_:

- Mayan EDMS 2.1 installed via PIP from `PyPI`_
- Mayan EDMS 2.2 installed via PIP from `PyPI`_
- Includes all pre-reqs: Virtualenv/Django/uWSGI/Celery/Redis/Supervisor
- SSL support out of the box.
- PostgreSQL is is installed as Mayan's backend database
Expand All @@ -29,8 +29,7 @@ Credentials *(passwords set at first boot)*
- Mayan EDMS Admin Account: **admin**

.. _Mayan EDMS: http://www.mayan-edms.com
.. _PyPI: https://pypi.python.org/pypi/mayan-edms/2.1.3
.. _GitHub: https://github.com/odoo/odoo
.. _PyPI: https://pypi.python.org/pypi/mayan-edms
.. _TurnKey Core: https://www.turnkeylinux.org/core
.. _Adminer: http://www.adminer.org/
.. _upstream: https://github.com/DocCyblade/tkl-mayan-edms
Expand Down
16 changes: 16 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
turnkey-mayan-edms-14.2 (1) turnkey; urgency=low

* Initial release of appliance:
- Mayan EDMS v2.2
- includes PostgreSQL for database backend
- includes Nginx for web front end
- upstream source install (PyPI)

* Based on the work of community member Ken Robinson (@DocCyblade)
Build source: https://github.com/DocCyblade/tkl-mayan-edms

* Note: Please refer to turnkey-core's changelog for changes common to all
appliances.

-- Ken Robinson <[email protected]> Mon, 08 May 2017 23:54:00 -0400

143 changes: 143 additions & 0 deletions conf.d/main
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/bin/bash -ex

# Demo files download function
# dl [URL] [TARGET DIR] [TARGET FILE NAME]
#
dl() {
[ "$FAB_HTTP_PROXY" ] && PROXY="--proxy $FAB_HTTP_PROXY"
cd $2; curl -L -f $PROXY $1 -o $3; cd -
}

# Use FAB proxy with PIP
# fab-pip-install [package]
fab-pip-install() {
[ "$FAB_HTTP_PROXY" ] && PROXY="--proxy $FAB_HTTP_PROXY"
pip $PROXY install $1
}

# Use FAB proxy with PIP Upgrade
# fab-pip-upgrade [package]
fab-pip-upgrade() {
[ "$FAB_HTTP_PROXY" ] && PROXY="--proxy $FAB_HTTP_PROXY"
pip $PROXY install -U $1
}

# Set variables
#
DB_NAME=mayan
DB_USER=mayan
DB_PASS=$(mcookie)


APP_SETTINGS=/usr/share/mayan-edms/mayan/settings/local.py
APP_SETTINGS_TEMPLATE=/usr/share/mayan-edms/mayan/settings/settings.template
APP_SETTINGS_DATA_DIR=/usr/share/mayan-edms/mayan/media/document_storage

# Create application directory (virtualenv)
cd /usr/share
virtualenv mayan-edms

# Activate the environment
source /usr/share/mayan-edms/bin/activate

# Upgrade PIP within the virtualenv
fab-pip-upgrade pip

# Install Mayan EDMS from PyPI
fab-pip-install mayan-edms

# Install Python client for PostgreSQL
fab-pip-install psycopg2

# Install Python client for Redis key-value store
fab-pip-install redis

# Install Python uWSGI server
fab-pip-install uwsgi


# Start postgresql server
/etc/init.d/postgresql start

# Create the database user and database for the installation
su postgres -c "createuser $DB_USER"
su postgres -c "createdb -O $DB_USER $DB_NAME"
su postgres -c "psql postgres" << EOF
alter user $DB_USER with encrypted password '$DB_PASS';
EOF


# Create log file directory for mayan and uwsgi
mkdir /var/log/mayan
mkdir /var/log/uwsgi

# Make a convenience symbolic link
cd /usr/share/mayan-edms
ln -s lib/python2.7/site-packages/mayan .

# Make doc store
mkdir -p $APP_SETTINGS_DATA_DIR

# Create an initial settings file and db.template
# We will recreate this on first boot, but create it
# here for testing builds.
mayan-edms.py createsettings -v 3

cat << EOF > $APP_SETTINGS_TEMPLATE
DEBUG = False
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '$DB_NAME',
'USER': '$DB_USER',
'PASSWORD': '$DB_PASS',
'HOST': 'localhost',
'PORT': '5432',
}
}
BROKER_URL = 'redis://127.0.0.1:6379/0'
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/0'
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
EOF



# Create initial settings
mayan-edms.py createsettings

# Apply the settings template
cat $APP_SETTINGS_TEMPLATE >> $APP_SETTINGS


# Init Mayan Database
mayan-edms.py initialsetup


# Disable the default NGINX site
rm /etc/nginx/sites-enabled/default

# Enable the NGINX site for Mayan EDMS
ln -s /etc/nginx/sites-available/mayan /etc/nginx/sites-enabled/

# Collect static files
mayan-edms.py collectstatic --noinput


# Make the installation and directory readable and writable by the webserver user
chown www-data:www-data /usr/share/mayan-edms -R

# Stop postgresql server
/etc/init.d/postgresql stop


# Link Nginx Adminer conifg
ln -s /etc/nginx/sites-available/adminer /etc/nginx/sites-enabled/adminer

# Configure fastcgi for Adminer via Nginx (php-fastcgi)
update-rc.d php-fastcgi defaults
5 changes: 5 additions & 0 deletions overlay/etc/confconsole/services.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Mayan EDMS: https://$ipaddr
Web shell: https://$ipaddr:12320
Webmin: https://$ipaddr:12321
Adminer: https://$ipaddr:12322
SSH/SFTP: root@$ipaddr (port 22)
10 changes: 10 additions & 0 deletions overlay/etc/default/php-fastcgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SOCKETDIR=/var/run/nginx
mkdir -p $SOCKETDIR
chown root:www-data $SOCKETDIR
chmod 770 $SOCKETDIR

START=yes
EXEC_AS_USER=www-data:www-data
PHP_FCGI_SOCKET=$SOCKETDIR/$NAME.sock
PHP_FCGI_CHILDREN=2
PHP_FCGI_MAX_REQUESTS=1000
131 changes: 131 additions & 0 deletions overlay/etc/init.d/php-fastcgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: php-fastcgi
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop php-cgi in external FASTCGI mode
# Description: Start and stop php-cgi in external FASTCGI mode
### END INIT INFO

# Author: Kurt Zankl <[email protected]>

# Do NOT "set -e"

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=php-fastcgi
DESC="php-cgi in external FASTCGI mode"
DAEMON=/usr/bin/php-cgi
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

# If the daemon is not enabled, give the user a warning and then exit,
# unless we are stopping the daemon
if [ "$START" != "yes" -a "$1" != "stop" ]; then
log_warning_msg "To enable $NAME, edit /etc/default/$NAME and set START=yes"
exit 0
fi

# Process configuration
export PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS
DAEMON_ARGS="-q -b $PHP_FCGI_SOCKET"



do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \
--background --make-pidfile --chuid $EXEC_AS_USER --startas $DAEMON -- \
$DAEMON_ARGS \
|| return 2
}

do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE > /dev/null # --name $DAEMON
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}

case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac

# The colon at the end makes sure that the script returns the correct return value of log_end_msg
# using systemd with this script, it will fail without this colon! Keep it there!

:

26 changes: 26 additions & 0 deletions overlay/etc/nginx/fastcgi_params
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

fastcgi_param HTTP_PROXY "";

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
9 changes: 9 additions & 0 deletions overlay/etc/nginx/include/php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include /etc/nginx/fastcgi_params;

location ~ \.php$ {
# http://forum.nginx.org/read.php?2,88845,page=3
try_files $uri =404;

fastcgi_pass unix:/var/run/nginx/php-fastcgi.sock;
fastcgi_index index.php;
}
Loading

0 comments on commit 70c4a74

Please sign in to comment.