1
0
mirror of https://github.com/chylex/Nextcloud-News.git synced 2025-04-09 19:15:42 +02:00

add systemd scripts for updater

This commit is contained in:
Bernhard Posselt 2014-12-04 10:32:23 +01:00
parent 90ae9ae044
commit 69624de11f
11 changed files with 160 additions and 2 deletions

8
.gitignore vendored
View File

@ -7,6 +7,14 @@ js/*.xml
.rvm
*.clover
# python
PKG-INFO
*pyc
*~
__pycache__
dist/
ocdev.egg-info
# just sane ignores
.*.sw[po]
*.bak

View File

@ -1,5 +1,7 @@
owncloud-news (4.2.7)
owncloud-news (4.3.0)
* **Backwards incompatible change**: Move updater.py from bin/ to bin/updater
* **Enhancement**: Add metronieuws.nl article enhancer
* **Enhancement**: Ship a systemd unit file and makefile to run the updater on boot
owncloud-news (4.2.6)
* **Bugfix**: Wording fixes

27
bin/updater/Makefile Normal file
View File

@ -0,0 +1,27 @@
all: install
install: install-systemd
install-systemd:
mkdir -p /etc/owncloud/news
# install systemd unit file
cp $(CURDIR)/example-config.ini /etc/owncloud/news/updater.ini
cp $(CURDIR)/systemd/owncloud-news.service /etc/systemd/system/
python3 setup.py install
@echo "Installed files. Please edit your config in /etc/owncloud/news/updater.ini and run:"
@echo " systemctl enable owncloud-news"
@echo " systemctl start owncloud-news"
@echo "to run the updater on startup and:"
@echo " systemctl restart owncloud-news"
@echo "if you change the config in /etc/owncloud/news/updater.ini"
make uninstall:
rm -rf /etc/owncloud/news
rm -rf /etc/systemd/systemd/owncloud-news.service
python3 setup.py uninstall
@echo "Uninstalled files. Please run: "
@echo " systemctl disable owncloud-news"
@echo "to remove it from boot"

71
bin/updater/REAME.rst Normal file
View File

@ -0,0 +1,71 @@
ownCloud News Updater
=====================
ownCloud does not require people to install threading or multiprocessing libraries. Because the feed update process is mainly limited by I/O, parallell fetching of RSS feed updates can speed up the updating process a lot. In addition the cronjob can get `into a deadlock <https://github.com/owncloud/core/issues/3221>`_ which will halt cause your feeds not to be updated. This can be soled by using a script that uses the `updater API <https://github.com/owncloud/news/wiki/Cron-1.2>`_
Preinstallation
---------------
To run the updates via an external threaded script the cron updater has to be disabled. To do that go to the admin section an uncheck the "Use ownCloud cron" checkbox or open **owncloud/data/news/config/config.ini** set:
::
useCronUpdates = true
to
::
useCronUpdates = false
Installation: No init system
----------------------------
If you decide against using an init system to run the script simply run::
sudo setup.py install
Then you can run the updater daemon using::
owncloud-news-updater --user USERNAME --password PASSWORD http://yourcloud.com
or if you are using a config file::
owncloud-news-updater -c /path/to/config
Installation: SystemD
---------------------
To install the script for systemd run::
sudo make install-systemd
Then edit the config in **/etc/owncloud/news/updater.ini** with your details and run::
owncloud-news-updater -c /etc/owncloud/news/updater.ini
to test your settings. If everything worked out fine, enable the systemd unit with::
sudo systemctl enable owncloud-news
sudo systemctl start owncloud-news
Finally turn off the cron updates in the owncloud admin interface
Self signed certificates
------------------------
Should you use a self signed certificate over SSL, first consider getting a free valid cert signed by `StartSSL <http://startssl.com>`_. If you don't want to get a valid certificate, you need to add it to the installed certs::
cat /path/to/your/cert/cacert.pem >> /usr/local/lib/python3.X/dist-packages/requests/cacert.pem
The directories might vary depending on your distribution and Python version.
Development
-----------
If you want to edit the python code and test it run::
python3 -m owncloud_news -c /path/to/config.ini

View File

View File

@ -0,0 +1,3 @@
from owncloud_news.application import main
main()

View File

@ -4,7 +4,6 @@ Updater script for the news app which allows multiple feeds to be updated at
once to speed up the update process. Built in cron has to be disabled in the
news config, see the README.rst file in the top directory for more information.
"""
__author__ = 'Bernhard Posselt'
__copyright__ = 'Copyright 2012-2014, Bernhard Posselt'
__license__ = 'AGPL3+'

39
bin/updater/setup.py Normal file
View File

@ -0,0 +1,39 @@
from os import exit
from xml.etree import ElementTree
try:
from setuptools import setup, find_packages
except ImportError as e:
print('Could not find setuptools. Did you install the package?')
exit(1)
with open('requirements.txt', 'r') as infile:
install_requires = infile.read().split('\n')
with open('README.rst', 'r') as infile:
long_description = infile.read()
# parse version from info.xml
tree = ElementTree.parse('../../appinfo/info.xml')
for element in tree.findall('version'):
version = element.text
setup (
name = 'owncloud-news-updater',
version = version,
description = 'ownCloud news updater',
long_description = long_description,
author = 'Bernhard Posselt',
author_email = 'dev@bernhard-posselt.com',
url = 'https://github.com/owncloud/news',
packages = find_packages(),
include_package_data = True,
license = 'AGPL',
install_requires = install_requires,
keywords = ['owncloud', 'news', 'updater'],
entry_points = {
'console_scripts': [
'owncloud-news-updater = owncloud_news.application:main'
]
}
)

View File

@ -0,0 +1,9 @@
[Unit]
After=default.target
[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/local/bin/owncloud-news-updater -c /etc/owncloud/news/config.ini
[Install]
WantedBy=default.target