Skip to content
Snippets Groups Projects
Commit db1e1cab authored by nimrod's avatar nimrod
Browse files

Complete refactor and reworked usage.

The usage is completely replaced. Now locally I run inside a pipenv and
remotely using Docker.

- Use Supersonic as the Cron daemon.
- Run locally using pipenv.
- Run remotely using Docker (and docker-compose).
- Automate tasks using pipenv custom script shortcuts.
- Updated pre-commit hooks, added yamllint hook.
- Added license.
- Updated README.
parent a08cc415
No related branches found
No related tags found
No related merge requests found
*
!Pipfile*
!poca.xml
!crontab
.envrc 0 → 100644
source_up
layout pipenv
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
sha: v0.7.1
rev: v2.2.1
hooks:
- id: check-added-large-files
- id: check-yaml
- id: check-xml
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/willthames/ansible-lint
sha: v3.4.13
hooks:
- id: ansible-lint
files: playbook\.yml
args: ['--exclude=roles']
- repo: https://github.com/adarnimrod/shell-pre-commit
sha: v0.5.4
- id: check-symlinks
- id: trailing-whitespace
- repo: https://github.com/adrienverge/yamllint
rev: v1.15.0
hooks:
- id: shell-lint
files: receiver
- id: shellcheck
files: receiver
- id: yamllint
FROM adarnimrod/cron as supersonic
FROM python:3.7-alpine
COPY --from=supersonic /usr/local/bin/supersonic /usr/local/bin/
RUN pip install --no-cache-dir pipenv
COPY Pipfile* /poquita/
WORKDIR /poquita
RUN apk add --update --no-cache --virtual .lxml-build build-base libxslt-dev && \
pipenv install --deploy --system && \
apk del .lxml-build && \
apk add --update --no-cache --virtual .lxml-runtime libxml2 libxslt
COPY --chown=root:root crontab /poquita/
COPY --chown=root:root poca.xml /poquita/
VOLUME /poquita/db/ /poquita/Podcasts/
CMD [ "supersonic", "crontab" ]
USER nobody
HEALTHCHECK CMD pgrep supersonic
MIT License
Copyright (c) 2019 Adar Nimrod
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Pipfile 0 → 100644
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
pre-commit = "*"
docker-compose = "*"
[packages]
poca = "*"
[requires]
python_version = "3.7"
[scripts]
deploy = "docker-compose up --detach --build --remove-orphans"
subscribe = "poca-subscribe -c ."
lint = "pre-commit"
This diff is collapsed.
# Poquita
My setup of [Poca](https://github.com/brokkr/poca/).
> My setup of [Poca](https://github.com/brokkr/poca/).
My workflow is managing the podcast list (and config and provisioning and
deployment scripts) via git, using
[gitreceive](https://github.com/progrium/gitreceive/) to deploy new versions to
the downloading machine (syncing files locally when afterward).
My setup consists of keeping the subscriptions in git (`poca.xml`), managing
them locally and running the downloader inside a Docker container remotely. The
final part of syncing the downloads is using unison and is managed in my
[rcfiles](https://www.shore.co.il/git/rcfiles) repository.
## Running Poca locally
## Requirements
`tox`
- Python 3.7
- pipenv
## Running poca-subscribe locally
## Usage
`tox -e poca-subscribe -- {add,delete,list,toggle} ...`
Adding/ removing/ list/ toggling subscriptions:
```
pipenv run subscribe {add,delete,list,toggle}
```
## Provision a machine for git push
Deploying a new version:
```
pipenv run deploy
```
`tox -e ansible -- -i xbmc.shore.co.il,`
Linting (using [pre-commit](https://pre-commit.com/)):
```
pipenv run lint
```
## Deploying a new version
## License
git remote add kodi git@xbmc.shore.co.il:poquita.git
git push kodi
## Running [pre-commit](http://pre-commit.com/)
`tox -e pre-commit`
This software is licensed under the MIT license (see `LICENSE.txt`).
[defaults]
library = library
host_key_checking = False
retry_files_enabled = False
roles_path = ./roles/
command_warnings = True
deprecation_warnings = True
callback_whitelist = profile_tasks
retry_files_save_path = /tmp/
[ssh_connection]
pipelining = True
[privilege_escalation]
become = True
become_method = sudo
become_user = root
become_ask_pass = False
0 */4 * * * cd /poquita && poca --config ./
---
version: '2'
services:
- poquita:
build:
context: ./
restart: on-failure
user: '1000' # My (Nimrod) uid on the xbmc host.
volumes:
- /srv/library/nimrod/Podcasts:/poquita/Podcasts
- poquita:/poquita/db
volumes:
poquita:
---
- hosts: all
pre_tasks:
- name: APT install Python3, Tox, Cron, Unison
apt:
name:
- python3
- tox
- cron-daemon
- unison
state: present
update_cache: True
cache_valid_time: 3600
- name: Get authorized keys
become: False
slurp:
src: ~/.ssh/authorized_keys
register: authorized_keys
roles:
- name: gitreceive
gitreceive_public_keys: "{{ (authorized_keys['content']|b64decode).splitlines() }}"
gitreceive_receiver_script: |
#!/bin/sh
set -eu
echo '----> Unpacking ...'
mkdir -p ~/poquita
cd ~/poquita
tar -xf -
if [ -f receiver ] && [ -x receiver ]
then
echo '----> Running receiver ...'
./receiver
fi
echo '----> OK.'
post_tasks:
- name: Create Podcasts directory
file:
path: /srv/library/nimrod/Podcasts
state: directory
owner: nimrod
group: git
mode: 0o0775
#!/bin/sh
set -eu
# shellcheck disable=SC2016
( (crontab -l 2>/dev/null || true) | sed '/poquita/d'; echo '0 */4 * * * tox -c $HOME/poquita/tox.ini | logger' ) | crontab -
---
- src: adarnimrod.gitreceive
name: gitreceive
[tox]
skipsdist = True
envlist = poca
[testenv:poca]
basepython = python3
deps =
feedparser
lxml
mutagen
git+https://github.com/brokkr/poca/@v0.8
commands =
poca --config ./ {posargs}
[testenv:poca-subscribe]
envdir = {toxworkdir}/poca
basepython = python3
deps =
feedparser
lxml
mutagen
git+https://github.com/brokkr/poca/@v0.8
commands =
poca-subscribe --config ./ {posargs}
[testenv:ansible]
deps =
ansible==2.3.0.0
commands =
ansible-galaxy install -r requirements.yml
ansible-playbook playbook.yml {posargs}
passenv = HOME TERM ANSIBLE_* AWS_*
setenv =
ANSIBLE_VERBOSITY=2
[testenv:pre-commit]
deps =
pre-commit==0.14.1
commands =
pre-commit {posargs}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment