diff --git a/.gitignore b/.gitignore index ba9b135..543baee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ # Custom -films/* -poster/* -mongo/db +films/ +poster/ +mongo/db/ +ansible/collections/ !.gitkeep # Logs diff --git a/README.md b/README.md index 565f04d..6cf5a59 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ ## Start +The [Production](#production) and [Development](#development) sections include informations to manually install the project. If you want to use a raspberry pi to host the project there is also a [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) role in this repository that you can use to install the project and setup a auto start. You can fin more information [here](#information-about-hosting-on-a-pi) + ### Production To run the latest official release download the `docker-compose.yml` and create a `films`, `mongo/db` and `poster` folder (or symlink for your media) in the same directory. So it should look kinda like this: @@ -115,9 +117,29 @@ see [here](DEPENDENCIES.md) ### Information about hosting on a pi -To run on a raspberry pi use either the [64-bit version](https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit) on `raspi 3+`
-or [ubuntu for raspberry pi](https://ubuntu.com/download/raspberry-pi) on `raspi 4+` +To run on a raspberry pi use the [64-bit version](https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit) on `raspi 3` or higher + +For the installation and the setup of the autostart you can use Ansible role in `./ansible/` + +> **IMPORTANT:** Ansible run on your pc, not on your pi and executes commands via a ssh connection. To use the role a [passwordless ssh connection](https://www.ssh.com/academy/ssh/copy-id) to the pi is necessary. +Once that is ensured, you can follow the steps below for installation and setup. + +1. [Install Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) on your pc +2. Download the repository on your pc +3. Navigate to the `ansible` folder of the repository +4. Install the requirements with: + +```sh +ansible-galaxy install -r requirements.yml +``` + +5. Customize the variables in the `vars/vars.yml` file to your liking +6. Start the role with: + +```sh +ansible-playbook install.yml +``` ### Information about remote easyfications diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 0000000..00a0627 --- /dev/null +++ b/ansible/ansible.cfg @@ -0,0 +1,5 @@ +[defaults] +roles_path = ./roles +inventory = ./inventory +collections_paths = ./collections + diff --git a/ansible/collections/.gitkeep b/ansible/collections/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/ansible/install.yml b/ansible/install.yml new file mode 100644 index 0000000..129ab32 --- /dev/null +++ b/ansible/install.yml @@ -0,0 +1,9 @@ +--- +- name: Install senior-movie-selector on a pie + hosts: pi + + vars_files: + - vars/vars.yml + + roles: + - senior-movie-selector diff --git a/ansible/inventory b/ansible/inventory new file mode 100644 index 0000000..6fb5bd9 --- /dev/null +++ b/ansible/inventory @@ -0,0 +1,2 @@ +[pi] +"{{ host_ip_address }}" \ No newline at end of file diff --git a/ansible/requirements.yml b/ansible/requirements.yml new file mode 100644 index 0000000..d764e63 --- /dev/null +++ b/ansible/requirements.yml @@ -0,0 +1,3 @@ +--- +collections: + - name: community.docker \ No newline at end of file diff --git a/ansible/roles/senior-movie-selector/README.md b/ansible/roles/senior-movie-selector/README.md new file mode 100644 index 0000000..fd28976 --- /dev/null +++ b/ansible/roles/senior-movie-selector/README.md @@ -0,0 +1,10 @@ +# General + +With this role you can install the [senior-movie-selector](https://github.com/JohannesFleischer/senior-movie-selector) project on a raspberry pi with the raspbian 64-bit OS + +Besides the installation there is also a autostart functionality added that automatically restarts the application on startup and starts chromium in fullscreen with the client opened. + +## Supported Platforms + +tested on and written for raspbian 64bit +the installation probably works also on other Debian based operating systems but the autostart on boot wont work diff --git a/ansible/roles/senior-movie-selector/defaults/main.yml b/ansible/roles/senior-movie-selector/defaults/main.yml new file mode 100644 index 0000000..5e86a3b --- /dev/null +++ b/ansible/roles/senior-movie-selector/defaults/main.yml @@ -0,0 +1,13 @@ +--- + +senior_movie_selector_version: "{{ version }}" + +senior_movie_selector_films_path: "{{ films_media_path }}" + +senior_movie_selector_poster_path: "{{ poster_media_path }}" + +senior_movie_selector_project_dir: "{{ project_dir }}" + +senior_movie_selector_project_owner: "{{ host_username }}" + +senior_movie_selector_setup_autostart: "{{ setup_autostart }}" \ No newline at end of file diff --git a/ansible/roles/senior-movie-selector/meta/main.yml b/ansible/roles/senior-movie-selector/meta/main.yml new file mode 100644 index 0000000..7870378 --- /dev/null +++ b/ansible/roles/senior-movie-selector/meta/main.yml @@ -0,0 +1,10 @@ +galaxy_info: + author: Johannes Fleischer + description: Sets up the Senior-Movie-selector project on raspbian (64bit). + + issue_tracker_url: https://github.com/JohannesFleischer/senior-movie-selector/issues + + license: All rights reserved. + + min_ansible_version: "2.1" + diff --git a/ansible/roles/senior-movie-selector/tasks/main.yml b/ansible/roles/senior-movie-selector/tasks/main.yml new file mode 100644 index 0000000..e57ac2a --- /dev/null +++ b/ansible/roles/senior-movie-selector/tasks/main.yml @@ -0,0 +1,78 @@ +--- +- name: Make sure directories exists + ansible.builtin.file: + path: "{{ item }}" + state: directory + mode: "0700" + loop: + - "{{ senior_movie_selector_project_dir }}" + - "{{ senior_movie_selector_project_dir }}/mongo/db" + - "/home/{{ senior_movie_selector_project_owner }}/.config/autostart" + +# Create films directory or symlink: +- name: Create 'films' directory if the path is empty + ansible.builtin.file: + path: "{{ senior_movie_selector_project_dir }}/films" + state: directory + mode: "0700" + when: senior_movie_selector_films_path == "" + +- name: Make sure the 'films' link exists if the path is not empty + ansible.builtin.file: + src: "{{ senior_movie_selector_films_path }}" + dest: "{{ senior_movie_selector_project_dir }}/films" + state: link + when: senior_movie_selector_films_path != "" + +# Create poster directory or symlink: +- name: Make sure the 'poster' directory exists if the path is empty + ansible.builtin.file: + path: "{{ senior_movie_selector_project_dir }}/poster" + state: directory + mode: "0700" + when: senior_movie_selector_poster_path == "" + +- name: Make sure the 'poster' link exists if the path is not empty + ansible.builtin.file: + src: "{{ senior_movie_selector_poster_path }}" + dest: "{{ senior_movie_selector_project_dir }}/poster" + state: link + when: senior_movie_selector_poster_path != "" + +# Create necessary files +- name: Download docker-compose.yml + ansible.builtin.get_url: + url: "https://raw.githubusercontent.com/JohannesFleischer/senior-movie-selector/{{ senior_movie_selector_version }}/docker-compose.yml" + dest: "{{ senior_movie_selector_project_dir }}/docker-compose.yml" + mode: "0700" + +- name: Create autostart files from template if selected + ansible.builtin.template: + src: "{{ item.src_file }}" + dest: "{{ item.dest_file }}" + mode: "0700" + loop: + - { + src_file: "senior-movie-selector.desktop.j2", + dest_file: "/home/{{ senior_movie_selector_project_owner }}/.config/autostart/senior-movie-selector.desktop" + } + - { + src_file: "senior-movie-selector.sh.j2", + dest_file: "/home/{{ senior_movie_selector_project_owner }}/Desktop/senior-movie-selector.sh" + } + when: senior_movie_selector_setup_autostart + +- name: Install pip + ansible.builtin.apt: + name: python3-pip + +- name: Install docker and docker-compose python package + ansible.builtin.pip: + name: + - docker + - docker-compose + +- name: Start senior-movie-selector + community.docker.docker_compose: + project_src: "{{ senior_movie_selector_project_dir }}" + state: present diff --git a/ansible/roles/senior-movie-selector/templates/senior-movie-selector.desktop.j2 b/ansible/roles/senior-movie-selector/templates/senior-movie-selector.desktop.j2 new file mode 100644 index 0000000..04b946c --- /dev/null +++ b/ansible/roles/senior-movie-selector/templates/senior-movie-selector.desktop.j2 @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Senior Movie Selector +Comment=Startet das senior-movie-selector Project +Type=Application +Hidden=false +NoDisplay=false +X-GNOME-Autostart-enabled=true +Exec=lxterminal -e "/home/{{ senior_movie_selector_project_owner }}/Desktop/senior-movie-selector.sh" \ No newline at end of file diff --git a/ansible/roles/senior-movie-selector/templates/senior-movie-selector.sh.j2 b/ansible/roles/senior-movie-selector/templates/senior-movie-selector.sh.j2 new file mode 100644 index 0000000..c60fd59 --- /dev/null +++ b/ansible/roles/senior-movie-selector/templates/senior-movie-selector.sh.j2 @@ -0,0 +1,6 @@ +#! /bin/sh + +echo "starting senior-movie-selector" +cd "{{ senior_movie_selector_project_dir }}" && sudo docker compose restart +xhost + && chromium-browser --disable-gpu --start-fullscreen localhost +exit 0 \ No newline at end of file diff --git a/ansible/vars/vars.yml b/ansible/vars/vars.yml new file mode 100644 index 0000000..043e46a --- /dev/null +++ b/ansible/vars/vars.yml @@ -0,0 +1,25 @@ +--- + +# The name of your pi user +host_username: pi + +# The local ip of your pi. The default value is just an example +host_ip_address: "192.168.178.63" + +# The release version of the senior-movie-selector project you want to install +version: v1.0.1 + +# The directory you want the project to be stored in on your pi +project_dir: "/home/{{ host_username }}/senior-movie-selector" + +# Path to the media folder with the films if you want to replace the default folders with links to the folder. Leave empty if thats not the case +films_media_path: "" + +# Path to the media folder with the poster if you want to replace the default folders with links to the folder. Leave empty if thats not the case +poster_media_path: "" + +# With this variable you can choose whether the autostart configuration should be applied. +# When activated this role adds two files that try to pull and restart the project on startup and launch chromium in fullscreen with the Client opened +# Options: true/false +setup_autostart: true +