mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-14 12:07:12 +00:00
Merge pull request #543 from maur/master
lxc installation - small improvements
This commit is contained in:
6 files changed
+305
-2
No files matched your search
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="terminal" baseProfile="full" viewBox="0 0 1056 733" width="1056" version="1.1">
|
||||
<defs>
|
||||
<termtosvg:template_settings xmlns:termtosvg="https://github.com/nbedos/termtosvg">
|
||||
<termtosvg:screen_geometry columns="132" rows="43"/>
|
||||
</termtosvg:template_settings>
|
||||
<style type="text/css" id="generated-style"><![CDATA[:root {
|
||||
--animation-duration: 218367ms;
|
||||
}
|
||||
|
||||
#screen {
|
||||
font-family: 'DejaVu Sans Mono', monospace;
|
||||
font-style: normal;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
text {
|
||||
dominant-baseline: text-before-edge;
|
||||
white-space: pre;
|
||||
}]]></style>
|
||||
<style type="text/css" id="user-style">
|
||||
/* gjm8 color theme (source: https://terminal.sexy/) */
|
||||
.foreground {fill: #c5c5c5;}
|
||||
.background {fill: #1c1c1c;}
|
||||
.color0 {fill: #1c1c1c;}
|
||||
.color1 {fill: #ff005b;}
|
||||
.color2 {fill: #cee318;}
|
||||
.color3 {fill: #ffe755;}
|
||||
.color4 {fill: #048ac7;}
|
||||
.color5 {fill: #833c9f;}
|
||||
.color6 {fill: #0ac1cd;}
|
||||
.color7 {fill: #e5e5e5;}
|
||||
.color8 {fill: #1c1c1c;}
|
||||
.color9 {fill: #ff005b;}
|
||||
.color10 {fill: #cee318;}
|
||||
.color11 {fill: #ffe755;}
|
||||
.color12 {fill: #048ac7;}
|
||||
.color13 {fill: #833c9f;}
|
||||
.color14 {fill: #0ac1cd;}
|
||||
.color15 {fill: #e5e5e5;}
|
||||
</style>
|
||||
</defs>
|
||||
<svg id="screen" width="1056" viewBox="0 0 1056 731" preserveAspectRatio="xMidYMin meet">
|
||||
<rect class="background" height="100%" width="100%" x="0" y="0"/><g display="none"><rect class="foreground" height="17" width="8" x="0" y="0"/><use y="0" xlink:href="#g1"/><animate attributeName="display" begin="0ms; anim_last.end" dur="47ms" from="inline" to="inline"/></g><g display="none"><rect class="foreground" height="17" width="8" x="144" y="0"/><use y="0" xlink:href="#g2"/><animate attributeName="display" begin="47ms; anim_last.end+47ms" dur="1580ms" from="inline" to="inline"/></g><g display="none"><rect class="foreground" height="17" width="8" x="0" y="34"/><use y="34" xlink:href="#g1"/><animate attributeName="display" begin="1627ms; anim_last.end+1627ms" dur="1060ms" from="inline" to="inline"/></g><g display="none"><rect class="foreground" height="17" width="8" x="0" y="629"/><use y="629" xlink:href="#g1"/><animate attributeName="display" begin="2687ms; anim_last.end+2687ms" dur="68ms" from="inline" to="inline"/></g><g display="none"><rect class="foreground" height="17" width="8" x="104" y="629"/><use y="629" xlink:href="#g3"/><animate attributeName="display" begin="2755ms; anim_last.end+2755ms" dur="2000ms" from="inline" to="inline"/></g><g display="none"><rect class="foreground" height="17" width="8" x="328" y="646"/><use y="646" xlink:href="#g4"/><animate attributeName="display" begin="4755ms; anim_last.end+4755ms" dur="1059ms" from="inline" to="inline"/></g><g display="none"><rect class="foreground" height="17" width="8" x="0" y="663"/><use y="663" xlink:href="#g1"/><animate attributeName="display" begin="5814ms; anim_last.end+5814ms" dur="65ms" from="inline" to="inline"/></g><g display="none"><rect class="foreground" height="17" width="8" x="0" y="680"/><use y="680" xlink:href="#g1"/><animate attributeName="display" begin="5879ms; anim_last.end+5879ms" dur="2000ms" from="inline" to="inline"/></g><g display="none"><rect class="foreground" height="17" width="8" x="0" y="697"/><use y="697" xlink:href="#g1"/><animate attributeName="display" begin="7879ms; anim_last.end+7879ms" dur="465ms" from="inline" to="inline"/></g><g display="none"><use y="0" xlink:href="#g5"/><use y="17" xlink:href="#g6"/><animate attributeName="display" begin="1627ms; anim_last.end+1627ms" dur="8717ms" from="inline" to="inline"/></g><g display="none"><use y="34" xlink:href="#g7"/><use y="68" xlink:href="#g8"/><use y="85" xlink:href="#g9"/><use y="102" xlink:href="#g10"/><use y="136" xlink:href="#g11"/><use y="170" xlink:href="#g12"/><use y="187" xlink:href="#g13"/><use y="204" xlink:href="#g14"/><use y="221" xlink:href="#g15"/><use y="238" xlink:href="#g16"/><use y="272" xlink:href="#g17"/><use y="306" xlink:href="#g18"/><use y="323" xlink:href="#g19"/><use y="357" xlink:href="#g20"/><use y="391" xlink:href="#g21"/><use y="425" xlink:href="#g22"/><use y="476" xlink:href="#g23"/><use y="493" xlink:href="#g24"/><use y="510" xlink:href="#g25"/><use y="544" xlink:href="#g26"/><use y="561" xlink:href="#g27"/><use y="612" xlink:href="#g28"/><animate attributeName="display" begin="2687ms; anim_last.end+2687ms" dur="7657ms" from="inline" to="inline"/></g><g display="none"><use y="629" xlink:href="#g29"/><animate attributeName="display" begin="4755ms; anim_last.end+4755ms" dur="5589ms" from="inline" to="inline"/></g><g display="none"><use y="646" xlink:href="#g30"/><animate attributeName="display" begin="5814ms; anim_last.end+5814ms" dur="4530ms" from="inline" to="inline"/></g><g display="none"><use y="663" xlink:href="#g31"/><animate attributeName="display" begin="5879ms; anim_last.end+5879ms" dur="4465ms" from="inline" to="inline"/></g><g display="none"><use y="680" xlink:href="#g32"/><animate attributeName="display" begin="7879ms; anim_last.end+7879ms" dur="2465ms" from="inline" to="inline"/></g><g display="none"><rect class="foreground" height="17" width="8" x="104" y="697"/><use y="697" xlink:href="#g3"/><animate attributeName="display" begin="8344ms; anim_last.end+8344ms" dur="2000ms" from="inline" to="inline"/></g><g display="none"><use y="0" xlink:href="#g6"/><use y="17" xlink:href="#g7"/><use y="51" xlink:href="#g8"/><use y="68" xlink:href="#g9"/><use y="85" xlink:href="#g10"/><use y="119" xlink:href="#g11"/><use y="153" xlink:href="#g12"/><use y="170" xlink:href="#g13"/><use y="187" xlink:href="#g14"/><use y="204" xlink:href="#g15"/><use y="221" xlink:href="#g16"/><use y="255" xlink:href="#g17"/><use y="289" xlink:href="#g18"/><use y="306" xlink:href="#g19"/><use y="340" xlink:href="#g20"/><use y="374" xlink:href="#g21"/><use y="408" xlink:href="#g22"/><use y="459" xlink:href="#g23"/><use y="476" xlink:href="#g24"/><use y="493" xlink:href="#g25"/><use y="527" xlink:href="#g26"/><use y="544" xlink:href="#g27"/><use y="595" xlink:href="#g28"/><use y="612" xlink:href="#g29"/><use y="629" xlink:href="#g30"/><use y="646" xlink:href="#g31"/><use y="663" xlink:href="#g32"/><use y="680" xlink:href="#g33"/><use y="697" xlink:href="#g34"/><rect class="foreground" height="17" width="8" x="248" y="714"/><use y="714" xlink:hreLine truncated
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.9 MiB |
@@ -0,0 +1,156 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Bash script to install paperless in lxc containter
|
||||
# paperless.lan
|
||||
#
|
||||
# Will set-up paperless, apache2 and proftpd
|
||||
#
|
||||
# lxc launch ubuntu: paperless
|
||||
# lxc exec paperless -- sh -c "sudo apt-get update && sudo apt-get install -y wget"
|
||||
# lxc exec paperless -- sh -c "wget https://raw.githubusercontent.com/the-paperless-project/paperless/master/docs/examples/lxc/lxc-install.sh && /bin/bash lxc-install.sh --email "
|
||||
#
|
||||
#
|
||||
set +e
|
||||
PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9+@%^{} | head -c20;echo;)
|
||||
EMAIL=
|
||||
|
||||
function displayHelp() {
|
||||
echo "available parameters:
|
||||
-e <email> | --email <email>
|
||||
-p <password> | --password <password>
|
||||
"
|
||||
}
|
||||
|
||||
POSITIONAL=()
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
key="$1"
|
||||
i=$key
|
||||
|
||||
case $i in
|
||||
-e|--email)
|
||||
EMAIL="${2}"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-p|--password)
|
||||
PASSWORD="${2}"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--default|-h|--help)
|
||||
shift
|
||||
displayHelp
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "argument: $i not recognized"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
set -- "${POSITIONAL[@]}" # restore positional parameters
|
||||
|
||||
if [ -z $EMAIL ]; then
|
||||
echo "missing email, try running with -h "
|
||||
exit 3
|
||||
fi
|
||||
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
|
||||
echo "Not running as root"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $(grep -c paperless /etc/passwd) -eq 0 ]; then
|
||||
# Add paperless user with no password
|
||||
adduser --disabled-password --gecos "" paperless
|
||||
fi
|
||||
|
||||
if [ $(grep -c ftpupload /etc/passwd) -eq 0 ]; then
|
||||
# Add ftpupload
|
||||
adduser --disabled-password --gecos "" ftpupload
|
||||
echo "Set ftpupload password: "
|
||||
#passwd ftpupload
|
||||
#TODO: generate some password and allow parameter
|
||||
echo "ftpupload:ftpuploadpassword" | chpasswd
|
||||
fi
|
||||
|
||||
if [ $(id -nG paperless | grep -Fcw ftpupload) -eq 0 ]; then
|
||||
# Allow paperless group to access
|
||||
adduser paperless ftpupload
|
||||
chmod g+w /home/ftpupload
|
||||
fi
|
||||
|
||||
# Get apt up to date
|
||||
apt-get update
|
||||
|
||||
# Needed for plain Paperless
|
||||
apt-get -y install unpaper gnupg libpoppler-cpp-dev python3-pyocr tesseract-ocr imagemagick optipng git
|
||||
|
||||
# Needed for Apache
|
||||
apt-get -y install apache2 libapache2-mod-wsgi-py3
|
||||
|
||||
if [ ! -f /etc/proftpd/proftpd.conf -o $(grep -c paperless /etc/proftpd/proftpd.conf) -eq 0 ]; then
|
||||
# Install ftp server and make sure all uplaoded files are owned by paperless
|
||||
apt-get -y install proftpd
|
||||
cat <<EOF >> /etc/proftpd/proftpd.conf
|
||||
<Directory /home/ftpupload/>
|
||||
UserOwner paperless
|
||||
GroupOwner paperless
|
||||
</Directory>
|
||||
EOF
|
||||
systemctl restart proftpd
|
||||
fi
|
||||
|
||||
#Get Paperless from git
|
||||
su -c "cd /home/paperless ; git clone https://github.com/the-paperless-project/paperless" paperless
|
||||
|
||||
# Install Pip Requirements
|
||||
apt-get -y install python3-pip python3-venv
|
||||
cd /home/paperless/paperless
|
||||
pip3 install -r requirements.txt
|
||||
|
||||
# Take paperless.conf.example and set consumuption dir (ftp dir)
|
||||
sed -e '/PAPERLESS_CONSUMPTION_DIR=/s/=.*/=\"\/home\/ftpupload\/\"/' \
|
||||
/home/paperless/paperless/paperless.conf.example >/etc/paperless.conf
|
||||
|
||||
# Update /etc/paperless.conf with PAPERLESS_SECRET_KEY
|
||||
SECRET=$(strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo)
|
||||
sed -i "s/#PAPERLESS_SECRET_KEY.*/PAPERLESS_SECRET_KEY=$SECRET/" /etc/paperless.conf
|
||||
|
||||
#Initialise the SQLite database
|
||||
su -c "cd /home/paperless/paperless/src/ ; ./manage.py migrate" paperless
|
||||
echo "if superuser doesn't exists, create one with login: paperless and password: ${PASSWORD}"
|
||||
#Create a user for your Paperless instance
|
||||
su -c "cd /home/paperless/paperless/src/ ; echo ./manage.py create_superuser_with_password --username paperless --email ${EMAIL} --password ${PASSWORD} --preserve" paperless
|
||||
su -c "cd /home/paperless/paperless/src/ ; ./manage.py create_superuser_with_password --username paperless --email ${EMAIL} --password ${PASSWORD} --preserve" paperless
|
||||
|
||||
if [ ! -d /home/paperless/paperless/static ]; then
|
||||
# 167 static files copied to '/home/paperless/paperless/static'.
|
||||
su -c "cd /home/paperless/paperless/src/ ; ./manage.py collectstatic" paperless
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/apache2/sites-available/paperless.conf ]; then
|
||||
# Set-up apache
|
||||
cp /home/paperless/paperless/docs/examples/lxc/paperless.conf /etc/apache2/sites-available/
|
||||
a2dissite 000-default.conf
|
||||
a2ensite paperless.conf
|
||||
systemctl reload apache2
|
||||
fi
|
||||
|
||||
sed -e "s:home/paperless/project/virtualenv/bin/python:usr/bin/python3:" \
|
||||
/home/paperless/paperless/scripts/paperless-consumer.service \
|
||||
>/etc/systemd/system/paperless-consumer.service
|
||||
|
||||
sed -i "s:/home/paperless/project/src/manage.py:/home/paperless/paperless/src/manage.py:" \
|
||||
/etc/systemd/system/paperless-consumer.service
|
||||
|
||||
|
||||
systemctl enable paperless-consumer
|
||||
systemctl start paperless-consumer
|
||||
|
||||
# convert-im6.q16: not authorized
|
||||
# Security risk ?
|
||||
# https://stackoverflow.com/questions/42928765/convertnot-authorized-aaaa-error-constitute-c-readimage-453
|
||||
if [ -f /etc/ImageMagick-6/policy.xml ]; then
|
||||
mv /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xmlout
|
||||
fi
|
||||
@@ -0,0 +1,18 @@
|
||||
<VirtualHost *:80>
|
||||
ServerName paperless.lan
|
||||
|
||||
Alias /static/ /home/paperless/paperless/static/
|
||||
<Directory /home/paperless/paperless/static>
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
WSGIScriptAlias / /home/paperless/paperless/src/paperless/wsgi.py
|
||||
WSGIDaemonProcess paperless.lan user=paperless group=paperless threads=5 python-path=/home/paperless/paperless/src
|
||||
WSGIProcessGroup paperless.lan
|
||||
|
||||
<Directory /home/paperless/paperless/src/paperless>
|
||||
<Files wsgi.py>
|
||||
Require all granted
|
||||
</Files>
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
+48
-1
@@ -43,6 +43,7 @@ You can go multiple routes with setting up and running Paperless:
|
||||
|
||||
* The `bare metal route`_
|
||||
* The `docker route`_
|
||||
* A suggested `linux containers route`_
|
||||
|
||||
|
||||
The `docker route`_ is quick & easy.
|
||||
@@ -50,10 +51,14 @@ The `docker route`_ is quick & easy.
|
||||
The `bare metal route`_ is a bit more complicated to setup but makes it easier
|
||||
should you want to contribute some code back.
|
||||
|
||||
The `linux containers route`_ is quick, but makes alot of assumptions on the
|
||||
set-up, on the other hand the script could be used to install on a base
|
||||
debian or ubuntu server.
|
||||
|
||||
.. _docker route: setup-installation-docker_
|
||||
.. _bare metal route: setup-installation-bare-metal_
|
||||
.. _Docker Machine: https://docs.docker.com/machine/
|
||||
|
||||
.. _linux containers route: setup-installation-linux-containers_
|
||||
|
||||
.. _setup-installation-bare-metal:
|
||||
|
||||
@@ -485,3 +490,45 @@ If you're using Docker, you can set a restart-policy_ in the
|
||||
Docker daemon.
|
||||
|
||||
.. _restart-policy: https://docs.docker.com/engine/reference/commandline/run/#restart-policies-restart
|
||||
|
||||
|
||||
.. _setup-installation-linux-containers:
|
||||
|
||||
Suggested way for Linux Container Method
|
||||
++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
This method uses some rigid assumptions, for the best set-up:-
|
||||
|
||||
* Ubuntu lts as the container
|
||||
* Apache as the webserver
|
||||
* proftpd as ftp server
|
||||
* ftpupload as the ftp user
|
||||
* paperless as the main user for website
|
||||
* http://paperless.lan is the desired lan url
|
||||
* LXC set to give ip addresses on your lan
|
||||
|
||||
This could also be used as an install on a base debain/ubuntu server,
|
||||
if the above assumptions are acceptable.
|
||||
|
||||
1. Install lxc
|
||||
|
||||
|
||||
2. Lanch paperless container
|
||||
|
||||
.. code:: bash
|
||||
|
||||
$ lxc launch ubuntu: paperless
|
||||
|
||||
3. Run install script within container
|
||||
|
||||
.. code:: bash
|
||||
|
||||
$ lxc exec paperless -- sh -c "wget https://raw.githubusercontent.com/the-paperless-project/paperless/master/docs/examples/lxc/lxc-install.sh && /bin/bash lxc-install.sh --email"
|
||||
|
||||
The script will ask you for an ftpupload password.
|
||||
As well as the super-user for paperless web front-end.
|
||||
After around 10 mins, http://paperless.lan is ready and
|
||||
ftp://paperless.lan with user: ftpupload
|
||||
|
||||
See the `Installation recording <_static/lxc-install.svg>`_.
|
||||
|
||||
@@ -72,4 +72,4 @@ with a DPI of 300, then merging the images into the single PDF with
|
||||
For more information on this and situations like it, you should take a look
|
||||
at `Issue #118`_ as that's where this tip originated.
|
||||
|
||||
.. _Issue #118: https://github.com/the-paperless-project/paperless/issues/118
|
||||
.. _Issue #118: https://github.com/the-paperless-project/paperless/issues/118
|
||||
@@ -0,0 +1,38 @@
|
||||
from django.contrib.auth.management.commands import createsuperuser
|
||||
from django.core.management import CommandError
|
||||
|
||||
|
||||
class Command(createsuperuser.Command):
|
||||
help = 'Crate a superuser, and allow password to be provided'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
super(Command, self).add_arguments(parser)
|
||||
parser.add_argument(
|
||||
'--password', dest='password', default=None,
|
||||
help='Specifies the password for the superuser.',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--preserve', dest='preserve', default=False, action='store_true',
|
||||
help='Exit normally if the user already exists.',
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
password = options.get('password')
|
||||
username = options.get('username')
|
||||
database = options.get('database')
|
||||
|
||||
if password and not username:
|
||||
raise CommandError("--username is required if specifying --password")
|
||||
|
||||
if username and options.get('preserve'):
|
||||
exists = self.UserModel._default_manager.db_manager(database).filter(username=username).exists()
|
||||
if exists:
|
||||
self.stdout.write("User exists, exiting normally due to --preserve")
|
||||
return
|
||||
|
||||
super(Command, self).handle(*args, **options)
|
||||
|
||||
if password:
|
||||
user = self.UserModel._default_manager.db_manager(database).get(username=username)
|
||||
user.set_password(password)
|
||||
user.save()
|
||||
Reference in new issue
Block a user